use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method dropWMTrigger.
@Override
public void dropWMTrigger(String resourcePlanName, String triggerName) throws NoSuchObjectException, InvalidOperationException, MetaException {
resourcePlanName = normalizeIdentifier(resourcePlanName);
triggerName = normalizeIdentifier(triggerName);
boolean commited = false;
Query query = null;
try {
openTransaction();
MWMResourcePlan resourcePlan = getMWMResourcePlan(resourcePlanName, true);
query = pm.newQuery(MWMTrigger.class, "resourcePlan == rp && name == triggerName");
query.declareParameters("MWMResourcePlan rp, java.lang.String triggerName");
if (query.deletePersistentAll(resourcePlan, triggerName) != 1) {
throw new NoSuchObjectException("Cannot delete trigger: " + triggerName);
}
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method createWMTriggerToPoolMapping.
@Override
public void createWMTriggerToPoolMapping(String resourcePlanName, String triggerName, String poolPath) throws AlreadyExistsException, 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().add(trigger);
trigger.getPools().add(pool);
pm.makePersistent(pool);
pm.makePersistent(trigger);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, (Query) null);
}
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method dropWMMapping.
@Override
public void dropWMMapping(WMMapping mapping) throws NoSuchObjectException, InvalidOperationException, MetaException {
String entityType = mapping.getEntityType().trim().toUpperCase();
String entityName = normalizeIdentifier(mapping.getEntityName());
boolean commited = false;
Query query = null;
try {
openTransaction();
MWMResourcePlan resourcePlan = getMWMResourcePlan(mapping.getResourcePlanName(), true);
query = pm.newQuery(MWMMapping.class, "resourcePlan == rp && entityType == type && entityName == name");
query.declareParameters("MWMResourcePlan rp, java.lang.String type, java.lang.String name");
if (query.deletePersistentAll(resourcePlan, entityType, entityName) != 1) {
throw new NoSuchObjectException("Cannot delete mapping.");
}
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method getMWMResourcePlan.
private MWMResourcePlan getMWMResourcePlan(String name, boolean editCheck, boolean mustExist) throws NoSuchObjectException, InvalidOperationException {
MWMResourcePlan resourcePlan;
boolean commited = false;
Query query = null;
name = normalizeIdentifier(name);
try {
openTransaction();
query = pm.newQuery(MWMResourcePlan.class, "name == rpname");
query.declareParameters("java.lang.String rpname");
query.setUnique(true);
resourcePlan = (MWMResourcePlan) query.execute(name);
pm.retrieve(resourcePlan);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
if (mustExist && resourcePlan == null) {
throw new NoSuchObjectException("There is no resource plan named: " + name);
}
if (editCheck && resourcePlan != null && resourcePlan.getStatus() != MWMResourcePlan.Status.DISABLED) {
throw new InvalidOperationException("Resource plan must be disabled to edit it.");
}
return resourcePlan;
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method alterWMTrigger.
@Override
public void alterWMTrigger(WMTrigger trigger) throws NoSuchObjectException, InvalidOperationException, MetaException {
boolean commited = false;
Query query = null;
try {
openTransaction();
MWMResourcePlan resourcePlan = getMWMResourcePlan(trigger.getResourcePlanName(), true);
MWMTrigger mTrigger = getTrigger(resourcePlan, trigger.getTriggerName());
// Update the object.
if (trigger.isSetTriggerExpression()) {
mTrigger.setTriggerExpression(trigger.getTriggerExpression());
}
if (trigger.isSetActionExpression()) {
mTrigger.setActionExpression(trigger.getActionExpression());
}
if (trigger.isSetIsInUnmanaged()) {
mTrigger.setIsInUnmanaged(trigger.isIsInUnmanaged());
}
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
}
Aggregations