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();
}
}
}
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;
}
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();
}
}
}
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);
}
}
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();
}
}
}
Aggregations