Esempio n. 1
0
 /** Signals that no further connections will be added. */
 public void noFurtherConnections() {
   lock.lock();
   try {
     connections.noFurtherConnections();
   } finally {
     lock.unlock();
   }
 }
Esempio n. 2
0
 /**
  * Adds a connection to some other message hub. Outgoing messages are forwarded to this
  * connection, and incoming messages are received from it.
  *
  * <p>Does not cleanup connections on stop or disconnect. It is the caller's responsibility to
  * manage the connection lifecycle.
  */
 public void addConnection(RemoteConnection<InterHubMessage> connection) {
   lock.lock();
   try {
     assertRunning("add connection");
     ConnectionState connectionState = connections.add(connection);
     workers.execute(new ConnectionDispatch(connectionState));
     workers.execute(new ConnectionReceive(connectionState));
   } finally {
     lock.unlock();
   }
 }
Esempio n. 3
0
 /**
  * Requests that this message hub commence shutting down. Does the following:
  *
  * <ul>
  *   <li>Stops accepting any further outgoing messages.
  *   <li>If no connections are available, dispatches queued messages to any handlers that
  *       implement {@link RejectedMessageListener}.
  * </ul>
  */
 public void requestStop() {
   lock.lock();
   try {
     if (state != State.Running) {
       return;
     }
     try {
       outgoingQueue.endOutput();
       connections.noFurtherConnections();
     } finally {
       state = State.Stopping;
     }
   } finally {
     lock.unlock();
   }
 }