protected void handleWMServiceChangeIfNeeded(WMFullResourcePlan appliedResourcePlan, boolean isActivate,
      boolean isForceDeactivate, boolean replace) throws HiveException {
    boolean mustHaveAppliedChange = isActivate || isForceDeactivate;
    if (!mustHaveAppliedChange && !replace) {
      return; // The modification cannot affect an active plan.
    }
    if (appliedResourcePlan == null && !mustHaveAppliedChange) {
      return; // Replacing an inactive plan.
    }

    WorkloadManager wm = WorkloadManager.getInstance();
    boolean isInTest = HiveConf.getBoolVar(context.getConf(), ConfVars.HIVE_IN_TEST);
    if (wm == null && isInTest) {
      return; // Skip for tests if WM is not present.
    }

    if ((appliedResourcePlan == null) != isForceDeactivate) {
      throw new HiveException("Cannot get a resource plan to apply; or non-null plan on disable");
      // TODO: shut down HS2?
    }
    assert appliedResourcePlan == null || appliedResourcePlan.getPlan().getStatus() == WMResourcePlanStatus.ACTIVE;

    handleWMServiceChange(wm, isActivate, appliedResourcePlan);
  }
Abstract ancestor of the enable / disable Resource Plan operations.
ql/src/java/org/apache/hadoop/hive/ql/ddl/workloadmanagement/resourceplan/alter/AbstractAlterResourcePlanStatusOperation.java