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."); }
/* Use this version for fire and forget style messaging. */ public void sendOneWay(Message message, EndPoint to) { // do local deliveries if (message.getFrom().equals(to)) { MessagingService.receive(message); return; } Runnable tcpWriteEvent = new MessageSerializationTask(message, to); messageSerializerExecutor_.execute(tcpWriteEvent); }
private static void enqueueRunnable(String stageName, Runnable runnable) { IStage stage = StageManager.getStage(stageName); if (stage != null) { logger_.info("Running on stage " + stage.getName()); stage.execute(runnable); } else { logger_.info("Running on default stage - beware"); messageSerializerExecutor_.execute(runnable); } }
public void stream(String file, long startPosition, long total, EndPoint from, EndPoint to) { isStreaming_.set(true); /* Streaming asynchronously on streamExector_ threads. */ Runnable streamingTask = new FileStreamTask(file, startPosition, total, from, to); streamExecutor_.execute(streamingTask); }