Search in sources :

Example 1 with WMTrigger

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

the class DDLSemanticAnalyzer method analyzeCreateTrigger.

private void analyzeCreateTrigger(ASTNode ast) throws SemanticException {
    if (ast.getChildCount() != 4) {
        throw new SemanticException("Invalid syntax for create trigger statement");
    }
    String rpName = unescapeIdentifier(ast.getChild(0).getText());
    String triggerName = unescapeIdentifier(ast.getChild(1).getText());
    String triggerExpression = buildTriggerExpression((ASTNode) ast.getChild(2));
    String actionExpression = buildTriggerActionExpression((ASTNode) ast.getChild(3));
    WMTrigger trigger = new WMTrigger(rpName, triggerName);
    trigger.setTriggerExpression(triggerExpression);
    trigger.setActionExpression(actionExpression);
    CreateWMTriggerDesc desc = new CreateWMTriggerDesc(trigger);
    addServiceOutput();
    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)));
}
Also used : CreateWMTriggerDesc(org.apache.hadoop.hive.ql.plan.CreateWMTriggerDesc) DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger)

Example 2 with WMTrigger

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

the class TezSessionPoolManager method updateTriggers.

public void updateTriggers(final WMFullResourcePlan appliedRp) {
    if (sessionTriggerProvider != null) {
        List<WMTrigger> wmTriggers = appliedRp != null ? appliedRp.getTriggers() : null;
        List<Trigger> triggers = new ArrayList<>();
        if (wmTriggers != null) {
            for (WMTrigger wmTrigger : wmTriggers) {
                if (wmTrigger.isSetIsInUnmanaged() && wmTrigger.isIsInUnmanaged()) {
                    triggers.add(ExecutionTrigger.fromWMTrigger(wmTrigger));
                }
            }
        }
        sessionTriggerProvider.setTriggers(Collections.unmodifiableList(triggers));
    }
}
Also used : WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) ExecutionTrigger(org.apache.hadoop.hive.ql.wm.ExecutionTrigger) Trigger(org.apache.hadoop.hive.ql.wm.Trigger) ArrayList(java.util.ArrayList) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger)

Example 3 with WMTrigger

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

the class AbstractJdbcTriggersTest method wmTriggerFromTrigger.

WMTrigger wmTriggerFromTrigger(Trigger trigger) {
    WMTrigger result = new WMTrigger("rp", trigger.getName());
    result.setTriggerExpression(trigger.getExpression().toString());
    result.setActionExpression(trigger.getAction().toString());
    return result;
}
Also used : WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger)

Example 4 with WMTrigger

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

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

WMTrigger (org.apache.hadoop.hive.metastore.api.WMTrigger)11 ExecutionTrigger (org.apache.hadoop.hive.ql.wm.ExecutionTrigger)4 Trigger (org.apache.hadoop.hive.ql.wm.Trigger)4 ArrayList (java.util.ArrayList)3 WMFullResourcePlan (org.apache.hadoop.hive.metastore.api.WMFullResourcePlan)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 WMPoolTrigger (org.apache.hadoop.hive.metastore.api.WMPoolTrigger)2 WMResourcePlan (org.apache.hadoop.hive.metastore.api.WMResourcePlan)2 MWMTrigger (org.apache.hadoop.hive.metastore.model.MWMTrigger)2 DDLWork (org.apache.hadoop.hive.ql.plan.DDLWork)2 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Query (javax.jdo.Query)1 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)1 WMPool (org.apache.hadoop.hive.metastore.api.WMPool)1 MStringList (org.apache.hadoop.hive.metastore.model.MStringList)1 MWMResourcePlan (org.apache.hadoop.hive.metastore.model.MWMResourcePlan)1 AlterWMTriggerDesc (org.apache.hadoop.hive.ql.plan.AlterWMTriggerDesc)1