Пример #1
0
  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.");
  }
Пример #2
0
  /*
      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);
  }
Пример #3
0
  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);
    }
  }
Пример #4
0
 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);
 }