private Boolean checkAndAddSessionToAnotherPool(
    WmTezSession session, String destPoolName, Set<String> poolsToRedistribute) {
    if (session.isIrrelevantForWm()) {
      // This is called only during move session handling, removing session already checks this.
      // So this is not expected as remove failing will not even invoke this method
      LOG.error("Unexpected during add session to another pool. If remove failed this should not have been called.");
      return false;
    }

    PoolState destPool = pools.get(destPoolName);
    if (destPool != null && destPool.sessions.add(session)) {
      if (destPool.metrics != null) {
        destPool.metrics.addRunningQuery();
      }
      session.setPoolName(destPoolName);
      updateTriggers(session);
      poolsToRedistribute.add(destPoolName);
      return true;
    }
    LOG.error("Session {} was not added to pool {}", session, destPoolName);
    return null;
  }
Checks if the session is still relevant for WM and if yes, removes it from its thread.
@param isSessionOk Whether the user thinks the session being returned in some way is ok;
                   true means it is (return, reuse); false mean it isn't (reopen, destroy);
                   null means this is not a user call.
@return true if the session was removed; false if the session was already processed by WM
        thread (so we are dealing with an outdated request); null if the session should be
        in WM but wasn't found in the requisite pool (internal error?).
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/WorkloadManager.java