Search in sources :

Example 21 with MWMResourcePlan

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

the class ObjectStore method handleSimpleAlter.

private WMFullResourcePlan handleSimpleAlter(String name, WMNullableResourcePlan changes, boolean canActivateDisabled, boolean canDeactivate) throws InvalidOperationException, NoSuchObjectException, MetaException {
    MWMResourcePlan plan = name == null ? getActiveMWMResourcePlan() : getMWMResourcePlan(name, !changes.isSetStatus());
    boolean hasNameChange = changes.isSetName() && !changes.getName().equals(name);
    // Verify that field changes are consistent with what Hive does. Note: we could handle this.
    if (changes.isSetIsSetQueryParallelism() || changes.isSetIsSetDefaultPoolPath() || hasNameChange) {
        if (changes.isSetStatus()) {
            throw new InvalidOperationException("Cannot change values during status switch.");
        } else if (plan.getStatus() != MWMResourcePlan.Status.DISABLED) {
            throw new InvalidOperationException("Resource plan must be disabled to edit it.");
        }
    }
    // Handle rename and other changes.
    if (changes.isSetName()) {
        String newName = normalizeIdentifier(changes.getName());
        if (newName.isEmpty()) {
            throw new InvalidOperationException("Cannot rename to empty value.");
        }
        if (!newName.equals(plan.getName())) {
            plan.setName(newName);
        }
    }
    if (changes.isSetIsSetQueryParallelism() && changes.isIsSetQueryParallelism()) {
        if (changes.isSetQueryParallelism()) {
            if (changes.getQueryParallelism() <= 0) {
                throw new InvalidOperationException("queryParallelism should be positive.");
            }
            plan.setQueryParallelism(changes.getQueryParallelism());
        } else {
            plan.setQueryParallelism(null);
        }
    }
    if (changes.isSetIsSetDefaultPoolPath() && changes.isIsSetDefaultPoolPath()) {
        if (changes.isSetDefaultPoolPath()) {
            MWMPool pool = getPool(plan, changes.getDefaultPoolPath());
            plan.setDefaultPool(pool);
        } else {
            plan.setDefaultPool(null);
        }
    }
    // Handle the status change.
    if (changes.isSetStatus()) {
        return switchStatus(name, plan, changes.getStatus().name(), canActivateDisabled, canDeactivate);
    }
    return 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 22 with MWMResourcePlan

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

the class ObjectStore method createPool.

@Override
public void createPool(WMPool pool) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
    boolean commited = false;
    try {
        openTransaction();
        MWMResourcePlan resourcePlan = getMWMResourcePlan(pool.getResourcePlanName(), true);
        if (!poolParentExists(resourcePlan, pool.getPoolPath())) {
            throw new NoSuchObjectException("Pool path is invalid, the parent does not exist");
        }
        String policy = pool.getSchedulingPolicy();
        if (!MetaStoreUtils.isValidSchedulingPolicy(policy)) {
            throw new InvalidOperationException("Invalid scheduling policy " + policy);
        }
        MWMPool mPool = new MWMPool(resourcePlan, pool.getPoolPath(), pool.getAllocFraction(), pool.getQueryParallelism(), policy);
        pm.makePersistent(mPool);
        commited = commitTransaction();
    } catch (Exception e) {
        checkForConstraintException(e, "Pool already exists: ");
        throw e;
    } finally {
        rollbackAndCleanup(commited, (Query) null);
    }
}
Also used : MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MWMResourcePlan(org.apache.hadoop.hive.metastore.model.MWMResourcePlan) AlreadyExistsException(org.apache.hadoop.hive.metastore.api.AlreadyExistsException) InvalidInputException(org.apache.hadoop.hive.metastore.api.InvalidInputException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) IOException(java.io.IOException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) JDOCanRetryException(javax.jdo.JDOCanRetryException) InvalidPartitionException(org.apache.hadoop.hive.metastore.api.InvalidPartitionException) UnknownPartitionException(org.apache.hadoop.hive.metastore.api.UnknownPartitionException) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) JDOException(javax.jdo.JDOException) MissingTableException(org.datanucleus.store.rdbms.exceptions.MissingTableException) SQLException(java.sql.SQLException) UnknownDBException(org.apache.hadoop.hive.metastore.api.UnknownDBException) TException(org.apache.thrift.TException) JDODataStoreException(javax.jdo.JDODataStoreException) JDOObjectNotFoundException(javax.jdo.JDOObjectNotFoundException) UnknownTableException(org.apache.hadoop.hive.metastore.api.UnknownTableException)

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