Skip to content

Commit 5790d85

Browse files
Merge pull request #27 from yuriy-glotanov/2020.1beta
2020.1beta
2 parents 64ab2f6 + e6d6c0d commit 5790d85

10 files changed

Lines changed: 185 additions & 157 deletions

File tree

interference-2020.1.jar

751 Bytes
Binary file not shown.

interference-2020.1.jar.md5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c790f85b766e557a220bfbc57ba76047 *interference-2020.1.jar
1+
dda5a3ba8ed161e2bbab852457b37b5d *interference-2020.1.jar

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,11 @@ public Object getEntity () {
527527
final DataChunk dc = (DataChunk) Instance.getInstance().getChunkByPointer(this.getHeader().getFramePtr(), this.getHeader().getFramePtrRowId().getRowPointer());
528528
((IndexChunk)o).setDataChunk(dc);
529529
if (dc == null) {
530-
final long allocId = Instance.getInstance().getFrameById(this.header.getRowID().getFileId()+this.header.getRowID().getFramePointer()).getAllocId();
531-
final long allocId2 = Instance.getInstance().getFrameById(this.getHeader().getFramePtr()).getAllocId();
532-
logger.error("null datachunk found for indexframe allocId = " + allocId + " indexptr allocId = " + allocId2);
530+
// todo during rframe.IndexFrame.init system directory not yet contains replicated FrameData objects
531+
// final long allocId = Instance.getInstance().getFrameById(this.header.getRowID().getFileId()+this.header.getRowID().getFramePointer()).getAllocId();
532+
// final long allocId2 = Instance.getInstance().getFrameById(this.getHeader().getFramePtr()).getAllocId();
533+
// logger.error("null datachunk found for indexframe allocId = " + allocId + " indexptr allocId = " + allocId2);
534+
logger.error("null datachunk found");
533535
}
534536
}
535537
if (!t.isNoTran()) {

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.core;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
29+
2730
import java.util.concurrent.atomic.AtomicLong;
2831
import java.util.concurrent.locks.ReentrantLock;
2932
import java.util.concurrent.ConcurrentHashMap;
@@ -41,32 +44,55 @@ public class LLT {
4144
private static final ReentrantLock rlck = new ReentrantLock();
4245
private static final ConcurrentHashMap<Long, LLT> pool = new ConcurrentHashMap<Long, LLT>();
4346
private static final ConcurrentHashMap<Long, Frame> frames = new ConcurrentHashMap<Long, Frame>();
47+
private final static Logger logger = LoggerFactory.getLogger(LLT.class);
4448
private final boolean lock;
4549
private final long id;
50+
private final StackTraceElement[] trace;
51+
52+
// WARNING!!!
53+
// change of 'debug' value to true causes decrease total performance
54+
// dev & QA engineers may change this constant
55+
private static final boolean debug = false;
4656

47-
private LLT(boolean lock) {
48-
id = cntr.incrementAndGet();
57+
private LLT(long id, boolean lock) {
58+
this.id = id;
4959
this.lock = lock;
60+
this.trace = debug ? Thread.currentThread().getStackTrace() : null;
5061
}
5162

5263
public static long getSyncId() {
5364
return sync.get();
5465
}
5566

5667
public static LLT getLLT() throws InterruptedException {
68+
final long id_ = Thread.currentThread().getId();
69+
if (pool.get(id_) != null) {
70+
if (debug) {
71+
for (StackTraceElement e : pool.get(id_).getTrace()) {
72+
logger.info(e.toString());
73+
}
74+
}
75+
logger.error("an unexpected attempt to get llt with id = "+id_+" which already exists");
76+
throw new RuntimeException("an unexpected attempt to get llt with id = "+id_+" which already exists");
77+
}
5778
rlck.lock();
58-
final LLT llt = new LLT(false);
79+
final LLT llt = new LLT(id_, false);
5980
pool.put(llt.getId(), llt);
6081
rlck.unlock();
6182
return llt;
6283
}
6384

6485
public static LLT getLLTAndLock() throws InterruptedException {
86+
final long id_ = Thread.currentThread().getId();
87+
if (pool.get(id_) != null) {
88+
logger.error("an unexpected attempt to get llt with id = "+id_+" which already exists");
89+
throw new RuntimeException("an unexpected attempt to get llt with id = "+id_+" which already exists");
90+
}
6591
if (Config.getConfig().SYNC_LOCK_ENABLE) {
6692
rlck.lock();
6793
}
6894
while(poolNotEmpty()) { }
69-
final LLT llt = new LLT(true);
95+
final LLT llt = new LLT(id_, true);
7096
sync.compareAndSet(0, llt.getId());
7197
pool.put(llt.getId(), llt);
7298
return llt;
@@ -103,4 +129,7 @@ public long getId() {
103129
return id;
104130
}
105131

132+
public StackTraceElement[] getTrace() {
133+
return trace;
134+
}
106135
}

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class SyncFrame implements Comparable, Serializable, AllowRPredicate {
4646
private final long allocId;
4747
private final int fileType;
4848
private final int frameType;
49-
private final int objectId;
5049
private final String className;
5150
private long prevId;
5251
private long nextId;
@@ -56,6 +55,7 @@ public class SyncFrame implements Comparable, Serializable, AllowRPredicate {
5655
private final boolean started;
5756
private FrameData bd;
5857
private DataFile df;
58+
private Frame rFrame;
5959
private final HashMap<Long, Long> imap;
6060
private final HashMap<Long, Transaction> rtran;
6161
private final ArrayList<TransFrame> tframes;
@@ -64,19 +64,21 @@ public class SyncFrame implements Comparable, Serializable, AllowRPredicate {
6464
public SyncFrame(Frame frame, Session s, FreeFrame fb) throws Exception {
6565
final Table t = Instance.getInstance().getTableById(frame.getObjectId());
6666
final FrameData bd = Instance.getInstance().getFrameById(frame.getPtr());
67-
if (bd == null) {
67+
allowR = frame.isLocal() ? !t.isNoTran() || t.getName().equals("su.interference.persistent.UndoChunk") : false;
68+
69+
if (bd == null && allowR) {
6870
final FreeFrame fframe = Instance.getInstance().getFreeFrameById(frame.getPtr());
6971
if (fframe == null) {
7072
logger.error(frame.getClass().getSimpleName()+" does not match any system objects");
7173
throw new InternalException();
74+
} else {
75+
fframe.setPassed(1);
76+
fb = fframe;
7277
}
73-
fframe.setPassed(1);
74-
fb = fframe;
7578
//throw new MissingSyncFrameException();
7679
}
7780

78-
allowR = frame.isLocal() ? !t.isNoTran() || t.getName().equals("su.interference.persistent.UndoChunk") : false;
79-
className = t.getName();
81+
className = bd == null ? null : t.getName();
8082
rtran = frame.getLiveTransactions();
8183
tframes = frame.getLiveTransFrames();
8284
if (frame.getClass().getName().equals("su.interference.core.DataFrame")) {
@@ -125,7 +127,14 @@ public SyncFrame(Frame frame, Session s, FreeFrame fb) throws Exception {
125127
b = frame.getFrame();
126128
frameId = frame.getPtr();
127129
this.allocId = frame.getAllocFile()+ frame.getAllocPointer();
128-
objectId = bd == null ? 0 : frame.getObjectId();
130+
}
131+
132+
public Frame getRFrame() {
133+
return rFrame;
134+
}
135+
136+
public void setRFrame(Frame rFrame) {
137+
this.rFrame = rFrame;
129138
}
130139

131140
public byte[] getBytes() {
@@ -148,10 +157,6 @@ public int getFrameType() {
148157
return frameType;
149158
}
150159

151-
public int getObjectId() {
152-
return objectId;
153-
}
154-
155160
public int getFile() {
156161
return (int)frameId%4096;
157162
}

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

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ public class FrameData implements Serializable, Comparable, FrameApi, FilePartit
9696
@Column
9797
private AtomicInteger current;
9898
@Column
99-
@IndexColumn
10099
private volatile int started;
101-
@Column
102-
@IndexColumn
103-
private AtomicInteger allocated;
104100
@Id
105101
@MapColumn
106102
@Transient
@@ -156,19 +152,6 @@ public void clearCurrent() {
156152
}
157153
}
158154

159-
public void allocate() {
160-
if (this.allocated==null) {
161-
this.allocated = new AtomicInteger(0);
162-
}
163-
this.allocated.compareAndSet(0, 1);
164-
}
165-
166-
public void deallocate() {
167-
if (this.allocated!=null) {
168-
this.allocated.compareAndSet(1, 0);
169-
}
170-
}
171-
172155
public DataObject getDataObject() {
173156
if (dataObject==null) {
174157
dataObject = Instance.getInstance().getTableById(this.objectId);
@@ -227,10 +210,6 @@ public void setFrame(Frame b) {
227210
this.frame = b;
228211
}
229212

230-
public FrameData() {
231-
this.allocated = new AtomicInteger();
232-
}
233-
234213
public long getFrameId() {
235214
return this.ptr+this.file;
236215
}
@@ -322,14 +301,34 @@ public int hasRemoteTransactions() throws InternalException {
322301
return nodeId;
323302
}
324303

304+
public FrameData() {
305+
306+
}
307+
325308
public FrameData(int file, long ptr, int size, DataObject tt) {
326309
this.dataObject = tt;
327310
this.objectId = tt.getObjectId();
328311
this.allocId = file+ptr;
329312
this.file = file;
330313
this.ptr = ptr;
331314
this.size = size;
332-
this.allocated = new AtomicInteger();
315+
}
316+
317+
public FrameData(FrameData bd, DataObject tt) {
318+
this.dataObject = tt;
319+
this.objectId = tt.getObjectId();
320+
this.allocId = bd.getFile()+bd.getPtr();
321+
this.file = bd.getFile();
322+
this.ptr = bd.getPtr();
323+
this.size = bd.getSize();
324+
this.allocId = bd.getAllocId();
325+
this.started = bd.getStarted();
326+
this.current = bd.getCurrent();
327+
this.used = bd.getUsed();
328+
this.prevFrame = bd.getPrevFrame();
329+
this.prevFile = bd.getPrevFile();
330+
this.nextFrame = bd.getNextFrame();
331+
this.nextFile = bd.getNextFile();
333332
}
334333

335334
public int compareTo(Object obj) {
@@ -371,10 +370,6 @@ public int getObjectId() {
371370
return objectId;
372371
}
373372

374-
public void setObjectId(int objectId) {
375-
this.objectId = objectId;
376-
}
377-
378373
public int getFile() {
379374
return file;
380375
}
@@ -490,12 +485,4 @@ public int getStarted() {
490485
public void setStarted(int started) {
491486
this.started = started;
492487
}
493-
494-
public AtomicInteger getAllocated() {
495-
return allocated;
496-
}
497-
498-
public void setAllocated(AtomicInteger allocated) {
499-
this.allocated = allocated;
500-
}
501488
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ this software and associated documentation files (the "Software"), to deal in
3434
*/
3535

3636
@Entity
37-
@SystemEntity
3837
public class Source {
3938
@Column
4039
@Id

0 commit comments

Comments
 (0)