code: public void waitForRestart() {
      if (standbyThread != null) {
        try {
          // if this is the standby avatarnode, then wait for the Standby to exit
          standbyThread.join();
        } catch (InterruptedException ie) {
          //eat it up
        }
        standbyThread = null;
        LOG.info("waitForRestart: Standby thread exited.");
  
        InjectionHandler.processEvent(InjectionEvent.AVATARNODE_WAIT_FOR_RESTART);
        while (failoverState == FailoverState.START_FAILOVER
            || failoverState == FailoverState.AWAIT_FAILOVER) {
          LOG.info("Current state : " + failoverState
              + ". Waiting for failover ....");
          try {
            Thread.sleep(1000);
          } catch (InterruptedException ie) {
            throw new RuntimeException("waitForRestart() interrupted");
          }
        }
  
        // if we are still in standbymode, that means we need to restart from
        // scratch.
        if (getAvatar() == Avatar.STANDBY) {
          runInfo.isRunning = false;
          LOG.info("waitForRestart Stopping encapsulated namenode.");
          super.stop(); // terminate encapsulated namenode
          super.join(); // wait for encapsulated namenode to exit
          shutdownStandby();
          LOG.info("waitForRestart exiting");
          return;
        }
      }
      super.join();            // wait for encapsulated namenode
    }
docs: Wait for the StandbyNode to exit. If it does, then stop the underlying namenode.