Search in sources :

Example 1 with TezSessionPoolManager

use of org.apache.hadoop.hive.ql.exec.tez.TezSessionPoolManager in project hive by apache.

the class DDLTask method alterResourcePlan.

private int alterResourcePlan(Hive db, AlterResourcePlanDesc desc) throws HiveException {
    if (desc.shouldValidate()) {
        WMValidateResourcePlanResponse result = db.validateResourcePlan(desc.getResourcePlanName());
        try (DataOutputStream out = getOutputStream(desc.getResFile())) {
            formatter.showErrors(out, result);
        } catch (IOException e) {
            throw new HiveException(e);
        }
        ;
        return 0;
    }
    WMNullableResourcePlan resourcePlan = desc.getResourcePlan();
    final WorkloadManager wm = WorkloadManager.getInstance();
    final TezSessionPoolManager pm = TezSessionPoolManager.getInstance();
    boolean isActivate = false, isInTest = HiveConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST);
    if (resourcePlan.getStatus() != null) {
        isActivate = resourcePlan.getStatus() == WMResourcePlanStatus.ACTIVE;
    }
    WMFullResourcePlan appliedRp = db.alterResourcePlan(desc.getResourcePlanName(), resourcePlan, desc.isEnableActivate(), desc.isForceDeactivate(), desc.isReplace());
    boolean mustHaveAppliedChange = isActivate || desc.isForceDeactivate();
    if (!mustHaveAppliedChange && !desc.isReplace()) {
        // The modification cannot affect an active plan.
        return 0;
    }
    if (appliedRp == null && !mustHaveAppliedChange) {
        // Replacing an inactive plan.
        return 0;
    }
    if (wm == null && isInTest) {
        // Skip for tests if WM is not present.
        return 0;
    }
    if ((appliedRp == null) != desc.isForceDeactivate()) {
        throw new HiveException("Cannot get a resource plan to apply; or non-null plan on disable");
    // TODO: shut down HS2?
    }
    assert appliedRp == null || appliedRp.getPlan().getStatus() == WMResourcePlanStatus.ACTIVE;
    handleWorkloadManagementServiceChange(wm, pm, isActivate, appliedRp);
    return 0;
}
Also used : WMNullableResourcePlan(org.apache.hadoop.hive.metastore.api.WMNullableResourcePlan) WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) DataOutputStream(java.io.DataOutputStream) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) WMValidateResourcePlanResponse(org.apache.hadoop.hive.metastore.api.WMValidateResourcePlanResponse) TezSessionPoolManager(org.apache.hadoop.hive.ql.exec.tez.TezSessionPoolManager) IOException(java.io.IOException) WorkloadManager(org.apache.hadoop.hive.ql.exec.tez.WorkloadManager)

Aggregations

DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 WMFullResourcePlan (org.apache.hadoop.hive.metastore.api.WMFullResourcePlan)1 WMNullableResourcePlan (org.apache.hadoop.hive.metastore.api.WMNullableResourcePlan)1 WMValidateResourcePlanResponse (org.apache.hadoop.hive.metastore.api.WMValidateResourcePlanResponse)1 TezSessionPoolManager (org.apache.hadoop.hive.ql.exec.tez.TezSessionPoolManager)1 WorkloadManager (org.apache.hadoop.hive.ql.exec.tez.WorkloadManager)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1