use of jp.ossc.nimbus.service.publish.MessageSendException in project nimbus by nimbus-org.
the class ServerConnectionImpl method close.
public synchronized void close() {
if (clientAcceptor != null) {
clientAcceptor.stopNoWait();
}
if (serverSocket != null) {
try {
serverSocket.close();
} catch (IOException e) {
}
}
try {
send(createMessage(MessageImpl.MESSAGE_TYPE_SERVER_CLOSE));
} catch (MessageSendException e) {
}
final Iterator clientItr = clients.iterator();
while (clientItr.hasNext()) {
ClientImpl client = (ClientImpl) clientItr.next();
client.close();
}
clientAcceptor = null;
if (sendQueueHandlerContainer != null) {
sendQueueHandlerContainer.stop();
sendQueueHandlerContainer.destroy();
sendQueueHandlerContainer = null;
}
if (asynchAcceptQueueHandlerContainer != null) {
asynchAcceptQueueHandlerContainer.stop();
asynchAcceptQueueHandlerContainer.destroy();
asynchAcceptQueueHandlerContainer = null;
}
if (asynchSendQueueHandlerContainer != null) {
asynchSendQueueHandlerContainer.stop();
asynchSendQueueHandlerContainer.destroy();
asynchSendQueueHandlerContainer = null;
}
if (queueSelector != null) {
queueSelector.stop();
queueSelector.destroy();
queueSelector = null;
}
}
use of jp.ossc.nimbus.service.publish.MessageSendException 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.MessageSendException 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.MessageSendException 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.MessageSendException 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