Skip to content

Commit 179056c

Browse files
pre-release 2020.1 final beta
1 parent 727d87d commit 179056c

19 files changed

Lines changed: 290 additions & 88 deletions

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class Config {
5959
private static final String P_DISKIO_MODE = "diskio.mode";
6060
private static final String P_SYNC_LOCK_ENABLE = "sync.lock.enable";
6161
private static final String P_SYNC_PERIOD = "sync.period";
62+
private static final String P_RETRIEVE_QUEUE_SIZE = "retrieve.queue.size";
6263
private static final String P_CODEPAGE = "codepage";
6364
private static final String P_DATEFORMAT = "dateformat";
6465
private static final int MAX_NODE_ID = 64;
@@ -80,7 +81,8 @@ public class Config {
8081
private static final int FILES_AMOUNT_DEFAULT=4;
8182
private static final String DISKIO_MODE_DEFAULT="rws";
8283
private static final boolean SYNC_LOCK_ENABLE_DEFAULT=false;
83-
private static final int SYNC_PERIOD_DEFAULT=5;
84+
private static final int SYNC_PERIOD_DEFAULT=2000;
85+
private static final int RETRIEVE_QUEUE_SIZE_DEFAULT=10000;
8486
private static final String CODEPAGE_DEFAULT="UTF-8";
8587
private static final String DATEFORMAT_DEFAULT="dd.MM.yyyy";
8688

@@ -101,6 +103,7 @@ public class Config {
101103
public final String DISKIO_MODE;
102104
public final boolean SYNC_LOCK_ENABLE;
103105
public final int SYNC_PERIOD;
106+
public final int RETRIEVE_QUEUE_SIZE;
104107
public final String CODEPAGE;
105108
public final String DATEFORMAT;
106109

@@ -158,6 +161,7 @@ private Config() {
158161
DISKIO_MODE = validateDiskioMode(p.getProperty(P_DISKIO_MODE));
159162
SYNC_LOCK_ENABLE = validateSyncLock(p.getProperty(P_SYNC_LOCK_ENABLE));
160163
SYNC_PERIOD = validateSyncPeriod(p.getProperty(P_SYNC_PERIOD));
164+
RETRIEVE_QUEUE_SIZE = validateQueueSize(p.getProperty(P_RETRIEVE_QUEUE_SIZE));
161165
} else {
162166
DB_PATH = DB_PATH_DEFAULT;
163167
JOURNAL_PATH = JOURNAL_PATH_DEFAULT;
@@ -178,6 +182,7 @@ private Config() {
178182
DISKIO_MODE = DISKIO_MODE_DEFAULT;
179183
SYNC_LOCK_ENABLE = SYNC_LOCK_ENABLE_DEFAULT;
180184
SYNC_PERIOD = SYNC_PERIOD_DEFAULT;
185+
RETRIEVE_QUEUE_SIZE = RETRIEVE_QUEUE_SIZE_DEFAULT;
181186
}
182187
System.setProperty("com.sun.management.jmxremote.port","8111");
183188
System.setProperty("com.sun.management.jmxremote.authenticate","false");
@@ -324,7 +329,19 @@ private static String validateDiskioMode(String mode) {
324329
private static int validateSyncPeriod(String value) {
325330
try {
326331
int p = Integer.valueOf(value);
327-
if (p > 0 && p < 10000) {
332+
if (p > 9 && p < 60001) {
333+
return p;
334+
}
335+
} catch(NumberFormatException e) {
336+
logger.error("sync period value is not valid - use default value");
337+
}
338+
return SYNC_PERIOD_DEFAULT;
339+
}
340+
341+
private static int validateQueueSize(String value) {
342+
try {
343+
int p = Integer.valueOf(value);
344+
if (p > 0 && p < 100000000) {
328345
return p;
329346
}
330347
} catch(NumberFormatException e) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1+
/**
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2010-2019 head systems, ltd
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
*/
24+
125
package su.interference.core;
226

327
import java.util.concurrent.Callable;
428

29+
/**
30+
* @author Yuriy Glotanov
31+
* @since 1.0
32+
*/
33+
534
public interface ManagedCallable<T> extends Callable<T> {
635
void stop();
736
}

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1+
/**
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2010-2019 head systems, ltd
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
*/
24+
125
package su.interference.core;
226

327
import java.util.concurrent.LinkedBlockingQueue;
428

29+
/**
30+
* @author Yuriy Glotanov
31+
* @since 1.0
32+
*/
33+
534
public class RetrieveQueue {
635
private final LinkedBlockingQueue<Chunk> q;
736
private final ManagedCallable r;
@@ -17,7 +46,7 @@ public Object poll() {
1746
if (retrieve) {
1847
Chunk c = q.take();
1948
if (c.isTerminate()) {
20-
retrieve = false;
49+
stop();
2150
return null;
2251
}
2352
return c.getEntity();
@@ -33,7 +62,7 @@ public Chunk cpoll() {
3362
if (retrieve) {
3463
Chunk c = q.take();
3564
if (c.isTerminate()) {
36-
retrieve = false;
65+
stop();
3766
return null;
3867
}
3968
return c;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void run () {
141141
}
142142

143143
try {
144-
final int period = Config.getConfig().SYNC_PERIOD*1000;
144+
final int period = Config.getConfig().SYNC_PERIOD;
145145
Thread.sleep(period);
146146
} catch (InterruptedException e) {
147147
e.printStackTrace();

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,15 @@ this software and associated documentation files (the "Software"), to deal in
3535
import su.interference.proxy.RSProxyFactory;
3636
import su.interference.sql.ResultSet;
3737
import su.interference.sql.SQLColumn;
38+
import su.interference.sql.SQLCursor;
3839
import su.interference.sql.SQLSelect;
3940

4041
import java.util.*;
4142
import java.io.IOException;
4243
import java.lang.reflect.InvocationTargetException;
4344
import java.lang.reflect.Modifier;
4445
import java.net.MalformedURLException;
45-
import java.util.concurrent.ConcurrentHashMap;
46-
import java.util.concurrent.ExecutorService;
47-
import java.util.concurrent.Executors;
48-
import java.util.concurrent.Future;
46+
import java.util.concurrent.*;
4947
import javax.persistence.*;
5048

5149
/**
@@ -285,9 +283,18 @@ public Object find (Class c, long id) throws Exception {
285283

286284
protected synchronized RetrieveQueue getContentQueue(Table t) {
287285
if (t != null) {
288-
retrieveQueue = t.getContentQueue(this);
289-
Future f = rqpool.submit(retrieveQueue.getR());
290-
return retrieveQueue;
286+
try {
287+
retrieveQueue = t.getContentQueue(this);
288+
Future f = rqpool.submit(retrieveQueue.getR());
289+
Object o = f.get();
290+
return retrieveQueue;
291+
} catch (Exception e) {
292+
if (e instanceof ExecutionException) {
293+
e.getCause().printStackTrace();
294+
} else {
295+
e.printStackTrace();
296+
}
297+
}
291298
}
292299
return null;
293300
}
@@ -299,6 +306,10 @@ public void closeQueue() {
299306
retrieveQueue = null;
300307
}
301308

309+
public void closeStreamQueue() {
310+
SQLCursor.removeStreamQueue(this);
311+
}
312+
302313
public void close() {
303314
rqpool.shutdownNow();
304315
streampool.isShutdown();

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ protected RetrieveQueue getContentQueue(Session s) {
12911291
protected synchronized RetrieveQueue getTableContentQueue(Session s) {
12921292
final Table t = this;
12931293
final int ptr = 0;
1294-
final LinkedBlockingQueue<Chunk> q = new LinkedBlockingQueue<>();
1294+
final LinkedBlockingQueue<Chunk> q = new LinkedBlockingQueue<>(Config.getConfig().RETRIEVE_QUEUE_SIZE);
12951295
final AtomicBoolean stopped = new AtomicBoolean();
12961296
final Chunk tc = new DataChunk();
12971297
tc.setTerminate(true);
@@ -1330,7 +1330,7 @@ public void stop() {
13301330
protected synchronized RetrieveQueue getIndexContentQueue(Session s) {
13311331
final Table t = this;
13321332
final int ptr = 0;
1333-
final LinkedBlockingQueue<Chunk> q = new LinkedBlockingQueue<>();
1333+
final LinkedBlockingQueue<Chunk> q = new LinkedBlockingQueue<>(Config.getConfig().RETRIEVE_QUEUE_SIZE);
13341334
final AtomicBoolean stopped = new AtomicBoolean();
13351335
final Chunk tc = new DataChunk();
13361336
tc.setTerminate(true);
@@ -1506,11 +1506,6 @@ public DataChunk getChunkByEntity (Object o, Session s) throws IOException, Invo
15061506
}
15071507
}
15081508
} else {
1509-
if (this.idfield!=null&&this.generatedfield!=null) {
1510-
if (this.idfield.equals(this.generatedfield)) {
1511-
return null;
1512-
}
1513-
}
15141509
final EntityContainer to = (EntityContainer)o;
15151510
final Table idt = getFirstIndexByIdColumn();
15161511
if (to.getDataChunk()==null) {

src/main/java/su/interference/proxy/GenericResultImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public String toString() {
6262
sb.append(m.getName().substring(3).substring(1));
6363
sb.append(":");
6464
sb.append(m.invoke(this, null));
65+
sb.append(" ");
6566
}
6667
}
6768
} catch (Exception e) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ this software and associated documentation files (the "Software"), to deal in
2929
import su.interference.sqlexception.MissingTablesDescription;
3030
import su.interference.sqlexception.AmbiguousColumnName;
3131
import su.interference.sqlexception.InvalidColumnDescription;
32-
import su.interference.core.Instance;
3332
import su.interference.exception.InternalException;
3433

3534
import java.util.ArrayList;
3635
import java.util.Collections;
3736
import java.lang.reflect.Field;
38-
import java.net.MalformedURLException;
3937
import java.util.List;
4038

4139
/**

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ public void run() {
8181
}
8282
}
8383
//return last group after stop
84+
/*
8485
final DataChunk gdc = sqlg.add(null);
8586
if (gdc != null) {
8687
Object oo = gdc.getEntity(gtable);
8788
target.persist(oo, s);
8889
}
90+
*/
8991

9092

9193
} catch (Exception e) {
92-
((StreamQueue) target).stop(s);
94+
((StreamQueue) target).stop();
9395
logger.error("", e);
9496
}
9597
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ this software and associated documentation files (the "Software"), to deal in
3030
import su.interference.metrics.Metrics;
3131
import su.interference.persistent.*;
3232
import su.interference.proxy.GenericResult;
33-
import su.interference.transport.SQLEvent;
34-
import su.interference.transport.TransportContext;
35-
import su.interference.transport.TransportEvent;
3633

3734
import java.util.List;
3835
import java.util.concurrent.Callable;

0 commit comments

Comments
 (0)