Search in sources :

Example 1 with WorkloadManager

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

the class TestTriggersMoveWorkloadManager method setupTriggers.

private void setupTriggers(final List<Trigger> biTriggers, final List<Trigger> etlTriggers) throws Exception {
    WorkloadManager wm = WorkloadManager.getInstance();
    WMPool biPool = pool("BI", 1, 0.8f);
    WMPool etlPool = pool("ETL", 1, 0.2f);
    WMFullResourcePlan plan = new WMFullResourcePlan(plan(), Lists.newArrayList(biPool, etlPool));
    plan.getPlan().setDefaultPoolPath("BI");
    for (Trigger trigger : biTriggers) {
        plan.addToTriggers(wmTriggerFromTrigger(trigger));
        plan.addToPoolTriggers(new WMPoolTrigger("BI", trigger.getName()));
    }
    for (Trigger trigger : etlTriggers) {
        plan.addToTriggers(wmTriggerFromTrigger(trigger));
        plan.addToPoolTriggers(new WMPoolTrigger("ETL", trigger.getName()));
    }
    wm.updateResourcePlanAsync(plan).get(10, TimeUnit.SECONDS);
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) WMPoolTrigger(org.apache.hadoop.hive.metastore.api.WMPoolTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) WMPool(org.apache.hadoop.hive.metastore.api.WMPool) WMPoolTrigger(org.apache.hadoop.hive.metastore.api.WMPoolTrigger) WorkloadManager(org.apache.hadoop.hive.ql.exec.tez.WorkloadManager)

Example 2 with WorkloadManager

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

the class TestTriggersWorkloadManager method setupTriggers.

@Override
protected void setupTriggers(final List<Trigger> triggers) throws Exception {
    WorkloadManager wm = WorkloadManager.getInstance();
    WMPool pool = new WMPool("rp", "llap");
    pool.setAllocFraction(1.0f);
    pool.setQueryParallelism(1);
    WMFullResourcePlan rp = new WMFullResourcePlan(new WMResourcePlan("rp"), Lists.newArrayList(pool));
    rp.getPlan().setDefaultPoolPath("llap");
    for (Trigger trigger : triggers) {
        rp.addToTriggers(wmTriggerFromTrigger(trigger));
        rp.addToPoolTriggers(new WMPoolTrigger("llap", trigger.getName()));
    }
    wm.updateResourcePlanAsync(rp).get(10, TimeUnit.SECONDS);
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) WMPoolTrigger(org.apache.hadoop.hive.metastore.api.WMPoolTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) WMResourcePlan(org.apache.hadoop.hive.metastore.api.WMResourcePlan) WMPool(org.apache.hadoop.hive.metastore.api.WMPool) WMPoolTrigger(org.apache.hadoop.hive.metastore.api.WMPoolTrigger) WorkloadManager(org.apache.hadoop.hive.ql.exec.tez.WorkloadManager)

Example 3 with WorkloadManager

use of org.apache.hadoop.hive.ql.exec.tez.WorkloadManager 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

WMFullResourcePlan (org.apache.hadoop.hive.metastore.api.WMFullResourcePlan)3 WorkloadManager (org.apache.hadoop.hive.ql.exec.tez.WorkloadManager)3 WMPool (org.apache.hadoop.hive.metastore.api.WMPool)2 WMPoolTrigger (org.apache.hadoop.hive.metastore.api.WMPoolTrigger)2 Trigger (org.apache.hadoop.hive.ql.wm.Trigger)2 DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 WMNullableResourcePlan (org.apache.hadoop.hive.metastore.api.WMNullableResourcePlan)1 WMResourcePlan (org.apache.hadoop.hive.metastore.api.WMResourcePlan)1 WMValidateResourcePlanResponse (org.apache.hadoop.hive.metastore.api.WMValidateResourcePlanResponse)1 TezSessionPoolManager (org.apache.hadoop.hive.ql.exec.tez.TezSessionPoolManager)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 ExecutionTrigger (org.apache.hadoop.hive.ql.wm.ExecutionTrigger)1