Пример #1
0
 @ManagedOperation(description = "Disconnects the channel if connected")
 public synchronized void disconnect() {
   switch (state) {
     case OPEN:
     case CLOSED:
       return;
     case CONNECTING:
     case CONNECTED:
       if (cluster_name != null) {
         // Send down a DISCONNECT event, which travels down to the GMS, where a response is
         // returned
         try {
           down(new Event(Event.DISCONNECT, local_addr)); // DISCONNECT is handled by each layer
         } catch (Throwable t) {
           log.error(Util.getMessage("DisconnectFailure"), local_addr, t);
         }
       }
       state = State.OPEN;
       stopStack(true, false);
       notifyChannelDisconnected(this);
       init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful
               // rejoining
       break;
     default:
       throw new IllegalStateException("state " + state + " unknown");
   }
 }
Пример #2
0
 protected void _connect(Event connect_event) throws Exception {
   try {
     down(connect_event);
   } catch (Throwable t) {
     stopStack(true, false);
     state = State.OPEN;
     init();
     throw new Exception("connecting to channel \"" + connect_event.getArg() + "\" failed", t);
   }
 }
Пример #3
0
  /**
   * Disconnects and closes the channel. This method does the following things
   *
   * <ol>
   *   <li>Calls {@code this.disconnect} if the disconnect parameter is true
   *   <li>Calls {@code ProtocolStack.stop} on the protocol stack
   *   <li>Calls {@code ProtocolStack.destroy} on the protocol stack
   *   <li>Sets the channel closed and channel connected flags to true and false
   *   <li>Notifies any channel listener of the channel close operation
   * </ol>
   */
  protected void _close(boolean disconnect) {
    Address old_addr = local_addr;
    if (state == State.CLOSED) return;

    if (disconnect) disconnect(); // leave group if connected
    stopStack(true, true);
    state = State.CLOSED;
    notifyChannelClosed(this);
    init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining
    if (old_addr != null) UUID.remove(old_addr);
  }