/**
  * Add the node connection to the node connection map
  *
  * @param nodeId the node ID for the channel
  * @param channel the new channel
  */
 protected void nodeConnected(short nodeId, Channel channel) {
   logger.debug("[{}->{}] Connection established", syncManager.getLocalNodeId(), nodeId);
   synchronized (connections) {
     NodeConnection c = connections.get(nodeId);
     if (c == null) {
       connections.put(nodeId, c = new NodeConnection());
     }
     c.nodeChannel = channel;
     c.state = NodeConnectionState.CONNECTED;
   }
   clusterManager.connectionStateChange();
 }
  /**
   * Remove the connection from the connection registry and clean up any remaining shrapnel
   *
   * @param nodeId
   */
  public void disconnectNode(short nodeId) {
    synchronized (connections) {
      Short n = Short.valueOf(nodeId);
      MessageWindow mw = messageWindows.get(n);
      if (mw != null) {
        mw.lock.lock();
        mw.disconnected = true;
        try {
          mw.full.signalAll();
          messageWindows.remove(n);
        } finally {
          mw.lock.unlock();
        }
      }

      NodeConnection nc = connections.get(nodeId);
      if (nc != null) {
        nc.nuke();
      }
      connections.remove(nodeId);
    }
    clusterManager.connectionStateChange();
  }