Skip to content

Commit 0e9fc71

Browse files
improve overall performance & stability
1 parent 19fdc8f commit 0e9fc71

21 files changed

Lines changed: 383 additions & 192 deletions

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

Lines changed: 3 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-2020 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
@@ -31,7 +31,6 @@ this software and associated documentation files (the "Software"), to deal in
3131
import java.util.Properties;
3232
import java.io.FileInputStream;
3333
import java.io.File;
34-
import java.io.FileNotFoundException;
3534
import java.io.IOException;
3635
import java.util.StringTokenizer;
3736

@@ -104,8 +103,10 @@ public class Config {
104103
public final boolean SYNC_LOCK_ENABLE;
105104
public final int SYNC_PERIOD;
106105
public final int RETRIEVE_QUEUE_SIZE;
106+
public final int RETRIEVE_THREADS_AMOUNT = 8;
107107
public final String CODEPAGE;
108108
public final String DATEFORMAT;
109+
public final int TEST_DISTRIBUTE_MODE = 1;
109110

110111
private final Properties p;
111112

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class DataChunk implements Chunk {
6363
private volatile byte[] chunk;
6464
private Comparable id;
6565
private byte[] serializedId;
66-
private Object entity;
66+
private volatile Object entity;
6767
private Object undoentity;
6868
private Map<Integer, DataChunk> ics = new HashMap<>();
6969
private UndoChunk uc;
@@ -470,7 +470,7 @@ public Object getExistingEntity() {
470470
return this.entity;
471471
}
472472

473-
public Object getEntity () {
473+
public synchronized Object getEntity () {
474474
if (entity==null) {
475475
try {
476476
final ValueSet dcs = getDcsFromBytes();
@@ -580,10 +580,6 @@ public Object getEntity (Class c, Object[] params) {
580580
return entity;
581581
}
582582

583-
public void setFrameData(FrameData b) {
584-
entity = b;
585-
}
586-
587583
@Deprecated
588584
public Object getUndoEntity () {
589585
if (undoentity==null) {
@@ -715,10 +711,6 @@ public void setEntity(Object entity) {
715711
}
716712
}
717713

718-
protected void setEntity(Object entity, boolean z) {
719-
this.entity = entity;
720-
}
721-
722714
//method for transactional objects ONLY
723715
public synchronized DataChunk lock (Session s, LLT llt) throws Exception {
724716
final Object o = this.getEntity();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public synchronized void removeChunk (int ptr, LLT llt, boolean ignore) {
507507
}
508508

509509
//returns all actual records
510-
public synchronized ArrayList<Chunk> getFrameChunks (Session s) {
510+
public ArrayList<Chunk> getFrameChunks (Session s) {
511511
final ArrayList<Chunk> res = new ArrayList<>();
512512

513513
if (dataObject==null) {

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

Lines changed: 8 additions & 9 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-2020 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
@@ -32,7 +32,7 @@ this software and associated documentation files (the "Software"), to deal in
3232
import javax.persistence.*;
3333
import java.io.Serializable;
3434
import java.lang.reflect.Modifier;
35-
import java.net.MalformedURLException;
35+
import java.util.List;
3636

3737
/**
3838
* @author Yuriy Glotanov
@@ -87,7 +87,7 @@ public class Cursor implements Serializable {
8787
@Transient
8888
private SQLSelect sqlStmt;
8989
@Transient
90-
private String resultTargetName;
90+
private List<String> resultTargetNames;
9191
@Transient
9292
private Session session;
9393
@Transient
@@ -101,22 +101,21 @@ public Cursor() {
101101
this.state = STATE_IDLE;
102102
}
103103

104-
public Cursor(String sql, String resultTargetName, int type) {
104+
public Cursor(String sql, List<String> resultTargetNames, int type) {
105105
this.state = STATE_IDLE;
106106
this.sql = sql;
107-
this.resultTargetName = resultTargetName;
107+
this.resultTargetNames = resultTargetNames;
108108
this.type = type;
109109
}
110110

111111
public Cursor(String sql, int type) {
112112
this.state = STATE_IDLE;
113-
this.cursorId = cursorId;
114113
this.sql = sql;
115114
this.type = type;
116115
}
117116

118117
//constructor for low-level storage function (initial first-time load table descriptions from datafile)
119-
public Cursor (DataChunk chunk) throws IllegalAccessException, ClassNotFoundException, InternalException, MalformedURLException {
118+
public Cursor (DataChunk chunk) throws IllegalAccessException, InternalException {
120119
final Object[] dcs = chunk.getDcs().getValueSet();
121120
final Class c = this.getClass();
122121
final java.lang.reflect.Field[] f = c.getDeclaredFields();
@@ -174,8 +173,8 @@ public void setSqlStmt(SQLSelect sqlStmt) {
174173
this.sqlStmt = sqlStmt;
175174
}
176175

177-
public String getResultTargetName() {
178-
return resultTargetName;
176+
public List<String> getResultTargetNames() {
177+
return resultTargetNames;
179178
}
180179

181180
public Session getSession() {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ public synchronized FrameData createNewFrame(FrameData frame, int frameType, lon
217217
//replace chunk after usedSpace
218218
dc = new DataChunk(bd, s);
219219
db.insertChunk(dc, s, true, llt);
220-
dc.setFrameData(bd);
221220
t.addIndexValue(dc);
222221
} else {
223222
//syncframe event should not persist new frame

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,19 @@ public IndexFrame getIndexFrame() throws Exception {
190190
return (IndexFrame) frame;
191191
}
192192

193-
public synchronized ArrayList<Chunk> getFrameChunks(Session s) throws Exception {
193+
public ArrayList<Chunk> getFrameChunks(Session s) throws Exception {
194194
if (getDataObject().isIndex()) {
195195
final IndexFrame f = getIndexFrame();
196-
f.sort();
196+
synchronized (this) {
197+
f.sort();
198+
}
197199
return f.getFrameChunks(s);
198200
} else {
199201
return getDataFrame().getFrameChunks(s);
200202
}
201203
}
202204

203-
public synchronized ArrayList<Object> getFrameEntities(Session s) throws Exception {
205+
public ArrayList<Object> getFrameEntities(Session s) throws Exception {
204206
final ArrayList<Object> res = new ArrayList<>();
205207
for (Chunk c : getFrameChunks(s)) {
206208
res.add(((DataChunk)c).getEntity());

src/main/java/su/interference/sql/FrameApiJoin.java

Lines changed: 14 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-2019 head systems, ltd
4+
Copyright (c) 2010-2020 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,8 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.sql;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729
import su.interference.core.Config;
2830
import su.interference.metrics.Metrics;
2931

@@ -38,6 +40,7 @@ this software and associated documentation files (the "Software"), to deal in
3840
*/
3941

4042
public class FrameApiJoin implements Serializable, Callable<FrameApiJoin> {
43+
private final static Logger logger = LoggerFactory.getLogger(FrameApiJoin.class);
4144
private final int nodeId;
4245
private final transient FrameApi bd1;
4346
private final transient FrameApi bd2;
@@ -61,12 +64,20 @@ public FrameApiJoin(int nodeId, SQLCursor cur, FrameApi bd1, FrameApi bd2) {
6164
}
6265
}
6366

64-
public FrameApiJoin call() throws Exception {
67+
public FrameApiJoin call() throws InterruptedException {
68+
final Thread thread = Thread.currentThread();
6569
if (nodeId == Config.getConfig().LOCAL_NODE_ID) {
70+
thread.setName("interference-sql-join-task-" + thread.getId());
6671
Metrics.get("localTask").start();
67-
result = frameJoinTask.call();
72+
try {
73+
result = frameJoinTask.call();
74+
} catch (Exception e) {
75+
failed = true;
76+
logger.error("join task", e);
77+
}
6878
Metrics.get("localTask").stop();
6979
} else {
80+
thread.setName("interference-sql-remote-task-" + thread.getId());
7081
Metrics.get("remoteTask").start();
7182
latch.await();
7283
Metrics.get("remoteTask").stop();

src/main/java/su/interference/sql/FrameIterator.java

Lines changed: 2 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-2019 head systems, ltd
4+
Copyright (c) 2010-2020 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
@@ -26,8 +26,6 @@ this software and associated documentation files (the "Software"), to deal in
2626

2727
import su.interference.exception.InternalException;
2828

29-
import java.io.IOException;
30-
import java.lang.reflect.InvocationTargetException;
3129
import java.net.MalformedURLException;
3230
import java.util.List;
3331

@@ -50,5 +48,6 @@ public interface FrameIterator {
5048
List<Integer> getObjectIds();
5149
boolean isLeftfs();
5250
void setLeftfs(boolean leftfs);
51+
boolean noDistribute();
5352

5453
}

0 commit comments

Comments
 (0)