Search in sources :

Example 11 with WMFullResourcePlan

use of org.apache.hadoop.hive.metastore.api.WMFullResourcePlan in project hive by apache.

the class TestJsonRPFormatter method createRP.

private WMFullResourcePlan createRP(String name, Integer parallelism, String defaultPoolPath) {
    WMResourcePlan rp = new WMResourcePlan(name);
    rp.setStatus(WMResourcePlanStatus.ACTIVE);
    if (parallelism != null) {
        rp.setQueryParallelism(parallelism);
    }
    if (defaultPoolPath != null) {
        rp.setDefaultPoolPath(defaultPoolPath);
    }
    WMFullResourcePlan fullRp = new WMFullResourcePlan(rp, new ArrayList<>());
    return fullRp;
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) WMResourcePlan(org.apache.hadoop.hive.metastore.api.WMResourcePlan)

Example 12 with WMFullResourcePlan

use of org.apache.hadoop.hive.metastore.api.WMFullResourcePlan in project hive by apache.

the class TestJsonRPFormatter method testJsonRPFormatter.

@Test
public void testJsonRPFormatter() throws Exception {
    WMFullResourcePlan fullRp = createRP("test_rp_2", 10, "def");
    addPool(fullRp, "pool1", 0.3, 3, "fair");
    addTrigger(fullRp, "trigger1", "KILL", "BYTES > 2", "pool1");
    addPool(fullRp, "pool2", 0.7, 7, "fcfs");
    addMapping(fullRp, "user", "foo", "pool2");
    addMapping(fullRp, "user", "bar", "pool2");
    formatter.showFullResourcePlan(out, fullRp);
    out.flush();
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode jsonTree = objectMapper.readTree(bos.toByteArray());
    assertNotNull(jsonTree);
    assertTrue(jsonTree.isObject());
    assertEquals("test_rp_2", jsonTree.get("name").asText());
    assertEquals(10, jsonTree.get("parallelism").asInt());
    assertEquals("def", jsonTree.get("defaultPool").asText());
    assertTrue(jsonTree.get("pools").isArray());
    assertEquals(2, jsonTree.get("pools").size());
    JsonNode pool2 = jsonTree.get("pools").get(0);
    assertEquals("pool2", pool2.get("name").asText());
    assertEquals("fcfs", pool2.get("schedulingPolicy").asText());
    assertEquals(7, pool2.get("parallelism").asInt());
    assertEquals(0.7, pool2.get("allocFraction").asDouble(), 0.00001);
    assertTrue(pool2.get("triggers").isArray());
    assertEquals(0, pool2.get("triggers").size());
    assertTrue(pool2.get("mappings").isArray());
    JsonNode type0 = pool2.get("mappings").get(0);
    assertEquals("user", type0.get("type").asText());
    assertTrue(type0.get("values").isArray());
    assertEquals(2, type0.get("values").size());
    HashSet<String> vals = new HashSet<>();
    for (int i = 0; i < type0.get("values").size(); ++i) {
        vals.add(type0.get("values").get(i).asText());
    }
    assertTrue(vals.contains("foo"));
    assertTrue(vals.contains("bar"));
    JsonNode pool1 = jsonTree.get("pools").get(1);
    assertEquals("pool1", pool1.get("name").asText());
    assertEquals("fair", pool1.get("schedulingPolicy").asText());
    assertEquals(3, pool1.get("parallelism").asInt());
    assertEquals(0.3, pool1.get("allocFraction").asDouble(), 0.00001);
    assertTrue(pool1.get("triggers").isArray());
    assertEquals(1, pool1.get("triggers").size());
    JsonNode trigger1 = pool1.get("triggers").get(0);
    assertEquals("trigger1", trigger1.get("name").asText());
    assertEquals("KILL", trigger1.get("action").asText());
    assertEquals("BYTES > 2", trigger1.get("trigger").asText());
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) JsonNode(org.codehaus.jackson.JsonNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with WMFullResourcePlan

use of org.apache.hadoop.hive.metastore.api.WMFullResourcePlan 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 14 with WMFullResourcePlan

use of org.apache.hadoop.hive.metastore.api.WMFullResourcePlan in project hive by apache.

the class TestTriggersNoTezSessionPool method setupTriggers.

@Override
void setupTriggers(final List<Trigger> triggers) throws Exception {
    WMFullResourcePlan rp = new WMFullResourcePlan(new WMResourcePlan("rp"), null);
    for (Trigger trigger : triggers) {
        WMTrigger wmTrigger = wmTriggerFromTrigger(trigger);
        wmTrigger.setIsInUnmanaged(true);
        rp.addToTriggers(wmTrigger);
    }
    TezSessionPoolManager.getInstance().updateTriggers(rp);
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) WMResourcePlan(org.apache.hadoop.hive.metastore.api.WMResourcePlan) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger)

Example 15 with WMFullResourcePlan

use of org.apache.hadoop.hive.metastore.api.WMFullResourcePlan in project hive by apache.

the class TestTriggersTezSessionPoolManager method setupTriggers.

@Override
protected void setupTriggers(final List<Trigger> triggers) throws Exception {
    WMFullResourcePlan rp = new WMFullResourcePlan(new WMResourcePlan("rp"), null);
    for (Trigger trigger : triggers) {
        WMTrigger wmTrigger = wmTriggerFromTrigger(trigger);
        wmTrigger.setIsInUnmanaged(true);
        rp.addToTriggers(wmTrigger);
    }
    TezSessionPoolManager.getInstance().updateTriggers(rp);
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) WMResourcePlan(org.apache.hadoop.hive.metastore.api.WMResourcePlan) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger)

Aggregations

WMFullResourcePlan (org.apache.hadoop.hive.metastore.api.WMFullResourcePlan)28 Test (org.junit.Test)15 HiveConf (org.apache.hadoop.hive.conf.HiveConf)13 CountDownLatch (java.util.concurrent.CountDownLatch)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 WMResourcePlan (org.apache.hadoop.hive.metastore.api.WMResourcePlan)5 Trigger (org.apache.hadoop.hive.ql.wm.Trigger)5 WMPool (org.apache.hadoop.hive.metastore.api.WMPool)4 WMPoolTrigger (org.apache.hadoop.hive.metastore.api.WMPoolTrigger)4 ExecutionTrigger (org.apache.hadoop.hive.ql.wm.ExecutionTrigger)4 WMTrigger (org.apache.hadoop.hive.metastore.api.WMTrigger)3 WorkloadManager (org.apache.hadoop.hive.ql.exec.tez.WorkloadManager)3 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 Query (javax.jdo.Query)2 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 JsonNode (org.codehaus.jackson.JsonNode)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 Matchers.anyBoolean (org.mockito.Matchers.anyBoolean)2