Search in sources :

Example 16 with MeshProber

use of org.voltdb.probe.MeshProber in project voltdb by VoltDB.

the class RealVoltDB method buildClusterMesh.

/**
     * 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.
     */
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.getNodeStateSupplier()).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.getHostText();
    int port = hostAndPort.getPort();
    org.voltcore.messaging.HostMessenger.Config hmconfig;
    hmconfig = new org.voltcore.messaging.HostMessenger.Config(hostname, port);
    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;
    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) {
        VoltDB.crashLocalVoltDB(e.getMessage(), true, 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();
    }
    // 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) {
        m_clusterSettings.store(m_messenger.getZK());
    }
    m_clusterCreateTime = m_messenger.getInstanceId().getTimestamp();
    return determination;
}
Also used : VoltDbMessageFactory(org.voltdb.messaging.VoltDbMessageFactory) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType) MeshProber(org.voltdb.probe.MeshProber) SocketException(java.net.SocketException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) JSONException(org.json_voltpatches.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) KeeperException(org.apache.zookeeper_voltpatches.KeeperException) SettingsException(org.voltdb.settings.SettingsException) HostAndPort(com.google_voltpatches.common.net.HostAndPort) HostMessenger(org.voltcore.messaging.HostMessenger) HostMessenger(org.voltcore.messaging.HostMessenger) Supplier(com.google_voltpatches.common.base.Supplier)

Aggregations

MeshProber (org.voltdb.probe.MeshProber)16 Test (org.junit.Test)15 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 Determination (org.voltdb.probe.MeshProber.Determination)7 UUID (java.util.UUID)2 Supplier (com.google_voltpatches.common.base.Supplier)1 HostAndPort (com.google_voltpatches.common.net.HostAndPort)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SocketException (java.net.SocketException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)1 JSONException (org.json_voltpatches.JSONException)1 JSONObject (org.json_voltpatches.JSONObject)1 HostMessenger (org.voltcore.messaging.HostMessenger)1 ClusterType (org.voltdb.compiler.deploymentfile.ClusterType)1 VoltDbMessageFactory (org.voltdb.messaging.VoltDbMessageFactory)1