private void startActiveMasterManager(int infoPort) throws KeeperException {
    String backupZNode = ZNodePaths.joinZNode(zooKeeper.getZNodePaths().backupMasterAddressesZNode,
      serverName.toString());
    /*
     * Add a ZNode for ourselves in the backup master directory since we may not become the active
     * master. If so, we want the actual active master to know we are backup masters, so that it
     * won't assign regions to us if so configured. If we become the active master later,
     * ActiveMasterManager will delete this node explicitly. If we crash before then, ZooKeeper will
     * delete this node for us since it is ephemeral.
     */
    LOG.info("Adding backup master ZNode " + backupZNode);
    if (!MasterAddressTracker.setMasterAddress(zooKeeper, backupZNode, serverName, infoPort)) {
      LOG.warn("Failed create of " + backupZNode + " by " + serverName);
    }
    this.activeMasterManager.setInfoPort(infoPort);
    int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
    // If we're a backup master, stall until a primary to write this address
    if (conf.getBoolean(HConstants.MASTER_TYPE_BACKUP, HConstants.DEFAULT_MASTER_TYPE_BACKUP)) {
      LOG.debug("HMaster started in backup mode. Stalling until master znode is written.");
      // This will only be a minute or so while the cluster starts up,
      // so don't worry about setting watches on the parent znode
      while (!activeMasterManager.hasActiveMaster()) {
        LOG.debug("Waiting for master address and cluster state znode to be written.");
        Threads.sleep(timeout);
      }
    }

    // Here for the master startup process, we use TaskGroup to monitor the whole progress.
    // The UI is similar to how Hadoop designed the startup page for the NameNode.
    // See HBASE-21521 for more details.
    // We do not cleanup the startupTaskGroup, let the startup progress information
    // be permanent in the MEM.
    startupTaskGroup = TaskMonitor.createTaskGroup(true, "Master startup");
    try {
      if (activeMasterManager.blockUntilBecomingActiveMaster(timeout, startupTaskGroup)) {
        finishActiveMasterInitialization();
      }
    } catch (Throwable t) {
      startupTaskGroup.abort("Failed to become active master due to:" + t.getMessage());
      LOG.error(HBaseMarkers.FATAL, "Failed to become active master", t);
      // HBASE-5680: Likely hadoop23 vs hadoop 20.x/1.x incompatibility
      if (
        t instanceof NoClassDefFoundError
          && t.getMessage().contains("org/apache/hadoop/hdfs/protocol/HdfsConstants$SafeModeAction")
      ) {
        // improved error message for this special case
        abort("HBase is having a problem with its Hadoop jars.  You may need to recompile "
          + "HBase against Hadoop version " + org.apache.hadoop.util.VersionInfo.getVersion()
          + " or change your hadoop jars to start properly", t);
      } else {
        abort("Unhandled exception. Starting shutdown.", t);
      }
    }
  }
Switch for the background CatalogJanitor thread. Used for testing. The thread will continue to
run. It will just be a noop if disabled.
@param b If false, the catalog janitor won't do anything.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java