use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method getActiveResourcePlan.
@Override
public WMFullResourcePlan getActiveResourcePlan() throws MetaException {
// Note: fullFromMResroucePlan needs to be called inside the txn, otherwise we could have
// deduplicated this with getActiveMWMResourcePlan.
boolean commited = false;
Query query = null;
WMFullResourcePlan result = null;
try {
openTransaction();
query = pm.newQuery(MWMResourcePlan.class, "status == activeStatus");
query.declareParameters("java.lang.String activeStatus");
query.setUnique(true);
MWMResourcePlan mResourcePlan = (MWMResourcePlan) query.execute(Status.ACTIVE.toString());
if (mResourcePlan != null) {
result = fullFromMResourcePlan(mResourcePlan);
}
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
return result;
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method alterPool.
@Override
public void alterPool(WMNullablePool pool, String poolPath) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
boolean commited = false;
try {
openTransaction();
MWMResourcePlan resourcePlan = getMWMResourcePlan(pool.getResourcePlanName(), true);
MWMPool mPool = getPool(resourcePlan, poolPath);
pm.retrieve(mPool);
if (pool.isSetAllocFraction()) {
mPool.setAllocFraction(pool.getAllocFraction());
}
if (pool.isSetQueryParallelism()) {
mPool.setQueryParallelism(pool.getQueryParallelism());
}
if (pool.isSetIsSetSchedulingPolicy() && pool.isIsSetSchedulingPolicy()) {
if (pool.isSetSchedulingPolicy()) {
String policy = pool.getSchedulingPolicy();
if (!MetaStoreUtils.isValidSchedulingPolicy(policy)) {
throw new InvalidOperationException("Invalid scheduling policy " + policy);
}
mPool.setSchedulingPolicy(pool.getSchedulingPolicy());
} else {
mPool.setSchedulingPolicy(null);
}
}
if (pool.isSetPoolPath() && !pool.getPoolPath().equals(mPool.getPath())) {
moveDescendents(resourcePlan, mPool.getPath(), pool.getPoolPath());
mPool.setPath(pool.getPoolPath());
}
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 createOrUpdateWMMapping.
@Override
public void createOrUpdateWMMapping(WMMapping mapping, boolean update) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
EntityType entityType = EntityType.valueOf(mapping.getEntityType().trim().toUpperCase());
String entityName = normalizeIdentifier(mapping.getEntityName());
boolean commited = false;
Query query = null;
try {
openTransaction();
MWMResourcePlan resourcePlan = getMWMResourcePlan(mapping.getResourcePlanName(), true);
MWMPool pool = null;
if (mapping.isSetPoolPath()) {
pool = getPool(resourcePlan, mapping.getPoolPath());
}
if (!update) {
MWMMapping mMapping = new MWMMapping(resourcePlan, entityType, entityName, pool, mapping.getOrdering());
pm.makePersistent(mMapping);
} else {
query = pm.newQuery(MWMMapping.class, "resourcePlan == rp && entityType == type " + "&& entityName == name");
query.declareParameters("MWMResourcePlan rp, java.lang.String type, java.lang.String name");
query.setUnique(true);
MWMMapping mMapping = (MWMMapping) query.execute(resourcePlan, entityType.toString(), entityName);
mMapping.setPool(pool);
}
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method fromMResourcePlan.
private WMResourcePlan fromMResourcePlan(MWMResourcePlan mplan) {
if (mplan == null) {
return null;
}
WMResourcePlan rp = new WMResourcePlan();
rp.setName(mplan.getName());
rp.setStatus(WMResourcePlanStatus.valueOf(mplan.getStatus().name()));
if (mplan.getQueryParallelism() != null) {
rp.setQueryParallelism(mplan.getQueryParallelism());
}
if (mplan.getDefaultPool() != null) {
rp.setDefaultPoolPath(mplan.getDefaultPool().getPath());
}
return rp;
}
use of org.apache.hadoop.hive.metastore.model.MWMResourcePlan in project hive by apache.
the class ObjectStore method validateResourcePlan.
@Override
public WMValidateResourcePlanResponse validateResourcePlan(String name) throws NoSuchObjectException, InvalidObjectException, MetaException {
name = normalizeIdentifier(name);
Query query = null;
try {
query = pm.newQuery(MWMResourcePlan.class, "name == rpName");
query.declareParameters("java.lang.String rpName");
query.setUnique(true);
MWMResourcePlan mResourcePlan = (MWMResourcePlan) query.execute(name);
if (mResourcePlan == null) {
throw new NoSuchObjectException("Cannot find resourcePlan: " + name);
}
// Validate resource plan.
return getResourcePlanErrors(mResourcePlan);
} finally {
rollbackAndCleanup(true, query);
}
}
Aggregations