Exemplo n.º 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.");
  }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
  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;
  }
Exemplo n.º 5
0
  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];
  }
Exemplo n.º 6
0
 public static void removeAsyncResult(String key) {
   taskCompletionMap_.remove(key);
 }
Exemplo n.º 7
0
 public static IAsyncResult getAsyncResult(String key) {
   return taskCompletionMap_.remove(key);
 }
Exemplo n.º 8
0
 public static void removeRegisteredCallback(String key) {
   callbackMap_.remove(key);
 }
Exemplo n.º 9
0
 public static IAsyncCallback getRegisteredCallback(String key) {
   return callbackMap_.get(key);
 }
Exemplo n.º 10
0
 public IAsyncResult sendRR(Message message, EndPoint to) {
   IAsyncResult iar = new AsyncResult();
   taskCompletionMap_.put(message.getMessageId(), iar);
   sendOneWay(message, to);
   return iar;
 }
Exemplo n.º 11
0
 public String sendRR(Message message, EndPoint to, IAsyncCallback cb) {
   String messageId = message.getMessageId();
   callbackMap_.put(messageId, cb);
   sendOneWay(message, to);
   return messageId;
 }