/**
   * Try to establish a connection to server with id sid.
   *
   * @param sid server id
   */
  synchronized void connectOne(long sid) {
    if (senderWorkerMap.get(sid) == null) {
      InetSocketAddress electionAddr;
      if (self.quorumPeers.containsKey(sid)) {
        electionAddr = self.quorumPeers.get(sid).electionAddr;
      } else {
        LOG.warn("Invalid server id: " + sid);
        return;
      }
      try {

        if (LOG.isDebugEnabled()) {
          LOG.debug("Opening channel to server " + sid);
        }
        Socket sock = new Socket();
        setSockOpts(sock);
        sock.connect(self.getView().get(sid).electionAddr, cnxTO);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Connected to server " + sid);
        }
        initiateConnection(sock, sid);
      } catch (UnresolvedAddressException e) {
        // Sun doesn't include the address that causes this
        // exception to be thrown, also UAE cannot be wrapped cleanly
        // so we log the exception in order to capture this critical
        // detail.
        LOG.warn("Cannot open channel to " + sid + " at election address " + electionAddr, e);
        throw e;
      } catch (IOException e) {
        LOG.warn("Cannot open channel to " + sid + " at election address " + electionAddr, e);
      }
    } else {
      LOG.debug("There is a connection already for server " + sid);
    }
  }
 /**
  * Invokes initiateConnection for testing purposes
  *
  * @param sid
  */
 public void testInitiateConnection(long sid) throws Exception {
   if (LOG.isDebugEnabled()) {
     LOG.debug("Opening channel to server " + sid);
   }
   Socket sock = new Socket();
   setSockOpts(sock);
   sock.connect(self.getVotingView().get(sid).electionAddr, cnxTO);
   initiateConnection(sock, sid);
 }