private void closeAndDisallowHiveSessions() {
    LOG.info("Closing all open hive sessions.");
    if (cliService == null) {
      return;
    }
    cliService.getSessionManager().allowSessions(false);
    // No sessions can be opened after the above call. Close the existing ones if any.
    try {
      for (HiveSession session : cliService.getSessionManager().getSessions()) {
        cliService.getSessionManager().closeSession(session.getSessionHandle());
      }
      LOG.info("Closed all open hive sessions");
    } catch (HiveSQLException e) {
      LOG.error("Unable to close all open sessions.", e);
    }
  }
@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