Skip to content

Commit 635bb25

Browse files
RELEASE 2021.1 hotfix patch 01.03
1 parent 5f7f2ca commit 635bb25

22 files changed

Lines changed: 121 additions & 208 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# interference
22

33
##### java-based distributed database platform
4-
###### (c) 2010 - 2020 head systems, ltd
5-
###### current revision: release 2020.3
4+
###### (c) 2010 - 2021 head systems, ltd
5+
###### current revision: release 2021.1
66
###### for detailed information see:
7-
###### http://interference.su and doc/InterferenceManual.pdf
7+
###### http://io.digital and doc/InterferenceManual.pdf
88
###### contacts: info@inteference.su
99
##### https://github.com/interference-project/interference
1010

@@ -39,7 +39,7 @@ local persistent layer of the application and runs in the same JVM
3939
with the application.
4040

4141
To get started with interference, you need to download sources of
42-
the current interference release (2020.3), build it and install it
42+
the current interference release (2021.1), build it and install it
4343
into your local maven repository (mvn install).
4444
include the interference.jar library in your project configuration.
4545
For maven pom.xml, this might look like this:
@@ -49,7 +49,7 @@ For maven pom.xml, this might look like this:
4949
<dependency>
5050
<groupId>su.interference</groupId>
5151
<artifactId>interference</artifactId>
52-
<version>2020.2</version>
52+
<version>2021.1</version>
5353
</dependency>
5454
...
5555
</dependencies>

doc/InterferenceManual.pdf

-2.84 KB
Binary file not shown.

src/main/java/su/interference/core/Chunk.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -30,7 +30,6 @@ this software and associated documentation files (the "Software"), to deal in
3030

3131
import java.lang.reflect.Field;
3232
import java.lang.reflect.InvocationTargetException;
33-
import java.net.MalformedURLException;
3433

3534
/**
3635
* @author Yuriy Glotanov
@@ -48,6 +47,7 @@ public interface Chunk extends Comparable {
4847
boolean isTerminate();
4948
void setTerminate(boolean terminate);
5049
Object getEntity();
50+
Object getEntity(Session s);
5151
Object getUndoEntity();
5252
void updateEntity(Object o) throws InternalException, IllegalAccessException;
5353
UndoChunk getUndoChunk();

src/main/java/su/interference/core/DataChunk.java

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -218,23 +218,13 @@ public Comparable getId (Field idfield, Session s) throws InvocationTargetExcept
218218
for (int i = 0; i < f.length; i++) {
219219
final Id a = f[i].getAnnotation(Id.class);
220220
if (a != null) {
221-
if (sa != null) {
222-
id = (Comparable) f[i].get(entity);
223-
} else {
224-
Method z = c.getMethod("get" + f[i].getName().substring(0, 1).toUpperCase() + f[i].getName().substring(1, f[i].getName().length()), new Class<?>[]{Session.class});
225-
Object v = z.invoke(entity, new Object[]{s});
226-
id = (Comparable) v;
227-
}
221+
final Object entity_ = sa != null ? entity : getEntity(s);
222+
id = (Comparable) f[i].get(entity_);
228223
}
229224
}
230225
} else {
231-
if (sa != null) {
232-
id = (Comparable) idfield.get(entity);
233-
} else {
234-
Method z = c.getMethod("get" + idfield.getName().substring(0, 1).toUpperCase() + idfield.getName().substring(1, idfield.getName().length()), new Class<?>[]{Session.class});
235-
Object v = z.invoke(entity, new Object[]{s});
236-
id = (Comparable) v;
237-
}
226+
final Object entity_ = sa != null ? entity : getEntity(s);
227+
id = (Comparable) idfield.get(entity_);
238228
}
239229
}
240230
return id;
@@ -247,15 +237,10 @@ public byte[] getSerializedId (Session s) throws InvocationTargetException, NoSu
247237
}
248238
final Field idf = t.getIdField();
249239
if (idf != null) {
250-
if (t.isNoTran()) {
251-
final Method z = t.getIdmethod();
252-
id = (Comparable) z.invoke(entity, null);
253-
serializedId = this.external ? sr_.serialize(idf.getType().getName(), id) : sr.serialize(idf.getType().getName(), id);
254-
} else {
255-
final Method z = t.getIdmethod_();
256-
id = (Comparable) z.invoke(entity, new Object[]{s});
257-
serializedId = this.external ? sr_.serialize(idf.getType().getName(), id) : sr.serialize(idf.getType().getName(), id);
258-
}
240+
final Object entity_ = getEntity(s);
241+
final Method z = t.getIdmethod();
242+
id = (Comparable) z.invoke(entity_, null);
243+
serializedId = this.external ? sr_.serialize(idf.getType().getName(), id) : sr.serialize(idf.getType().getName(), id);
259244
}
260245

261246
}
@@ -502,6 +487,14 @@ public Object getExistingEntity() {
502487
return this.entity;
503488
}
504489

490+
public Object getEntity(Session s) {
491+
if (t.isNoTran()) {
492+
return getEntity();
493+
} else {
494+
return ((EntityContainer) getEntity()).getEntity(s);
495+
}
496+
}
497+
505498
public synchronized Object getEntity () {
506499
if (entity==null) {
507500
try {
@@ -850,18 +843,13 @@ public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
850843
}
851844

852845
public ValueSet getValueByColumnName(String[] columns, Session s) throws Exception {
853-
final Object o = this.getEntity();
854-
final Class c = o.getClass();
846+
final Class c = this.getEntity().getClass();
855847
final SystemEntity sa = (SystemEntity)c.getAnnotation(SystemEntity.class);
848+
final Object o = sa != null ? this.getEntity() : this.getEntity(s);
856849
final List<Object> res = new ArrayList<>();
857850
for (String name : columns) {
858-
if (sa != null) {
859-
final Method z = c.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1, name.length()), null);
860-
res.add(z.invoke(o, null));
861-
} else {
862-
final Method z = c.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1, name.length()), new Class<?>[]{Session.class});
863-
res.add(z.invoke(o, new Object[]{s}));
864-
}
851+
final Method z = c.getMethod("get" + name.substring(0, 1).toUpperCase() + name.substring(1, name.length()), null);
852+
res.add(z.invoke(o, null));
865853
}
866854
return new ValueSet(res.toArray(new Object[]{}));
867855
}

src/main/java/su/interference/core/DataChunkId.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -65,15 +65,10 @@ private byte[] getBytes(Field f, Object o) throws IllegalAccessException, Unsupp
6565
public DataChunkId (Object o, Table t, Session s) throws IOException, InvocationTargetException, InternalException, ClassNotFoundException, InstantiationException, IllegalAccessException {
6666
final Field idf = t.getIdField();
6767
if (idf != null) {
68-
if (t.isNoTran()) {
69-
final Method z = t.getIdmethod();
70-
id = z.invoke(o, null);
71-
idb = sr.serialize(idf.getType().getName(), id);
72-
} else {
73-
final Method z = t.getIdmethod_();
74-
id = z.invoke(o, new Object[]{s});
75-
idb = sr.serialize(idf.getType().getName(), id);
76-
}
68+
final Object o_ = t.isNoTran() ? o : ((EntityContainer) o).getEntity(s);
69+
final Method z = t.getIdmethod();
70+
id = z.invoke(o_, null);
71+
idb = sr.serialize(idf.getType().getName(), id);
7772
}
7873
}
7974

src/main/java/su/interference/core/EntityContainer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2019 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -24,6 +24,7 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.core;
2626

27+
import su.interference.persistent.Session;
2728
import su.interference.persistent.Transaction;
2829

2930
/**
@@ -34,6 +35,7 @@ this software and associated documentation files (the "Software"), to deal in
3435
public interface EntityContainer {
3536

3637
Transaction getTran();
38+
Object getEntity(Session s);
3739
void setTran(Transaction tran);
3840
su.interference.core.RowId getRowId();
3941
void setRowId(su.interference.core.RowId r);

src/main/java/su/interference/core/RetrieveQueue.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -24,6 +24,7 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.core;
2626

27+
import su.interference.persistent.Session;
2728
import java.util.concurrent.LinkedBlockingQueue;
2829

2930
/**
@@ -41,15 +42,15 @@ public RetrieveQueue(LinkedBlockingQueue<Chunk> q, ManagedCallable r) {
4142
this.r = r;
4243
}
4344

44-
public synchronized Object poll() {
45+
public synchronized Object poll(Session s) {
4546
try {
4647
if (retrieve) {
4748
Chunk c = q.take();
4849
if (c.isTerminate()) {
4950
stop();
5051
return null;
5152
}
52-
return c.getEntity();
53+
return c.getEntity(s);
5354
}
5455
} catch (Exception e) {
5556
e.printStackTrace();

src/main/java/su/interference/core/SystemCleanUp.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -103,10 +103,10 @@ private void cleanUpFrames() throws Exception {
103103
if (f.getDataFile().isIndex() && cleanupIndxEnabled()) {
104104
f.decreasePriority();
105105
xall++;
106-
if (f.getFrameType() == IndexFrame.INDEX_FRAME_NODE) {
106+
if (f.isSynced() && f.getFrameType() == IndexFrame.INDEX_FRAME_NODE) {
107107
xn++;
108108
}
109-
if (f.getFrameType() != IndexFrame.INDEX_FRAME_NODE && !f.isRbck() && frameAmount > Config.getConfig().IX_CLEANUP_PROTECTION_THR) {
109+
if (f.isSynced() && f.getFrameType() != IndexFrame.INDEX_FRAME_NODE && !f.isRbck() && frameAmount > Config.getConfig().IX_CLEANUP_PROTECTION_THR) {
110110
if (f.clearFrame()) {
111111
x++;
112112
}
@@ -116,7 +116,7 @@ private void cleanUpFrames() throws Exception {
116116
}
117117
}
118118
if (f.getDataFile().isTemp() && cleanupTempEnabled()) {
119-
if (f.getFrameType() != IndexFrame.INDEX_FRAME_NODE && frameAmount > Config.getConfig().CLEANUP_PROTECTION_THR) {
119+
if (f.isSynced() && f.getFrameType() != IndexFrame.INDEX_FRAME_NODE && frameAmount > Config.getConfig().CLEANUP_PROTECTION_THR) {
120120
if (f.clearFrame()) {
121121
i++;
122122
}

src/main/java/su/interference/persistent/FrameData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -107,7 +107,7 @@ public class FrameData implements Serializable, Comparable, FrameApi, FilePartit
107107
@Transient
108108
private volatile boolean synced = true;
109109
@Transient
110-
private volatile boolean rbck = true;
110+
private volatile boolean rbck;
111111
@Transient
112112
private volatile Frame frame;
113113
@Transient

src/main/java/su/interference/persistent/Session.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public Object find (String c, long id) throws Exception {
332332
if (t != null) {
333333
this.startStatement();
334334
final DataChunk dc = t.getChunkById(id, this);
335-
return dc == null ? null : dc.getStandaloneEntity();
335+
return dc == null ? null : ((EntityContainer) dc.getStandaloneEntity()).getEntity(this);
336336
}
337337
return null;
338338
}
@@ -398,7 +398,7 @@ public void run() {
398398
List<FrameData> frames = t.getStream(retrieved, s);
399399
for (FrameData b : frames) {
400400
for (Chunk c : b.getDataFrame().getChunks()) {
401-
Object o = c.getEntity();
401+
Object o = c.getEntity(s);
402402
task.call(o);
403403
}
404404
retrieved.put(b.getFrameId(), b.getAllocId());
@@ -416,7 +416,7 @@ public void run() {
416416
public Object nfind (Class c, long id) throws Exception {
417417
final Table t = Instance.getInstance().getTableByName(c.getName());
418418
if (t != null) {
419-
return t.getChunkById(id, this).getEntity();
419+
return t.getChunkById(id, this).getEntity(this);
420420
}
421421
return null;
422422
}

0 commit comments

Comments
 (0)