public ListenableFuture<Boolean> updateResourcePlanAsync(WMFullResourcePlan plan) {
    SettableFuture<Boolean> applyRpFuture = SettableFuture.create();
    currentLock.lock();
    try {
      // TODO: if there's versioning/etc., it will come in here. For now we rely on external
      //       locking or ordering of calls. This should potentially return a Future for that.
      if (current.resourcePlanToApply != null) {
        LOG.warn("Several resource plans are being applied at the same time; using the latest");
        current.applyRpFuture.setException(
          new HiveException("Another plan was applied in parallel"));
      }
      current.applyRpFuture = applyRpFuture;
      if (plan == null) {
        current.resourcePlanToApply = null;
        current.doClearResourcePlan = true;
      } else {
        current.resourcePlanToApply = plan;
        current.doClearResourcePlan = false;
      }
      notifyWmThreadUnderLock();
    } finally {
      currentLock.unlock();
    }
    return applyRpFuture;
  }
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