/**
  * Check startup mode on disk. Startup mode is specified by a property file on disk
  * ${dbdir}/startupmode
  *
  * @param config The Confiugration instance
  * @return BootMode instance if detected, null for no on-disk startup mode
  */
 private StartupMode checkStartupModeOnDisk(Configuration config) throws IOException {
   String modeType = readStartupModeFromDisk();
   if (modeType != null) {
     if (Constants.STARTUPMODE_HIBERNATE.equalsIgnoreCase(modeType)) {
       HibernateMode mode = new HibernateMode(config);
       mode.setCoordinator(_coordinator);
       mode.setSchemaUtil(_schemaUtil);
       mode.setDbDir(dbDir);
       return mode;
     } else if (Constants.STARTUPMODE_RESTORE_REINIT.equalsIgnoreCase(modeType)) {
       _log.info(
           "GeodbRestore startup mode found. Current vdc list {}",
           _schemaUtil.getVdcList().size());
       if (isGeoDbsvc() && _schemaUtil.getVdcList().size() > 1) {
         GeodbRestoreMode mode = new GeodbRestoreMode(config);
         mode.setCoordinator(_coordinator);
         mode.setSchemaUtil(_schemaUtil);
         mode.setDbDir(dbDir);
         return mode;
       }
     } else {
       throw new IllegalStateException("Unexpected startup mode " + modeType);
     }
   }
   return null;
 }
  /**
   * Determine current startup mode. See BootMode for detailed explanation of each mode.
   *
   * @param config
   * @return
   */
  private StartupMode checkStartupMode(Configuration config) throws IOException {
    // Check on disk mode first
    StartupMode bootMode = checkStartupModeOnDisk(config);
    if (bootMode != null) {
      return bootMode;
    }

    // Check geodb restore flag in zk
    if (checkConfigBool(config, Constants.STARTUPMODE_RESTORE_REINIT)) {
      _log.info("Found geodbrestore config: {}", Constants.STARTUPMODE_RESTORE_REINIT);
      GeodbRestoreMode mode = new GeodbRestoreMode(config);
      mode.setCoordinator(_coordinator);
      mode.setSchemaUtil(_schemaUtil);
      mode.setDbDir(dbDir);
      return mode;
    }

    // Check geodb reinit ZK flag for add-vdc
    if (checkConfigBool(config, Constants.REINIT_DB)) {
      _log.info("Found reinit config: {}", Constants.REINIT_DB);
      // reinit both system table and StorageOS tables
      DbReinitMode mode = new DbReinitMode(config);
      mode.setCoordinator(_coordinator);
      mode.setSchemaUtil(_schemaUtil);
      mode.setDbDir(dbDir);
      return mode;
    }

    // check geodb cleanup mode for remove-vdc
    List<String> obsoletePeers = checkConfigList(config, Constants.OBSOLETE_CASSANDRA_PEERS);
    if (!obsoletePeers.isEmpty()) {
      // drop peers ip/tokens from system table
      ObsoletePeersCleanupMode mode = new ObsoletePeersCleanupMode(config);
      mode.setCoordinator(_coordinator);
      mode.setSchemaUtil(_schemaUtil);
      mode.setObsoletePeers(obsoletePeers);
      return mode;
    } else {
      NormalMode mode = new NormalMode(config);
      mode.setCoordinator(_coordinator);
      mode.setSchemaUtil(_schemaUtil);
      return mode;
    }
  }