Search in sources :

Example 6 with Initiator

use of org.voltdb.iv2.Initiator in project voltdb by VoltDB.

the class RealVoltDB method onReplayCompletion.

@Override
public void onReplayCompletion(long txnId, Map<Integer, Long> perPartitionTxnIds) {
    /*
         * Remove the terminus file if it is there, which is written on shutdown --save
         */
    new File(m_nodeSettings.getVoltDBRoot(), VoltDB.TERMINUS_MARKER).delete();
    /*
         * Command log is already initialized if this is a rejoin or a join
         */
    if ((m_commandLog != null) && (m_commandLog.needsInitialization())) {
        // Initialize command logger
        m_commandLog.init(m_catalogContext.cluster.getLogconfig().get("log").getLogsize(), txnId, m_cartographer.getPartitionCount(), m_config.m_commandLogBinding, perPartitionTxnIds);
        try {
            ZKCountdownLatch latch = new ZKCountdownLatch(m_messenger.getZK(), VoltZK.commandlog_init_barrier, m_messenger.getLiveHostIds().size());
            latch.countDown(true);
            latch.await();
        } catch (Exception e) {
            VoltDB.crashLocalVoltDB("Failed to init and wait on command log init barrier", true, e);
        }
    }
    /*
         * IV2: After the command log is initialized, force the writing of the initial
         * viable replay set.  Turns into a no-op with no command log, on the non-leader sites, and on the MPI.
         */
    for (Initiator initiator : m_iv2Initiators.values()) {
        initiator.enableWritingIv2FaultLog();
    }
    /*
         * IV2: From this point on, not all node failures should crash global VoltDB.
         */
    if (m_leaderAppointer != null) {
        m_leaderAppointer.onReplayCompletion();
    }
    deleteStagedCatalogIfNeeded();
    if (m_startMode != null) {
        m_mode = m_startMode;
    } else {
        // Shouldn't be here, but to be safe
        m_mode = OperationMode.RUNNING;
    }
    if (!m_rejoining && !m_joining) {
        if (m_clientInterface != null) {
            try {
                m_clientInterface.startAcceptingConnections();
            } catch (IOException e) {
                hostLog.l7dlog(Level.FATAL, LogKeys.host_VoltDB_ErrorStartAcceptingConnections.name(), e);
                VoltDB.crashLocalVoltDB("Error starting client interface.", true, e);
            }
            // send hostUp trap
            m_snmp.hostUp("host is now a cluster member");
        }
        // Start listening on the DR ports
        createDRConsumerIfNeeded();
        prepareReplication();
        startHealthMonitor();
        // Allow export datasources to start consuming their binary deques safely
        // as at this juncture the initial truncation snapshot is already complete
        ExportManager.instance().startPolling(m_catalogContext);
        //Tell import processors that they can start ingesting data.
        ImportManager.instance().readyForData(m_catalogContext, m_messenger);
    }
    try {
        if (m_adminListener != null) {
            m_adminListener.start();
        }
    } catch (Exception e) {
        hostLog.l7dlog(Level.FATAL, LogKeys.host_VoltDB_ErrorStartHTTPListener.name(), e);
        VoltDB.crashLocalVoltDB("HTTP service unable to bind to port.", true, e);
    }
    if (!m_rejoining && !m_joining) {
        Object[] args = { (m_mode == OperationMode.PAUSED) ? "PAUSED" : "NORMAL" };
        consoleLog.l7dlog(Level.INFO, LogKeys.host_VoltDB_ServerOpMode.name(), args, null);
        consoleLog.l7dlog(Level.INFO, LogKeys.host_VoltDB_ServerCompletedInitialization.name(), null, null);
        m_statusTracker.setNodeState(NodeState.UP);
    }
    // Create a zk node to indicate initialization is completed
    m_messenger.getZK().create(VoltZK.init_completed, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, new ZKUtil.StringCallback(), null);
}
Also used : MpInitiator(org.voltdb.iv2.MpInitiator) SpInitiator(org.voltdb.iv2.SpInitiator) Initiator(org.voltdb.iv2.Initiator) BaseInitiator(org.voltdb.iv2.BaseInitiator) ZKCountdownLatch(org.voltcore.zk.ZKCountdownLatch) JSONObject(org.json_voltpatches.JSONObject) IOException(java.io.IOException) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) 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) ZKUtil(org.voltcore.zk.ZKUtil)

Aggregations

BaseInitiator (org.voltdb.iv2.BaseInitiator)6 Initiator (org.voltdb.iv2.Initiator)6 MpInitiator (org.voltdb.iv2.MpInitiator)6 SpInitiator (org.voltdb.iv2.SpInitiator)6 IOException (java.io.IOException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 SocketException (java.net.SocketException)3 ExecutionException (java.util.concurrent.ExecutionException)3 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)3 JSONException (org.json_voltpatches.JSONException)3 SettingsException (org.voltdb.settings.SettingsException)3 File (java.io.File)2 TreeMap (java.util.TreeMap)2 JSONObject (org.json_voltpatches.JSONObject)2 ZKUtil (org.voltcore.zk.ZKUtil)2 ImmutableList (com.google_voltpatches.common.collect.ImmutableList)1 ImmutableMap (com.google_voltpatches.common.collect.ImmutableMap)1 PrintStream (java.io.PrintStream)1 InetAddress (java.net.InetAddress)1 SimpleDateFormat (java.text.SimpleDateFormat)1