use of jp.ossc.nimbus.service.publish.Message in project nimbus by nimbus-org.
the class DistributedSharedContextService method load.
public synchronized void load(long timeout) throws Exception {
if (isMain()) {
if (contextStore != null) {
contextStore.load(this);
} else {
throw new UnsupportedOperationException();
}
} else {
try {
Message message = serverConnection.createMessage(subject, null);
Set receiveClients = serverConnection.getReceiveClientIds(message);
if (receiveClients.size() != 0) {
message.setObject(new DistributedSharedContextEvent(DistributedSharedContextEvent.EVENT_LOAD));
try {
Message[] responses = serverConnection.request(message, isClient ? clientSubject : subject, null, 1, timeout);
Object ret = responses[0].getObject();
responses[0].recycle();
if (ret instanceof Throwable) {
throw new SharedContextSendException((Throwable) ret);
}
} catch (RequestTimeoutException e) {
throw new SharedContextTimeoutException(e);
}
}
} catch (MessageException e) {
throw new SharedContextSendException(e);
} catch (MessageSendException e) {
throw new SharedContextSendException(e);
}
}
}
use of jp.ossc.nimbus.service.publish.Message in project nimbus by nimbus-org.
the class DistributedSharedContextService method onLoadKey.
protected synchronized Message onLoadKey(DistributedSharedContextEvent event, final Object sourceId, final int sequence, final String responseSubject, final String responseKey) {
if (isMain()) {
Thread loadThread = new Thread() {
public void run() {
Message response = null;
try {
if (contextStore != null) {
contextStore.loadKey(DistributedSharedContextService.this);
} else {
throw new UnsupportedOperationException();
}
response = createResponseMessage(responseSubject, responseKey, null);
} catch (Throwable th) {
response = createResponseMessage(responseSubject, responseKey, th);
}
try {
serverConnection.response(sourceId, sequence, response);
} catch (MessageSendException e) {
getLogger().write("DSCS_00002", new Object[] { isClient ? clientSubject : subject, response }, e);
}
}
};
loadThread.start();
}
return null;
}
use of jp.ossc.nimbus.service.publish.Message in project nimbus by nimbus-org.
the class DistributedSharedContextService method onRehash.
protected Message onRehash(final DistributedSharedContextEvent event, final Object sourceId, final int sequence, final String responseSubject, final String responseKey) {
final DistributeInfo info = (DistributeInfo) event.value;
Thread rehashThread = new Thread() {
public void run() {
Message response = null;
try {
info.apply(distributeInfo, sharedContextArray);
response = createResponseMessage(responseSubject, responseKey, null);
} catch (Throwable th) {
response = createResponseMessage(responseSubject, responseKey, th);
}
try {
serverConnection.response(sourceId, sequence, response);
} catch (MessageSendException e) {
getLogger().write("DSCS_00002", new Object[] { isClient ? clientSubject : subject, response }, e);
}
}
};
rehashThread.start();
return null;
}
use of jp.ossc.nimbus.service.publish.Message in project nimbus by nimbus-org.
the class DistributedSharedContextService method getServerMemberIdSet.
public Set getServerMemberIdSet() {
if (serverConnection == null) {
return new HashSet();
}
try {
Message message = serverConnection.createMessage(subject, null);
Set result = serverConnection.getReceiveClientIds(message);
if (!isClient) {
result.add(getId());
}
return result;
} catch (MessageException e) {
return new HashSet();
}
}
use of jp.ossc.nimbus.service.publish.Message in project nimbus by nimbus-org.
the class DistributedSharedContextService method loadKey.
public synchronized void loadKey(long timeout) throws Exception {
if (isMain()) {
if (contextStore != null) {
contextStore.loadKey(this);
} else {
throw new UnsupportedOperationException();
}
} else {
try {
Message message = serverConnection.createMessage(subject, null);
Set receiveClients = serverConnection.getReceiveClientIds(message);
if (receiveClients.size() != 0) {
message.setObject(new DistributedSharedContextEvent(DistributedSharedContextEvent.EVENT_LOAD_KEY));
try {
Message[] responses = serverConnection.request(message, isClient ? clientSubject : subject, null, 1, timeout);
Object ret = responses[0].getObject();
responses[0].recycle();
if (ret instanceof Throwable) {
throw new SharedContextSendException((Throwable) ret);
}
} catch (RequestTimeoutException e) {
throw new SharedContextTimeoutException(e);
}
}
} catch (MessageException e) {
throw new SharedContextSendException(e);
} catch (MessageSendException e) {
throw new SharedContextSendException(e);
}
}
}
Aggregations