Search in sources :

Example 1 with MWMResourcePlan

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;
}
Also used : WMFullResourcePlan(org.apache.hadoop.hive.metastore.api.WMFullResourcePlan) Query(javax.jdo.Query) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 2 with MWMResourcePlan

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);
    }
}
Also used : MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 3 with MWMResourcePlan

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);
    }
}
Also used : EntityType(org.apache.hadoop.hive.metastore.model.MWMMapping.EntityType) Query(javax.jdo.Query) MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) MWMMapping(org.apache.hadoop.hive.metastore.model.MWMMapping) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 4 with MWMResourcePlan

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;
}
Also used : WMResourcePlan(org.apache.hadoop.hive.metastore.api.WMResourcePlan) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Example 5 with MWMResourcePlan

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);
    }
}
Also used : Query(javax.jdo.Query) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan)

Aggregations

MWMResourcePlan (org.apache.hadoop.hive.metastore.model.MWMResourcePlan)22 Query (javax.jdo.Query)13 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)9 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)9 MWMPool (org.apache.hadoop.hive.metastore.model.MWMPool)8 MWMTrigger (org.apache.hadoop.hive.metastore.model.MWMTrigger)6 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)5 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)4 JDOCanRetryException (javax.jdo.JDOCanRetryException)4 JDODataStoreException (javax.jdo.JDODataStoreException)4 JDOException (javax.jdo.JDOException)4 JDOObjectNotFoundException (javax.jdo.JDOObjectNotFoundException)4 AlreadyExistsException (org.apache.hadoop.hive.metastore.api.AlreadyExistsException)4 InvalidInputException (org.apache.hadoop.hive.metastore.api.InvalidInputException)4 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)4 InvalidPartitionException (org.apache.hadoop.hive.metastore.api.InvalidPartitionException)4 UnknownDBException (org.apache.hadoop.hive.metastore.api.UnknownDBException)4 UnknownPartitionException (org.apache.hadoop.hive.metastore.api.UnknownPartitionException)4