Search in sources :

Example 11 with WMTrigger

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

the class ObjectStore method getTriggersForResourcePlan.

@Override
public List<WMTrigger> getTriggersForResourcePlan(String resourcePlanName) throws NoSuchObjectException, MetaException {
    List<WMTrigger> triggers = new ArrayList();
    boolean commited = false;
    Query query = null;
    try {
        openTransaction();
        MWMResourcePlan resourcePlan;
        try {
            resourcePlan = getMWMResourcePlan(resourcePlanName, false);
        } catch (InvalidOperationException e) {
            // Should not happen, edit check is false.
            throw new RuntimeException(e);
        }
        query = pm.newQuery(MWMTrigger.class, "resourcePlan == rp");
        query.declareParameters("MWMResourcePlan rp");
        List<MWMTrigger> mTriggers = (List<MWMTrigger>) query.execute(resourcePlan);
        pm.retrieveAll(mTriggers);
        commited = commitTransaction();
        if (mTriggers != null) {
            for (MWMTrigger trigger : mTriggers) {
                triggers.add(fromMWMTrigger(trigger, resourcePlanName));
            }
        }
    } finally {
        rollbackAndCleanup(commited, query);
    }
    return triggers;
}
Also used : Query(javax.jdo.Query) ArrayList(java.util.ArrayList) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) List(java.util.List) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

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