MeshProber.Determination buildClusterMesh(ReadDeploymentResults readDepl) {
        final boolean bareAtStartup  = m_config.m_forceVoltdbCreate
                || pathsWithRecoverableArtifacts(readDepl.deployment).isEmpty();
        setBare(bareAtStartup);

        final Supplier<Integer> hostCountSupplier = new Supplier<Integer>() {
            @Override
            public Integer get() {
                return m_clusterSettings.get().hostcount();
            }
        };

        ClusterType clusterType = readDepl.deployment.getCluster();

        MeshProber criteria = MeshProber.builder()
                .coordinators(m_config.m_coordinators)
                .versionChecker(m_versionChecker)
                .enterprise(m_config.m_isEnterprise)
                .startAction(m_config.m_startAction)
                .bare(bareAtStartup)
                .configHash(CatalogUtil.makeDeploymentHashForConfig(readDepl.deploymentBytes))
                .hostCountSupplier(hostCountSupplier)
                .kfactor(clusterType.getKfactor())
                .paused(m_config.m_isPaused)
                .nodeStateSupplier(m_statusTracker.getSupplier())
                .addAllowed(m_config.m_enableAdd)
                .safeMode(m_config.m_safeMode)
                .terminusNonce(getTerminusNonce())
                .missingHostCount(m_config.m_missingHostCount)
                .build();

        HostAndPort hostAndPort = criteria.getLeader();
        String hostname = hostAndPort.getHost();
        int port = hostAndPort.getPort();

        org.voltcore.messaging.HostMessenger.Config hmconfig;

        hmconfig = new org.voltcore.messaging.HostMessenger.Config(hostname, port, m_config.m_isPaused);
        if (m_config.m_placementGroup != null) {
            hmconfig.group = m_config.m_placementGroup;
        }
        hmconfig.internalPort = m_config.m_internalPort;
        hmconfig.internalInterface = m_config.m_internalInterface;
        hmconfig.zkInterface = m_config.m_zkInterface;
        hmconfig.deadHostTimeout = m_config.m_deadHostTimeoutMS;
        hmconfig.factory = new VoltDbMessageFactory();
        hmconfig.coreBindIds = m_config.m_networkCoreBindings;
        hmconfig.acceptor = criteria;
        hmconfig.localSitesCount = m_config.m_sitesperhost;
        if (!StringUtils.isEmpty(m_config.m_recoveredPartitions)) {
            hmconfig.recoveredPartitions = m_config.m_recoveredPartitions;
        }
        //if SSL needs to be enabled for internal communication, SSL context has to be setup before starting HostMessenger
        setupSSL(readDepl);
        if (m_config.m_sslInternal) {
            m_messenger = new org.voltcore.messaging.HostMessenger(hmconfig, this, m_config.m_sslServerContext,
                    m_config.m_sslClientContext);
        } else {
            m_messenger = new org.voltcore.messaging.HostMessenger(hmconfig, this);
        }

        hostLog.info(String.format("Beginning inter-node communication on port %d.", m_config.m_internalPort));

        try {
            m_messenger.start();
        } catch (Exception e) {
            boolean printStackTrace =  true;
            // do not log fatal exception message in these cases
            if (e.getMessage() != null) {
                if (e.getMessage().indexOf(SocketJoiner.FAIL_ESTABLISH_MESH_MSG) > -1 ||
                        e.getMessage().indexOf(MeshProber.MESH_ONE_REJOIN_MSG )> -1) {
                    printStackTrace = false;
                }
            }
            VoltDB.crashLocalVoltDB(e.getMessage(), printStackTrace, e);
        }

        VoltZK.createPersistentZKNodes(m_messenger.getZK());

        // Use the host messenger's hostId.
        m_myHostId = m_messenger.getHostId();
        hostLog.info(String.format("Host id of this node is: %d", m_myHostId));
        consoleLog.info(String.format("Host id of this node is: %d", m_myHostId));

        MeshProber.Determination determination = criteria.waitForDetermination();

        // paused is determined in the mesh formation exchanged
        if (determination.paused) {
            m_messenger.pause();
        } else {
            m_messenger.unpause();
        }

        // Semi-hacky check to see if we're attempting to rejoin to ourselves.
        // The leader node gets assigned host ID 0, always, so if we're the
        // leader and we're rejoining, this is clearly bad.
        if (m_myHostId == 0 && determination.startAction.doesJoin()) {
            VoltDB.crashLocalVoltDB("Unable to rejoin a node to itself.  " +
                    "Please check your command line and start action and try again.", false, null);
        }
        // load or store settings form/to zookeeper
        if (determination.startAction.doesJoin()) {
            m_clusterSettings.load(m_messenger.getZK());
            m_clusterSettings.get().store();
        } else if (m_myHostId == 0) {
            if (hostLog.isDebugEnabled()) {
                hostLog.debug("Writing initial hostcount " +
                               m_clusterSettings.get().getProperty(ClusterSettings.HOST_COUNT) +
                               " to ZK");
            }
            m_clusterSettings.store(m_messenger.getZK());
        }
        m_clusterCreateTime = m_messenger.getInstanceId().getTimestamp();
        return determination;
    }
MeshProber . Determination buildClusterMesh ( ReadDeploymentResults readDepl ) { final boolean bareAtStartup = m_config . m_forceVoltdbCreate || pathsWithRecoverableArtifacts ( readDepl . deployment ) . isEmpty ( ) ; setBare ( bareAtStartup ) ; final Supplier < Integer > hostCountSupplier = new Supplier < Integer > ( ) { @ Override public Integer get ( ) { return m_clusterSettings . get ( ) . hostcount ( ) ; } } ; ClusterType clusterType = readDepl . deployment . getCluster ( ) ; MeshProber criteria = MeshProber . builder ( ) . coordinators ( m_config . m_coordinators ) . versionChecker ( m_versionChecker ) . enterprise ( m_config . m_isEnterprise ) . startAction ( m_config . m_startAction ) . bare ( bareAtStartup ) . configHash ( CatalogUtil . makeDeploymentHashForConfig ( readDepl . deploymentBytes ) ) . hostCountSupplier ( hostCountSupplier ) . kfactor ( clusterType . getKfactor ( ) ) . paused ( m_config . m_isPaused ) . nodeStateSupplier ( m_statusTracker . getSupplier ( ) ) . addAllowed ( m_config . m_enableAdd ) . safeMode ( m_config . m_safeMode ) . terminusNonce ( getTerminusNonce ( ) ) . missingHostCount ( m_config . m_missingHostCount ) . build ( ) ; HostAndPort hostAndPort = criteria . getLeader ( ) ; String hostname = hostAndPort . getHost ( ) ; int port = hostAndPort . getPort ( ) ; org . voltcore . messaging . HostMessenger . Config hmconfig ; hmconfig = new org . voltcore . messaging . HostMessenger . Config ( hostname , port , m_config . m_isPaused ) ; if ( m_config . m_placementGroup != null ) { hmconfig . group = m_config . m_placementGroup ; } hmconfig . internalPort = m_config . m_internalPort ; hmconfig . internalInterface = m_config . m_internalInterface ; hmconfig . zkInterface = m_config . m_zkInterface ; hmconfig . deadHostTimeout = m_config . m_deadHostTimeoutMS ; hmconfig . factory = new VoltDbMessageFactory ( ) ; hmconfig . coreBindIds = m_config . m_networkCoreBindings ; hmconfig . acceptor = criteria ; hmconfig . localSitesCount = m_config . m_sitesperhost ; if ( ! StringUtils . isEmpty ( m_config . m_recoveredPartitions ) ) { hmconfig . recoveredPartitions = m_config . m_recoveredPartitions ; } setupSSL ( readDepl ) ; if ( m_config . m_sslInternal ) { m_messenger = new org . voltcore . messaging . HostMessenger ( hmconfig , this , m_config . m_sslServerContext , m_config . m_sslClientContext ) ; } else { m_messenger = new org . voltcore . messaging . HostMessenger ( hmconfig , this ) ; } hostLog . info ( String . format ( "Beginning inter-node communication on port %d." , m_config . m_internalPort ) ) ; try { m_messenger . start ( ) ; } catch ( Exception e ) { boolean printStackTrace = true ; if ( e . getMessage ( ) != null ) { if ( e . getMessage ( ) . indexOf ( SocketJoiner . FAIL_ESTABLISH_MESH_MSG ) > - 1 || e . getMessage ( ) . indexOf ( MeshProber . MESH_ONE_REJOIN_MSG ) > - 1 ) { printStackTrace = false ; } } VoltDB . crashLocalVoltDB ( e . getMessage ( ) , printStackTrace , e ) ; } VoltZK . createPersistentZKNodes ( m_messenger . getZK ( ) ) ; m_myHostId = m_messenger . getHostId ( ) ; hostLog . info ( String . format ( "Host id of this node is: %d" , m_myHostId ) ) ; consoleLog . info ( String . format ( "Host id of this node is: %d" , m_myHostId ) ) ; MeshProber . Determination determination = criteria . waitForDetermination ( ) ; if ( determination . paused ) { m_messenger . pause ( ) ; } else { m_messenger . unpause ( ) ; } if ( m_myHostId == 0 && determination . startAction . doesJoin ( ) ) { VoltDB . crashLocalVoltDB ( "Unable to rejoin a node to itself.  " + "Please check your command line and start action and try again." , false , null ) ; } if ( determination . startAction . doesJoin ( ) ) { m_clusterSettings . load ( m_messenger . getZK ( ) ) ; m_clusterSettings . get ( ) . store ( ) ; } else if ( m_myHostId == 0 ) { if ( hostLog . isDebugEnabled ( ) ) { hostLog . debug ( "Writing initial hostcount " + m_clusterSettings . get ( ) . getProperty ( ClusterSettings . HOST_COUNT ) + " to ZK" ) ; } m_clusterSettings . store ( m_messenger . getZK ( ) ) ; } m_clusterCreateTime = m_messenger . getInstanceId ( ) . getTimestamp ( ) ; return determination ; }
Start the voltcore HostMessenger. This joins the node
to the existing cluster. In the non rejoin case, this
function will return when the mesh is complete. If
rejoining, it will return when the node and agreement
site are synched to the existing cluster.