docs: private void connectToPrimary(InetSocketAddress coordIp, ConnectStrategy mode) throws Exception {
          // collect clock skews from all nodes
          List<Long> skews = new ArrayList<Long>();
  
          // collect the set of active voltdb version strings in the cluster
          // this is used to limit simulatanious versions to two
          Set<String> activeVersions = new TreeSet<String>();
  
          try {
              LOG.debug("Non-Primary Starting & Connecting to Primary: " + coordIp + " in mode: " + mode);
              SocketChannel socket = createLeaderSocket(coordIp, mode);
              if (socket == null)
               {
                  return; // in probe mode
              }
              socket.socket().setTcpNoDelay(true);
              socket.socket().setPerformancePreferences(0, 2, 1);
              SSLEngine leaderSSLEngine;
              try {
                  leaderSSLEngine = initializeSocket(socket, true, skews).m_sslEngine;
              } catch(IOException e) {
                  SocketAddress socketAddress = socket.getRemoteAddress();
                  try {
                      socket.close();
                  } catch(IOException t) { }
                  throw new IOException("SSL setup to " + socketAddress + " failed", e);
              }
              MessagingChannel leaderChannel = MessagingChannel.get(socket, leaderSSLEngine);
              if (!coordIp.equals(m_coordIp)) {
                  m_coordIp = coordIp;
              }
  
              // blocking call, send a request to the leader node and get a host id assigned by the leader
              RequestHostIdResponse response = requestHostId(leaderChannel, activeVersions);
              // check if the membership request is accepted
              JSONObject responseBody = response.getResponseBody();
              if (!responseBody.optBoolean(ACCEPTED, true)) {
                  socket.close();
                  if (!responseBody.optBoolean(MAY_RETRY, false)) {
                      org.voltdb.VoltDB.crashLocalVoltDB(
                              "Request to join cluster is rejected: "
                              + responseBody.optString(REASON, "rejection reason is not available"));
                  }
                  throw new CoreUtils.RetryException(responseBody.optString(REASON, "rejection reason is not available"));
              }
  
              /*
               * Get the generated host id, and the interface we connected on
               * that was echoed back
               */
              m_localHostId = responseBody.getInt(NEW_HOST_ID);
              m_reportedInternalInterface = responseBody.getString(REPORTED_ADDRESS);
  
              ImmutableMap.Builder<Integer, JSONObject> cmbld = ImmutableMap.builder();
              cmbld.put(m_localHostId, m_acceptor.decorate(responseBody, Optional.<Boolean>empty()));
  
              /*
               * Loop over all the hosts and create a connection (except for the first entry, that is the leader)
               * and publish the host id that was generated. This finishes creating the mesh
               */
              JSONArray otherHosts = responseBody.getJSONArray(HOSTS);
              int hostIds[] = new int[otherHosts.length()];
              SocketChannel hostSockets[] = new SocketChannel[hostIds.length];
              SSLEngine sslEngines[] = new SSLEngine[hostIds.length];
              InetSocketAddress listeningAddresses[] = new InetSocketAddress[hostIds.length];
  
              for (int ii = 0; ii < otherHosts.length(); ii++) {
                  JSONObject host = otherHosts.getJSONObject(ii);
                  String address = host.getString(ADDRESS);
                  int port = host.getInt(PORT);
                  final int hostId = host.getInt(HOST_ID);
  
                  LOG.info("Leader provided address " + address + ":" + port);
                  InetSocketAddress hostAddr = new InetSocketAddress(address, port);
                  if (ii == 0) {
                      //Leader already has a socket
                      hostIds[ii] = hostId;
                      listeningAddresses[ii] = hostAddr;
                      hostSockets[ii] = socket;
                      sslEngines[ii] = leaderSSLEngine;
                      cmbld.put(ii, response.getLeaderInfo());
                      continue;
                  }
                  // connect to all the peer hosts (except leader) and advertise our existence
                  SocketChannel hostSocket = connectToHost(hostAddr);
                  SSLEngine sslEngine = initializeSocket(hostSocket, true, skews).m_sslEngine;
                  MessagingChannel messagingChannel = MessagingChannel.get(hostSocket, sslEngine);
                  JSONObject hostInfo = publishHostId(hostAddr, messagingChannel, activeVersions);
  
                  hostIds[ii] = hostId;
                  hostSockets[ii] = hostSocket;
                  sslEngines[ii] = sslEngine;
                  listeningAddresses[ii] = hostAddr;
  
                  cmbld.put(ii, hostInfo);
              }
  
              /*
               * The max difference of clock skew cannot exceed MAX_CLOCKSKEW, and the number of
               * active versions in the cluster cannot be more than 2.
               */
              checkClockSkew(skews);
              checkActiveVersions(activeVersions, m_acceptor.getVersionChecker().getVersionString());
  
              /*
               * Notify the leader that we connected to the entire cluster, it will then go
               * and queue a txn for our agreement site to join the cluster
               */
              ByteBuffer joinCompleteBuffer = ByteBuffer.allocate(1);
              // No need to encrypt this one byte
              while (joinCompleteBuffer.hasRemaining()) {
                  hostSockets[0].write(joinCompleteBuffer);
              }
  
              /*
               * Let host messenger know about the connections.
               * It will init the agreement site and then we are done.
               */
              m_joinHandler.notifyOfHosts( m_localHostId, hostIds, hostSockets, sslEngines, listeningAddresses, cmbld.build());
          } catch (ClosedByInterruptException e) {
              //This is how shutdown is done
          }
      }