Skip to content

Commit 91d6bd9

Browse files
authored
Issue #837対応 (#838)
Co-authored-by: m-takata <[email protected]>
1 parent ca3dd49 commit 91d6bd9

10 files changed

+754
-292
lines changed

.classpath

+224-173
Large diffs are not rendered by default.

.factorypath

+176
Large diffs are not rendered by default.

.project

+32-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>nimbus</name>
4-
<comment>Nimbus Framework. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
5-
<projects/>
6-
<buildSpec>
7-
<buildCommand>
8-
<name>org.eclipse.jdt.core.javabuilder</name>
9-
</buildCommand>
10-
</buildSpec>
11-
<natures>
12-
<nature>org.eclipse.jdt.core.javanature</nature>
13-
</natures>
14-
</projectDescription>
3+
<name>nimbus</name>
4+
<comment>Nimbus Framework. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1618964800893</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
23
encoding//src/main/java/jp/ossc/nimbus/beans/dataset/DataSet.java=UTF-8
34
encoding//src/main/java/jp/ossc/nimbus/beans/dataset/Record.java=UTF-8
45
encoding//src/main/java/jp/ossc/nimbus/beans/dataset/RecordSchema.java=UTF-8
6+
encoding//src/main/resources=UTF-8
7+
encoding//src/test/java=UTF-8
8+
encoding//src/test/resources=UTF-8
59
encoding/<project>=UTF-8
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.apt.aptEnabled=true
3+
org.eclipse.jdt.apt.genSrcDir=target\\generated-sources\\annotations
4+
org.eclipse.jdt.apt.genTestSrcDir=target\\generated-test-sources\\test-annotations

.settings/org.eclipse.jdt.core.prefs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
#Thu May 24 18:59:17 JST 2018
21
eclipse.preferences.version=1
32
encoding/src/main/java=UTF-8
4-
encoding/src/test/resources=UTF-8
5-
encoding/src/test/java=UTF-8
63
encoding/src/main/resources=UTF-8
4+
encoding/src/test/java=UTF-8
5+
encoding/src/test/resources=UTF-8
6+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
7+
org.eclipse.jdt.core.compiler.compliance=1.6
8+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
9+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
10+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
11+
org.eclipse.jdt.core.compiler.processAnnotations=enabled
12+
org.eclipse.jdt.core.compiler.release=disabled
13+
org.eclipse.jdt.core.compiler.source=1.6

src/main/java/jp/ossc/nimbus/beans/BeanTableView.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ public Object clone(){
12341234
return clone;
12351235
}
12361236

1237-
protected static class BeanComparator implements Comparator, Externalizable{
1237+
public static class BeanComparator implements Comparator, Externalizable{
12381238

12391239
protected SimpleProperty[] properties;
12401240
protected boolean[] isAsc;

src/main/java/jp/ossc/nimbus/service/context/DistributedSharedContextService.java

+142-69
Large diffs are not rendered by default.

src/main/java/jp/ossc/nimbus/service/context/SharedContextService.java

+99-34
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.lang.reflect.InvocationTargetException;
4040

4141
import jp.ossc.nimbus.beans.*;
42+
import jp.ossc.nimbus.beans.dataset.*;
4243
import jp.ossc.nimbus.core.*;
4344
import jp.ossc.nimbus.daemon.*;
4445
import jp.ossc.nimbus.service.publish.*;
@@ -1648,8 +1649,8 @@ public boolean locks(Set keys, boolean ifAcquireable, boolean ifExist, long time
16481649
return result;
16491650
}
16501651
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
1651-
if(!isNoTimeout && timeout <= 0){
1652-
throw new SharedContextTimeoutException();
1652+
if(!isNoTimeout && currentTimeout <= 0){
1653+
throw new SharedContextTimeoutException("keys=" + keys.size() + ", timeout=" + timeout + ", processTime=" + (System.currentTimeMillis() - start));
16531654
}
16541655
}else{
16551656
if(ifAcquireable){
@@ -1736,6 +1737,9 @@ public boolean locks(Set keys, boolean ifAcquireable, boolean ifExist, long time
17361737
throw new NoConnectServerException("Main server is not found.");
17371738
}
17381739
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
1740+
if(!isNoTimeout && currentTimeout <= 0){
1741+
throw new SharedContextTimeoutException();
1742+
}
17391743
keyItr = keys.iterator();
17401744
while(keyItr.hasNext()){
17411745
Object key = keyItr.next();
@@ -1760,7 +1764,7 @@ public boolean locks(Set keys, boolean ifAcquireable, boolean ifExist, long time
17601764
}
17611765
}
17621766
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
1763-
if(!isNoTimeout && timeout <= 0){
1767+
if(!isNoTimeout && currentTimeout <= 0){
17641768
throw new SharedContextTimeoutException();
17651769
}
17661770
}
@@ -2173,12 +2177,10 @@ public Object getUpdateTemplate(Object key, long timeout) throws SharedContextSe
21732177

21742178
public Object getUpdateTemplate(Object key, long timeout, boolean withTransaction) throws SharedContextSendException, SharedContextTimeoutException{
21752179
Object value = null;
2176-
final boolean isNoTimeout = timeout <= 0;
2177-
long currentTimeout = timeout;
21782180
if(withTransaction && sharedContextTransactionManager != null){
21792181
SharedContextTransactionManager.SharedContextTransaction transaction = sharedContextTransactionManager.getTransaction();
21802182
if(transaction != null && (transaction.getState() == SharedContextTransactionManager.SharedContextTransaction.STATE_BEGIN)){
2181-
return transaction.getUpdateTemplate(this, key, currentTimeout);
2183+
return transaction.getUpdateTemplate(this, key, timeout);
21822184
}
21832185
}
21842186
if(isClient){
@@ -2195,7 +2197,7 @@ public Object getUpdateTemplate(Object key, long timeout, boolean withTransactio
21952197
clientSubject,
21962198
key == null ? null : key.toString(),
21972199
1,
2198-
currentTimeout
2200+
timeout
21992201
);
22002202
Object result = responses[0].getObject();
22012203
responses[0].recycle();
@@ -2254,40 +2256,33 @@ protected void update(Object key, SharedContextValueDifference diff, long timeou
22542256
}
22552257
}
22562258
}
2259+
final boolean isNoTimeout = timeout <= 0;
2260+
long currentTimeout = timeout;
22572261
try{
22582262
Object oldValue = null;
2259-
long startTime = System.currentTimeMillis();
2263+
long start = System.currentTimeMillis();
22602264
if(!updateLock.acquireForUse(timeout)){
22612265
throw new SharedContextTimeoutException();
22622266
}
2263-
if(timeout > 0){
2264-
timeout -= (System.currentTimeMillis() - startTime);
2265-
if(timeout <= 0){
2266-
throw new SharedContextTimeoutException();
2267-
}
2268-
startTime = System.currentTimeMillis();
2267+
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
2268+
if(!isNoTimeout && currentTimeout <= 0){
2269+
throw new SharedContextTimeoutException();
22692270
}
2270-
if(!referLock.acquireForUse(timeout)){
2271+
if(!referLock.acquireForUse(currentTimeout)){
22712272
throw new SharedContextTimeoutException();
22722273
}
2273-
if(timeout > 0){
2274-
timeout -= (System.currentTimeMillis() - startTime);
2275-
if(timeout <= 0){
2276-
throw new SharedContextTimeoutException();
2277-
}
2278-
startTime = System.currentTimeMillis();
2274+
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
2275+
if(!isNoTimeout && currentTimeout <= 0){
2276+
throw new SharedContextTimeoutException();
22792277
}
22802278
Object current = getRawLocal(key);
22812279
Object currentValue = unwrapCachedReference(current, false, false);
22822280
if(currentValue == null){
22832281
if(isClient && isEnabledIndexOnClient){
2284-
currentValue = get(key, timeout);
2285-
if(timeout > 0){
2286-
timeout -= (System.currentTimeMillis() - startTime);
2287-
if(timeout <= 0){
2288-
throw new SharedContextTimeoutException();
2289-
}
2290-
startTime = System.currentTimeMillis();
2282+
currentValue = get(key, currentTimeout);
2283+
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
2284+
if(!isNoTimeout && currentTimeout <= 0){
2285+
throw new SharedContextTimeoutException();
22912286
}
22922287
}
22932288
if(currentValue == null
@@ -2319,7 +2314,7 @@ protected void update(Object key, SharedContextValueDifference diff, long timeou
23192314
isClient ? clientSubject : subject,
23202315
key == null ? null : key.toString(),
23212316
0,
2322-
timeout
2317+
currentTimeout
23232318
);
23242319
for(int i = 0; i < responses.length; i++){
23252320
Object ret = responses[i].getObject();
@@ -3177,12 +3172,12 @@ public Object get(Object key, long timeout, boolean withTransaction) throws Shar
31773172
}
31783173
}
31793174
try{
3180-
long startTime = System.currentTimeMillis();
3175+
long start = System.currentTimeMillis();
31813176
if(!referLock.acquireForUse(currentTimeout)){
31823177
throw new SharedContextTimeoutException();
31833178
}
31843179
if(!isNoTimeout && currentTimeout <= 0){
3185-
currentTimeout -= (System.currentTimeMillis() - startTime);
3180+
currentTimeout = isNoTimeout ? currentTimeout : timeout - (System.currentTimeMillis() - start);
31863181
if(currentTimeout <= 0){
31873182
throw new SharedContextTimeoutException();
31883183
}
@@ -3207,11 +3202,10 @@ public Object get(Object key, long timeout, boolean withTransaction) throws Shar
32073202
}
32083203
if(lock != null){
32093204
lock.init();
3210-
final long start = System.currentTimeMillis();
32113205
if(!lock.waitLock(currentTimeout)){
32123206
throw new SharedContextTimeoutException();
32133207
}
3214-
currentTimeout = isNoTimeout ? timeout : currentTimeout - (System.currentTimeMillis() - start);
3208+
currentTimeout = isNoTimeout ? timeout : timeout - (System.currentTimeMillis() - start);
32153209
if(!isNoTimeout && currentTimeout <= 0){
32163210
throw new SharedContextTimeoutException();
32173211
}
@@ -5954,13 +5948,14 @@ public synchronized void callback(Lock lock, boolean notify){
59545948
}else{
59555949
message.setDestinationIds(receiveClients);
59565950
long currentTimeout = isNoTimeout ? timeout : timeout - (System.currentTimeMillis() - startTime);
5957-
if(!isNoTimeout && timeout <= 0){
5951+
if(!isNoTimeout && currentTimeout <= 0){
59585952
Message response = createResponseMessage(responseSubject, responseKey, new SharedContextTimeoutException());
59595953
try{
59605954
serverConnection.response(sourceId, sequence, response);
59615955
}catch(MessageSendException e){
59625956
getLogger().write("SCS__00006", new Object[]{isClient ? clientSubject : subject, response}, e);
59635957
}
5958+
return;
59645959
}
59655960
message.setObject(
59665961
new SharedContextEvent(
@@ -6704,6 +6699,76 @@ public Set getResultSet(){
67046699
return resultSet == null ? indexManager.keySet() : resultSet;
67056700
}
67066701

6702+
public Set getResultValueSet() throws SharedContextSendException, SharedContextTimeoutException{
6703+
return getResultValueSet(defaultTimeout);
6704+
}
6705+
6706+
public Set getResultValueSet(long timeout) throws SharedContextSendException, SharedContextTimeoutException{
6707+
Set keySet = getResultSet();
6708+
if(keySet == null){
6709+
return null;
6710+
}
6711+
Set resultValueSet = new LinkedHashSet();
6712+
final long start = System.currentTimeMillis();
6713+
long currentTimeout = timeout;
6714+
Iterator keys = keySet.iterator();
6715+
while(keys.hasNext()){
6716+
if(timeout > 0){
6717+
currentTimeout = timeout - (System.currentTimeMillis() - start);
6718+
if(currentTimeout <= 0){
6719+
throw new SharedContextTimeoutException();
6720+
}
6721+
}
6722+
resultValueSet.add(get(keys.next(), currentTimeout));
6723+
}
6724+
6725+
return resultValueSet;
6726+
}
6727+
6728+
public List getResultValueList() throws SharedContextSendException, SharedContextTimeoutException{
6729+
return getResultValueList(defaultTimeout);
6730+
}
6731+
6732+
public List getResultValueList(long timeout) throws SharedContextSendException, SharedContextTimeoutException{
6733+
Set keySet = getResultSet();
6734+
if(keySet == null){
6735+
return null;
6736+
}
6737+
List resultValueList = new ArrayList();
6738+
final long start = System.currentTimeMillis();
6739+
long currentTimeout = timeout;
6740+
Iterator keys = keySet.iterator();
6741+
while(keys.hasNext()){
6742+
if(timeout > 0){
6743+
currentTimeout = timeout - (System.currentTimeMillis() - start);
6744+
if(currentTimeout <= 0){
6745+
throw new SharedContextTimeoutException();
6746+
}
6747+
}
6748+
resultValueList.add(get(keys.next(), currentTimeout));
6749+
}
6750+
6751+
return resultValueList;
6752+
}
6753+
6754+
public List getResultValueList(long timeout, String[] propNames) throws SharedContextSendException, SharedContextTimeoutException{
6755+
return getResultValueList(timeout, propNames, null);
6756+
}
6757+
6758+
public List getResultValueList(long timeout, String[] propNames, boolean[] isAsc) throws SharedContextSendException, SharedContextTimeoutException{
6759+
List resultValueList = getResultValueList(timeout);
6760+
if(resultValueList == null || resultValueList.size() == 0){
6761+
return resultValueList;
6762+
}
6763+
Object template = resultValueList.get(0);
6764+
if(template instanceof Record){
6765+
RecordList.sort(resultValueList, propNames, isAsc);
6766+
}else{
6767+
Collections.sort(resultValueList, new BeanTableView.BeanComparator(template.getClass(), propNames, isAsc));
6768+
}
6769+
return resultValueList;
6770+
}
6771+
67076772
public SharedContextView and(){
67086773
operator = OPERATOR_AND;
67096774
return this;

0 commit comments

Comments
 (0)