Search in sources :

Example 6 with MWMResourcePlan

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

Example 7 with MWMResourcePlan

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

Example 8 with MWMResourcePlan

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

Example 9 with MWMResourcePlan

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

Example 10 with MWMResourcePlan

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