private void extractAllSessionsToKill(String killReason,
        IdentityHashMap<WmTezSession, GetRequest> toReuse,
        WmThreadSyncWork syncWork) {
      int totalCount = sessions.size() + initializingSessions.size();
      delayedMoveSessions.clear();
      for (WmTezSession sessionToKill : sessions) {
        resetRemovedSessionToKill(syncWork.toKillQuery,
          new KillQueryContext(sessionToKill, killReason), toReuse);
      }
      sessions.clear();
      for (SessionInitContext initCtx : initializingSessions) {
        // It is possible that the background init thread has finished in parallel, queued
        // the message for us but also returned the session to the user.
        WmTezSession sessionToKill = initCtx.cancelAndExtractSessionIfDone(
            killReason, syncWork.pathsToDelete);
        if (sessionToKill == null) {
          continue; // Async op in progress; the callback will take care of this.
        }
        resetRemovedSessionToKill(syncWork.toKillQuery,
          new KillQueryContext(sessionToKill, killReason), toReuse);
      }
      initializingSessions.clear();
      if (metrics != null) {
        metrics.removeRunningQueries(totalCount);
      }
    }
State of a single pool.
Unless otherwise specified, the members are only modified by the master thread.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/WorkloadManager.java