Skip to content

Commit 42d22f6

Browse files
Merge pull request #20 from yuriy-glotanov/2020.1beta
release 2020.1 beta (unstable)
2 parents 58c1e74 + 788e089 commit 42d22f6

31 files changed

Lines changed: 719 additions & 400 deletions

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
##### simple distributed persistent layer for java applications
44
##### (c) 2010 - 2020 head systems, ltd
5-
##### current revision: 2019.3
5+
##### current revision: 2020.1 beta (unstable)
66
##### for detailed information see doc/InterferenceManual.pdf
77

88
##### contacts: info@inteference.su
@@ -13,6 +13,7 @@
1313

1414
- supports Base JPA annotations
1515
- supports local & distributed SQL queries
16+
- supports complex event processing and streaming SQL
1617
- supports transactions
1718
- supports unique constraints
1819
- supports persistent indexes
@@ -25,7 +26,7 @@
2526
included in the cluster
2627
- does not contain any coordination nodes and does not require
2728
the launch of any additional coordinators. All cluster nodes are equivalent.
28-
- supports complex event processing and streaming SQL (in next release)
29+
2930

3031
## NOTE:
3132

@@ -53,7 +54,7 @@ like this:
5354
<dependency>
5455
<groupId>su.interference</groupId>
5556
<artifactId>interference</artifactId>
56-
<version>2019.3</version>
57+
<version>2020.1</version>
5758
</dependency>
5859
...
5960
</dependencies>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
<groupId>su.interference</groupId>
99
<artifactId>interference</artifactId>
10-
<version>2019.3</version>
10+
<version>2020.1</version>
1111
<packaging>jar</packaging>
1212

1313
<name>interference</name>
14-
<description>distributed persistent layer with JPA/SQL support</description>
14+
<description>distributed persistent layer with JPA/SQL/CEP support</description>
1515
<url>https://github.com/interference-project/interference</url>
1616

1717
<licenses>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public interface Chunk extends Comparable {
4545
int getBytesAmount();
4646
Comparable getId (Session s) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException;
4747
ValueSet getDcs();
48+
boolean isTerminate();
49+
void setTerminate(boolean terminate);
4850
Object getEntity() throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException;
4951
Object getUndoEntity() throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException;
5052
void updateEntity(Object o) throws InternalException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, MalformedURLException;

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) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class DataChunk implements Chunk {
6363
private Object undoentity;
6464
private DataChunk source;
6565
private UndoChunk uc;
66+
private boolean terminate;
6667
private final CustomSerializer sr = new CustomSerializer();
6768

6869
//returns datacolumn set
@@ -882,6 +883,14 @@ protected synchronized void undo(Session s, LLT llt) throws Exception {
882883
}
883884
}
884885

886+
public boolean isTerminate() {
887+
return terminate;
888+
}
889+
890+
public void setTerminate(boolean terminate) {
891+
this.terminate = terminate;
892+
}
893+
885894
private byte[] getBytesFromHexString(String s) {
886895
byte b[] = new byte[s.length()/2];
887896
for (int i=0; i<s.length(); i+=2) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ private void startProcesses(Session s) throws Exception {
435435
}
436436

437437
private void stopProcesses(Session s) throws Exception {
438-
final Table t = getTableByName("su.interference.persistent.Process");
439-
final ArrayList<Object> pss = t.getAll(s, 0);
438+
final List<Process> pss = getProcesses();
440439
for (Object p : pss) {
441440
final Process ps = (Process) p;
442441
ps.stop();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
25+
package su.interference.core;
26+
27+
import java.util.concurrent.Callable;
28+
29+
/**
30+
* @author Yuriy Glotanov
31+
* @since 1.0
32+
*/
33+
34+
public interface ManagedCallable<T> extends Callable<T> {
35+
void stop();
36+
}

src/main/java/su/interference/core/ManageProcess.java renamed to src/main/java/su/interference/core/ManagedProcess.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
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-
25-
package su.interference.core;
26-
27-
/**
28-
* @author Yuriy Glotanov
29-
* @since 1.0
30-
*/
31-
32-
public interface ManageProcess {
33-
void stop() throws InterruptedException;
34-
}
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+
25+
package su.interference.core;
26+
27+
/**
28+
* @author Yuriy Glotanov
29+
* @since 1.0
30+
*/
31+
32+
public interface ManagedProcess {
33+
void stop() throws InterruptedException;
34+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
25+
package su.interference.core;
26+
27+
import java.util.concurrent.LinkedBlockingQueue;
28+
29+
/**
30+
* @author Yuriy Glotanov
31+
* @since 1.0
32+
*/
33+
34+
public class RetrieveQueue {
35+
private final LinkedBlockingQueue<Chunk> q;
36+
private final ManagedCallable r;
37+
private boolean retrieve = true;
38+
39+
public RetrieveQueue(LinkedBlockingQueue<Chunk> q, ManagedCallable r) {
40+
this.q = q;
41+
this.r = r;
42+
}
43+
44+
public Object poll() {
45+
try {
46+
if (retrieve) {
47+
Chunk c = q.take();
48+
if (c.isTerminate()) {
49+
stop();
50+
return null;
51+
}
52+
return c.getEntity();
53+
}
54+
} catch (Exception e) {
55+
e.printStackTrace();
56+
}
57+
return null;
58+
}
59+
60+
public Chunk cpoll() {
61+
try {
62+
if (retrieve) {
63+
Chunk c = q.take();
64+
if (c.isTerminate()) {
65+
stop();
66+
return null;
67+
}
68+
return c;
69+
}
70+
} catch (Exception e) {
71+
e.printStackTrace();
72+
}
73+
return null;
74+
}
75+
76+
public void stop() {
77+
retrieve = false;
78+
if (r != null) {
79+
r.stop();
80+
}
81+
}
82+
83+
public LinkedBlockingQueue<Chunk> getQ() {
84+
return q;
85+
}
86+
87+
public ManagedCallable getR() {
88+
return r;
89+
}
90+
91+
public boolean isRetrieve() {
92+
return retrieve;
93+
}
94+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ this software and associated documentation files (the "Software"), to deal in
4141
* @since 1.0
4242
*/
4343

44-
public class SyncQueue implements Runnable, ManageProcess {
44+
public class SyncQueue implements Runnable, ManagedProcess {
4545

4646
private volatile boolean f = true;
4747
private volatile boolean running = false;
@@ -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();

0 commit comments

Comments
 (0)