use of org.apache.hadoop.hive.ql.wm.Trigger in project hive by apache.
the class TestTriggersTezSessionPoolManager method testTriggerCustomNonExistent.
@Test(timeout = 60000)
public void testTriggerCustomNonExistent() throws Exception {
Expression expression = ExpressionFactory.fromString("OPEN_FILES > 50");
Trigger trigger = new ExecutionTrigger("non_existent", expression, new Action(Action.Type.KILL_QUERY));
setupTriggers(Lists.newArrayList(trigger));
String query = "select l.under_col, l.value from " + tableName + " l join " + tableName + " r on l.under_col>=r.under_col";
runQueryWithTrigger(query, null, null);
}
use of org.apache.hadoop.hive.ql.wm.Trigger in project hive by apache.
the class TestTriggersTezSessionPoolManager method testTriggerHighBytesWrite.
@Test(timeout = 60000)
public void testTriggerHighBytesWrite() throws Exception {
Expression expression = ExpressionFactory.fromString("FILE_BYTES_WRITTEN > 100");
Trigger trigger = new ExecutionTrigger("big_write", expression, new Action(Action.Type.KILL_QUERY));
setupTriggers(Lists.newArrayList(trigger));
String query = "select sleep(t1.under_col, 5), t1.value from " + tableName + " t1 join " + tableName + " t2 on t1.under_col>=t2.under_col";
runQueryWithTrigger(query, null, trigger + " violated");
}
use of org.apache.hadoop.hive.ql.wm.Trigger in project hive by apache.
the class TestTriggersTezSessionPoolManager method testTriggerCustomCreatedFiles.
@Test(timeout = 120000)
public void testTriggerCustomCreatedFiles() throws Exception {
List<String> cmds = getConfigs();
Expression expression = ExpressionFactory.fromString("CREATED_FILES > 5");
Trigger trigger = new ExecutionTrigger("high_read_ops", expression, new Action(Action.Type.KILL_QUERY));
setupTriggers(Lists.newArrayList(trigger));
String query = "create table testtab2 as select * from " + tableName;
runQueryWithTrigger(query, cmds, trigger + " violated");
// partitioned insert
expression = ExpressionFactory.fromString("CREATED_FILES > 10");
trigger = new ExecutionTrigger("high_read_ops", expression, new Action(Action.Type.KILL_QUERY));
setupTriggers(Lists.newArrayList(trigger));
cmds.add("drop table src3");
cmds.add("create table src3 (key int) partitioned by (value string)");
query = "insert overwrite table src3 partition (value) select sleep(under_col, 10), value from " + tableName + " where under_col < 100";
runQueryWithTrigger(query, cmds, trigger + " violated");
}
use of org.apache.hadoop.hive.ql.wm.Trigger 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);
}
use of org.apache.hadoop.hive.ql.wm.Trigger in project hive by apache.
the class KillTriggerActionHandler method applyAction.
@Override
public void applyAction(final Map<TezSessionState, Trigger> queriesViolated) {
for (Map.Entry<TezSessionState, Trigger> entry : queriesViolated.entrySet()) {
switch(entry.getValue().getAction().getType()) {
case KILL_QUERY:
TezSessionState sessionState = entry.getKey();
String queryId = sessionState.getWmContext().getQueryId();
try {
KillQuery killQuery = sessionState.getKillQuery();
// if kill query is null then session might have been released to pool or closed already
if (killQuery != null) {
sessionState.getKillQuery().killQuery(queryId, entry.getValue().getViolationMsg());
}
} catch (HiveException e) {
LOG.warn("Unable to kill query {} for trigger violation");
}
break;
default:
throw new RuntimeException("Unsupported action: " + entry.getValue());
}
}
}
Aggregations