Search in sources :

Example 6 with MWMTrigger

use of org.apache.hadoop.hive.metastore.model.MWMTrigger in project hive by apache.

the class ObjectStore method getTrigger.

private MWMTrigger getTrigger(MWMResourcePlan resourcePlan, String triggerName) throws NoSuchObjectException {
    triggerName = normalizeIdentifier(triggerName);
    boolean commited = false;
    Query query = null;
    try {
        openTransaction();
        // Get the MWMTrigger object from DN
        query = pm.newQuery(MWMTrigger.class, "resourcePlan == rp && name == triggerName");
        query.declareParameters("MWMResourcePlan rp, java.lang.String triggerName");
        query.setUnique(true);
        MWMTrigger mTrigger = (MWMTrigger) query.execute(resourcePlan, triggerName);
        if (mTrigger == null) {
            throw new NoSuchObjectException("Cannot find trigger with name: " + triggerName);
        }
        pm.retrieve(mTrigger);
        commited = commitTransaction();
        return mTrigger;
    } finally {
        rollbackAndCleanup(commited, query);
    }
}
Also used : Query(javax.jdo.Query) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException)

Example 7 with MWMTrigger

use of org.apache.hadoop.hive.metastore.model.MWMTrigger in project hive by apache.

the class ObjectStore method fullFromMResourcePlan.

private WMFullResourcePlan fullFromMResourcePlan(MWMResourcePlan mplan) {
    if (mplan == null) {
        return null;
    }
    WMFullResourcePlan rp = new WMFullResourcePlan();
    rp.setPlan(fromMResourcePlan(mplan));
    for (MWMPool mPool : mplan.getPools()) {
        rp.addToPools(fromMPool(mPool, mplan.getName()));
        for (MWMTrigger mTrigger : mPool.getTriggers()) {
            rp.addToPoolTriggers(new WMPoolTrigger(mPool.getPath(), mTrigger.getName()));
        }
    }
    for (MWMTrigger mTrigger : mplan.getTriggers()) {
        rp.addToTriggers(fromMWMTrigger(mTrigger, mplan.getName()));
    }
    for (MWMMapping mMapping : mplan.getMappings()) {
        rp.addToMappings(fromMMapping(mMapping, mplan.getName()));
    }
    return rp;
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) WMPoolTrigger(org.apache.hadoop.hive.metastore.api.WMPoolTrigger) MWMMapping(org.apache.hadoop.hive.metastore.model.MWMMapping)

Example 8 with MWMTrigger

use of org.apache.hadoop.hive.metastore.model.MWMTrigger in project hive by apache.

the class ObjectStore method dropWMTriggerToPoolMapping.

@Override
public void dropWMTriggerToPoolMapping(String resourcePlanName, String triggerName, String poolPath) throws NoSuchObjectException, InvalidOperationException, MetaException {
    boolean commited = false;
    try {
        openTransaction();
        MWMResourcePlan resourcePlan = getMWMResourcePlan(resourcePlanName, true);
        MWMPool pool = getPool(resourcePlan, poolPath);
        MWMTrigger trigger = getTrigger(resourcePlan, triggerName);
        pool.getTriggers().remove(trigger);
        trigger.getPools().remove(pool);
        pm.makePersistent(pool);
        pm.makePersistent(trigger);
        commited = commitTransaction();
    } finally {
        rollbackAndCleanup(commited, (Query) null);
    }
}
Also used : MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 9 with MWMTrigger

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

MWMTrigger (org.apache.hadoop.hive.metastore.model.MWMTrigger)9 MWMResourcePlan (org.apache.hadoop.hive.metastore.model.MWMResourcePlan)5 MWMPool (org.apache.hadoop.hive.metastore.model.MWMPool)4 Query (javax.jdo.Query)3 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)2 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)2 WMTrigger (org.apache.hadoop.hive.metastore.api.WMTrigger)2 MWMMapping (org.apache.hadoop.hive.metastore.model.MWMMapping)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 JDOCanRetryException (javax.jdo.JDOCanRetryException)1 JDODataStoreException (javax.jdo.JDODataStoreException)1 JDOException (javax.jdo.JDOException)1