/**
   * Connect to a remote node if appropriate
   *
   * @param bootstrap the client bootstrap object
   * @param n the node to connect to
   */
  protected void doNodeConnect(ClusterNode n) {
    if (!shutDown && n.getNodeId() < syncManager.getLocalNodeId()) {
      Short nodeId = n.getNodeId();

      synchronized (connections) {
        NodeConnection c = connections.get(n.getNodeId());
        if (c == null) {
          connections.put(nodeId, c = new NodeConnection());
        }

        if (logger.isTraceEnabled()) {
          logger.trace(
              "[{}->{}] Connection state: {}",
              new Object[] {syncManager.getLocalNodeId(), nodeId, c.state});
        }
        if (c.state.equals(NodeConnectionState.NONE)) {
          if (logger.isDebugEnabled()) {
            logger.debug(
                "[{}->{}] Attempting connection {} {}",
                new Object[] {syncManager.getLocalNodeId(), nodeId, n.getHostname(), n.getPort()});
          }
          SocketAddress sa = new InetSocketAddress(n.getHostname(), n.getPort());
          c.pendingFuture = clientBootstrap.connect(sa);
          c.pendingFuture.addListener(new ConnectCFListener(n));
          c.state = NodeConnectionState.PENDING;
        }
      }
    }
  }