public static void shutdown() { logger_.info("Shutting down ..."); synchronized (MessagingService.class) { /* Stop listening on any socket */ for (SelectionKey skey : listenSockets_.values()) { SelectorManager.getSelectorManager().cancel(skey); } listenSockets_.clear(); /* Shutdown the threads in the EventQueue's */ messageDeserializationExecutor_.shutdownNow(); messageSerializerExecutor_.shutdownNow(); messageDeserializerExecutor_.shutdownNow(); streamExecutor_.shutdownNow(); /* shut down the cachetables */ taskCompletionMap_.shutdown(); callbackMap_.shutdown(); /* Interrupt the selector manager thread */ SelectorManager.getSelectorManager().interrupt(); poolTable_.clear(); verbHandlers_.clear(); bShutdown_ = true; } logger_.debug("Shutdown invocation complete."); }
public String sendRR(Message message, EndPoint[] to, IAsyncCallback cb) { String messageId = message.getMessageId(); callbackMap_.put(messageId, cb); for (int i = 0; i < to.length; ++i) { sendOneWay(message, to[i]); } return messageId; }
public String sendRR(Message[] messages, EndPoint[] to, IAsyncCallback cb) { if (messages.length != to.length) { throw new IllegalArgumentException( "Number of messages and the number of endpoints need to be same."); } String groupId = GuidGenerator.guid(); callbackMap_.put(groupId, cb); for (int i = 0; i < messages.length; ++i) { messages[i].setMessageId(groupId); sendOneWay(messages[i], to[i]); } return groupId; }
public IAsyncResult sendRR(Message[] messages, EndPoint[] to) { if (messages.length != to.length) { throw new IllegalArgumentException( "Number of messages and the number of endpoints need to be same."); } IAsyncResult iar = new MultiAsyncResult(messages.length); String groupId = GuidGenerator.guid(); taskCompletionMap_.put(groupId, iar); for (int i = 0; i < messages.length; ++i) { messages[i].setMessageId(groupId); sendOneWay(messages[i], to[i]); } return iar; }
public String sendRR(Message[][] messages, EndPoint[][] to, IAsyncCallback cb) { if (messages.length != to.length) { throw new IllegalArgumentException( "Number of messages and the number of endpoints need to be same."); } int length = messages.length; String[] gids = new String[length]; /* Generate the requisite GUID's */ for (int i = 0; i < length; ++i) { gids[i] = GuidGenerator.guid(); } /* attach this context to the callback */ cb.attachContext(gids); for (int i = 0; i < length; ++i) { callbackMap_.put(gids[i], cb); for (int j = 0; j < messages[i].length; ++j) { messages[i][j].setMessageId(gids[i]); sendOneWay(messages[i][j], to[i][j]); } } return gids[0]; }
public static void removeAsyncResult(String key) { taskCompletionMap_.remove(key); }
public static IAsyncResult getAsyncResult(String key) { return taskCompletionMap_.remove(key); }
public static void removeRegisteredCallback(String key) { callbackMap_.remove(key); }
public static IAsyncCallback getRegisteredCallback(String key) { return callbackMap_.get(key); }
public IAsyncResult sendRR(Message message, EndPoint to) { IAsyncResult iar = new AsyncResult(); taskCompletionMap_.put(message.getMessageId(), iar); sendOneWay(message, to); return iar; }
public String sendRR(Message message, EndPoint to, IAsyncCallback cb) { String messageId = message.getMessageId(); callbackMap_.put(messageId, cb); sendOneWay(message, to); return messageId; }