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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations