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