Search in sources :

Example 1 with MWMTrigger

use of org.apache.hadoop.hive.metastore.model.MWMTrigger 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 2 with MWMTrigger

use of org.apache.hadoop.hive.metastore.model.MWMTrigger 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)

Example 3 with MWMTrigger

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

the class ObjectStore method copyRpContents.

private void copyRpContents(MWMResourcePlan dest, MWMResourcePlan src) {
    dest.setQueryParallelism(src.getQueryParallelism());
    Map<String, MWMPool> pools = new HashMap<>();
    Map<String, Set<MWMPool>> triggersToPools = new HashMap<>();
    for (MWMPool copyPool : src.getPools()) {
        MWMPool pool = new MWMPool(dest, copyPool.getPath(), copyPool.getAllocFraction(), copyPool.getQueryParallelism(), copyPool.getSchedulingPolicy());
        pm.makePersistent(pool);
        pools.put(copyPool.getPath(), pool);
        if (copyPool.getTriggers() != null) {
            for (MWMTrigger trigger : copyPool.getTriggers()) {
                Set<MWMPool> p2t = triggersToPools.get(trigger.getName());
                if (p2t == null) {
                    p2t = new HashSet<>();
                    triggersToPools.put(trigger.getName(), p2t);
                }
                p2t.add(pool);
                pool.setTriggers(new HashSet<>());
            }
        }
    }
    dest.setPools(new HashSet<>(pools.values()));
    if (src.getDefaultPool() != null) {
        dest.setDefaultPool(pools.get(src.getDefaultPool().getPath()));
    }
    Set<MWMMapping> mappings = new HashSet<>();
    for (MWMMapping copyMapping : src.getMappings()) {
        MWMPool pool = null;
        if (copyMapping.getPool() != null) {
            pool = pools.get(copyMapping.getPool().getPath());
        }
        MWMMapping mapping = new MWMMapping(dest, copyMapping.getEntityType(), copyMapping.getEntityName(), pool, copyMapping.getOrdering());
        pm.makePersistent(mapping);
        mappings.add(mapping);
    }
    dest.setMappings(mappings);
    Set<MWMTrigger> triggers = new HashSet<>();
    for (MWMTrigger copyTrigger : src.getTriggers()) {
        Set<MWMPool> p2t = triggersToPools.get(copyTrigger.getName());
        if (p2t == null) {
            p2t = new HashSet<>();
        }
        MWMTrigger trigger = new MWMTrigger(dest, copyTrigger.getName(), copyTrigger.getTriggerExpression(), copyTrigger.getActionExpression(), p2t, copyTrigger.getIsInUnmanaged());
        pm.makePersistent(trigger);
        for (MWMPool pool : p2t) {
            pool.getTriggers().add(trigger);
        }
        triggers.add(trigger);
    }
    dest.setTriggers(triggers);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) PrincipalPrivilegeSet(org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet) HashMap(java.util.HashMap) MWMPool(org.apache.hadoop.hive.metastore.model.MWMPool) MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) MWMMapping(org.apache.hadoop.hive.metastore.model.MWMMapping) HashSet(java.util.HashSet)

Example 4 with MWMTrigger

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

the class ObjectStore method fromMWMTrigger.

private WMTrigger fromMWMTrigger(MWMTrigger mTrigger, String resourcePlanName) {
    WMTrigger trigger = new WMTrigger();
    trigger.setResourcePlanName(resourcePlanName);
    trigger.setTriggerName(mTrigger.getName());
    trigger.setTriggerExpression(mTrigger.getTriggerExpression());
    trigger.setActionExpression(mTrigger.getActionExpression());
    trigger.setIsInUnmanaged(mTrigger.getIsInUnmanaged());
    return trigger;
}
Also used : MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) WMTrigger(org.apache.hadoop.hive.metastore.api.WMTrigger)

Example 5 with MWMTrigger

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

the class ObjectStore method createWMTrigger.

@Override
public void createWMTrigger(WMTrigger trigger) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
    boolean commited = false;
    try {
        openTransaction();
        MWMResourcePlan resourcePlan = getMWMResourcePlan(trigger.getResourcePlanName(), true);
        MWMTrigger mTrigger = new MWMTrigger(resourcePlan, normalizeIdentifier(trigger.getTriggerName()), trigger.getTriggerExpression(), trigger.getActionExpression(), null, trigger.isSetIsInUnmanaged() && trigger.isIsInUnmanaged());
        pm.makePersistent(mTrigger);
        commited = commitTransaction();
    } catch (Exception e) {
        checkForConstraintException(e, "Trigger already exists, use alter: ");
        throw e;
    } finally {
        rollbackAndCleanup(commited, (Query) null);
    }
}
Also used : MWMTrigger(org.apache.hadoop.hive.metastore.model.MWMTrigger) 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

MWMTrigger (org.apache.hadoop.hive.metastore.model.MWMTrigger)9 MWMResourcePlan (org.apache.hadoop.hive.metastore.model.MWMResourcePlan)5 MWMPool (org.apache.hadoop.hive.metastore.model.MWMPool)4 Query (javax.jdo.Query)3 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)2 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)2 WMTrigger (org.apache.hadoop.hive.metastore.api.WMTrigger)2 MWMMapping (org.apache.hadoop.hive.metastore.model.MWMMapping)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Set (java.util.Set)1 JDOCanRetryException (javax.jdo.JDOCanRetryException)1 JDODataStoreException (javax.jdo.JDODataStoreException)1 JDOException (javax.jdo.JDOException)1