private void recoverClusterManagerFromDisk(HostsFileReader hostsReader)
    throws IOException {
    LOG.info("Restoring state from " +
      new java.io.File(conf.getCMStateFile()).getAbsolutePath());

    // This will prevent the expireNodes and expireSessions threads from
    // expiring the nodes and sessions respectively
    safeMode = true;
    LOG.info("Safe mode is now: " + (this.safeMode ? "ON" : "OFF"));

    CoronaSerializer coronaSerializer = new CoronaSerializer(conf);

    // Expecting the START_OBJECT token for ClusterManager
    coronaSerializer.readStartObjectToken("ClusterManager");

    coronaSerializer.readField("startTime");
    startTime = coronaSerializer.readValueAs(Long.class);

    coronaSerializer.readField("nodeManager");
    nodeManager = new NodeManager(this, hostsReader, coronaSerializer);
    nodeManager.setConf(conf);

    coronaSerializer.readField("sessionManager");
    sessionManager = new SessionManager(this, coronaSerializer);

    coronaSerializer.readField("sessionNotifier");
    sessionNotifier = new SessionNotifier(sessionManager, this, metrics,
                                          coronaSerializer);

    // Expecting the END_OBJECT token for ClusterManager
    coronaSerializer.readEndObjectToken("ClusterManager");

    lastRestartTime = clock.getTime();
  }
private void recoverClusterManagerFromDisk ( HostsFileReader hostsReader ) throws IOException { LOG . info ( "Restoring state from " + new java . io . File ( conf . getCMStateFile ( ) ) . getAbsolutePath ( ) ) ; safeMode = true ; LOG . info ( "Safe mode is now: " + ( this . safeMode ? "ON" : "OFF" ) ) ; CoronaSerializer coronaSerializer = new CoronaSerializer ( conf ) ; coronaSerializer . readStartObjectToken ( "ClusterManager" ) ; coronaSerializer . readField ( "startTime" ) ; startTime = coronaSerializer . readValueAs ( Long . class ) ; coronaSerializer . readField ( "nodeManager" ) ; nodeManager = new NodeManager ( this , hostsReader , coronaSerializer ) ; nodeManager . setConf ( conf ) ; coronaSerializer . readField ( "sessionManager" ) ; sessionManager = new SessionManager ( this , coronaSerializer ) ; coronaSerializer . readField ( "sessionNotifier" ) ; sessionNotifier = new SessionNotifier ( sessionManager , this , metrics , coronaSerializer ) ; coronaSerializer . readEndObjectToken ( "ClusterManager" ) ; lastRestartTime = clock . getTime ( ) ; }
This method is used when the ClusterManager is restarting after going down
while in Safe Mode. It starts the process of recovering the original
CM state by reading back the state in JSON form.
@param hostsReader The HostsReader instance
@throws IOException