private static SocketChannel connectToNode0(boolean isCurrentJvmNode0, NodeInfo node0) throws RuntimeException {
        if (isCurrentJvmNode0 == true) {
            return LoopbackSocketChannel.getInstance();
        } else {
            try {
                LOGGER.fine("Waiting 300-500ms before attempting to connect to node0 to ensure binding completion.");
                Thread.sleep(300 + (int) (Math.random() * 200));
            } catch (InterruptedException ex) {
                throw new RuntimeException("Interruption occurs while waiting before attempting to connect to node0.", ex);
            }
            for (int attempt = 0; attempt <= Configuration.RETRY_COUNT; ++attempt) {
                try {
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.log(Level.FINE, "Connecting to node0 ({0}:{1,number,#})...",
                                new Object[]{node0.getHostname(), node0.getPort()});
                    }

                    InetAddress inetAddressNode0 = InetAddress.getByName(node0.getHostname());
                    SocketChannel node0Socket = networker.connectTo(inetAddressNode0, node0.getPort());

                    if (LOGGER.isLoggable(Level.FINER)) {
                        LOGGER.log(Level.FINER, "Connected to node0 ({0}:{1,number,#}): {2}",
                                new Object[]{node0.getHostname(), node0.getPort(), Objects.toString(node0Socket)});
                    }

                    return node0Socket;
                } catch (IOException ex) {
                    if (attempt < Configuration.RETRY_COUNT) {
                        LOGGER.log(Level.WARNING,
                                "({0,number,#} attempt of {1,number,#}) Connecting to node0 ({2}:{3,number,#}) failed: {4}. Retrying.",
                                new Object[]{attempt + 1, Configuration.RETRY_COUNT + 1,
                                        node0.getHostname(), node0.getPort(), ex.getMessage()});
                        try {
                            Thread.sleep(Configuration.RETRY_DELAY * 1000 + (int) (Math.random() * 1000));
                        } catch (InterruptedException e) {
                            throw new RuntimeException("Interruption occurs while waiting for connection retry.", e);
                        }
                    } else {
                        throw new RuntimeException(String.format("Connecting to node0 (%s:%d) failed!",
                                node0.getHostname(), node0.getPort()), ex);
                    }
                } catch (InterruptedException ex) {
                    throw new RuntimeException(
                            String.format("Interruption occurs while connecting to node0 (%s:%d).",
                                    node0.getHostname(), node0.getPort()),
                            ex);
                }
            }
        }
        throw new IllegalStateException("Unreachable code.");

    }