@Override
    public void notLeader() {
      LOG.info("HS2 instance {} LOST LEADERSHIP. Stopping/Disconnecting tez sessions..", hiveServer2.serviceUri);
      hiveServer2.isLeader.set(false);
      hiveServer2.closeAndDisallowHiveSessions();
      hiveServer2.stopOrDisconnectTezSessions();
      LOG.info("Stopped/Disconnected tez sessions.");

      // resolve futures used for testing
      if (HiveConf.getBoolVar(hiveServer2.getHiveConf(), ConfVars.HIVE_IN_TEST)) {
        hiveServer2.notLeaderTestFuture.set(true);
        hiveServer2.resetIsLeaderTestFuture();
      }
    }
@return true if the server instance was deregistered from ZooKeeper, else false. The function might
be called even when the instance is not registered with the ZooKeeper (See
SessionManage.closeSessionInternal()). In that case, return false since the deregistration has
not really happened.
service/src/java/org/apache/hive/service/server/HiveServer2.java