Search in sources :

Example 1 with MCatalog

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

the class ObjectStore method dropCatalog.

@Override
public void dropCatalog(String catalogName) throws NoSuchObjectException, MetaException {
    LOG.debug("Dropping catalog {}", catalogName);
    boolean committed = false;
    try {
        openTransaction();
        MCatalog mCat = getMCatalog(catalogName);
        pm.retrieve(mCat);
        if (mCat == null) {
            throw new NoSuchObjectException("No catalog " + catalogName);
        }
        pm.deletePersistent(mCat);
        committed = commitTransaction();
    } finally {
        if (!committed) {
            rollbackTransaction();
        }
    }
}
Also used : NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException) MCatalog(org.apache.hadoop.hive.metastore.model.MCatalog)

Example 2 with MCatalog

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

the class ObjectStore method mCatToCat.

private Catalog mCatToCat(MCatalog mCat) {
    Catalog cat = new Catalog(mCat.getName(), mCat.getLocationUri());
    if (mCat.getDescription() != null) {
        cat.setDescription(mCat.getDescription());
    }
    cat.setCreateTime(mCat.getCreateTime());
    return cat;
}
Also used : MetaStoreUtils.getDefaultCatalog(org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog) Catalog(org.apache.hadoop.hive.metastore.api.Catalog) MCatalog(org.apache.hadoop.hive.metastore.model.MCatalog)

Example 3 with MCatalog

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

the class ObjectStore method alterCatalog.

@Override
public void alterCatalog(String catName, Catalog cat) throws MetaException, InvalidOperationException {
    if (!cat.getName().equals(catName)) {
        throw new InvalidOperationException("You cannot change a catalog's name");
    }
    boolean committed = false;
    try {
        MCatalog mCat = getMCatalog(catName);
        if (org.apache.commons.lang3.StringUtils.isNotBlank(cat.getLocationUri())) {
            mCat.setLocationUri(cat.getLocationUri());
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(cat.getDescription())) {
            mCat.setDescription(cat.getDescription());
        }
        openTransaction();
        pm.makePersistent(mCat);
        committed = commitTransaction();
    } finally {
        if (!committed) {
            rollbackTransaction();
        }
    }
}
Also used : InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) MCatalog(org.apache.hadoop.hive.metastore.model.MCatalog)

Example 4 with MCatalog

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

the class ObjectStore method getMCatalog.

private MCatalog getMCatalog(String catalogName) {
    boolean committed = false;
    Query query = null;
    try {
        openTransaction();
        catalogName = normalizeIdentifier(catalogName);
        query = pm.newQuery(MCatalog.class, "name == catname");
        query.declareParameters("java.lang.String catname");
        query.setUnique(true);
        MCatalog mCat = (MCatalog) query.execute(catalogName);
        pm.retrieve(mCat);
        committed = commitTransaction();
        return mCat;
    } finally {
        rollbackAndCleanup(committed, query);
    }
}
Also used : ScheduledQuery(org.apache.hadoop.hive.metastore.api.ScheduledQuery) Query(javax.jdo.Query) MScheduledQuery(org.apache.hadoop.hive.metastore.model.MScheduledQuery) MCatalog(org.apache.hadoop.hive.metastore.model.MCatalog)

Example 5 with MCatalog

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

the class ObjectStore method createCatalog.

@Override
public void createCatalog(Catalog cat) throws MetaException {
    LOG.debug("Creating catalog {}", cat);
    boolean committed = false;
    MCatalog mCat = catToMCat(cat);
    try {
        openTransaction();
        pm.makePersistent(mCat);
        committed = commitTransaction();
    } finally {
        if (!committed) {
            rollbackTransaction();
        }
    }
}
Also used : MCatalog(org.apache.hadoop.hive.metastore.model.MCatalog)

Aggregations

MCatalog (org.apache.hadoop.hive.metastore.model.MCatalog)7 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)2 Query (javax.jdo.Query)1 Catalog (org.apache.hadoop.hive.metastore.api.Catalog)1 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)1 ScheduledQuery (org.apache.hadoop.hive.metastore.api.ScheduledQuery)1 MScheduledQuery (org.apache.hadoop.hive.metastore.model.MScheduledQuery)1 MetaStoreUtils.getDefaultCatalog (org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog)1