@Override
    boolean blockUntilBecomingActiveMaster(int checkInterval, TaskGroup startupTaskGroup) {
      MonitoredTask loopTask = startupTaskGroup.addTask("Stay as a standby master.");
      while (!(master.isAborted() || master.isStopped())) {
        loopTask.setStatus("Forever looping to stay as a standby master.");
        try {
          activeMasterServerName = null;
          try {
            if (MasterAddressTracker.getMasterAddress(watcher) != null) {
              clusterHasActiveMaster.set(true);
            }
          } catch (IOException e) {
            // pass, we will get notified when some other active master creates the znode.
          }
          Threads.sleepWithoutInterrupt(1000);
        } catch (KeeperException e) {
          master.abort("Received an unexpected KeeperException, aborting", e);
          return false;
        }
        synchronized (this.clusterHasActiveMaster) {
          while (clusterHasActiveMaster.get() && !master.isStopped()) {
            try {
              clusterHasActiveMaster.wait(checkInterval);
            } catch (InterruptedException e) {
              // We expect to be interrupted when a master dies,
              // will fall out if so
              LOG.debug("Interrupted waiting for master to die", e);
            }
          }
          if (clusterShutDown.get()) {
            this.master.stop("Cluster went down before this master became active");
          }
        }
      }
      return false;
    }
An implementation that never transitions to an active master.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/AlwaysStandByHMaster.java