Search in sources :

Example 1 with EntityType

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

Aggregations

Query (javax.jdo.Query)1 MWMMapping (org.apache.hadoop.hive.metastore.model.MWMMapping)1 EntityType (org.apache.hadoop.hive.metastore.model.MWMMapping.EntityType)1 MWMPool (org.apache.hadoop.hive.metastore.model.MWMPool)1 MWMResourcePlan (org.apache.hadoop.hive.metastore.model.MWMResourcePlan)1