use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStore method getDatabases.
@Override
public List<String> getDatabases(String pattern) throws MetaException {
boolean commit = false;
openTransaction();
try {
List<Database> dbs = getHBase().scanDatabases(pattern == null ? null : HiveStringUtils.normalizeIdentifier(likeToRegex(pattern)));
List<String> dbNames = new ArrayList<String>(dbs.size());
for (Database db : dbs) dbNames.add(db.getName());
commit = true;
return dbNames;
} catch (IOException e) {
LOG.error("Unable to get databases ", e);
throw new MetaException("Unable to get databases, " + e.getMessage());
} finally {
commitOrRoleBack(commit);
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStore method createFunction.
@Override
public void createFunction(Function func) throws InvalidObjectException, MetaException {
boolean commit = false;
openTransaction();
try {
getHBase().putFunction(func);
commit = true;
} catch (IOException e) {
LOG.error("Unable to create function", e);
throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
} finally {
commitOrRoleBack(commit);
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStore method createDatabase.
@Override
public void createDatabase(Database db) throws InvalidObjectException, MetaException {
boolean commit = false;
openTransaction();
try {
Database dbCopy = db.deepCopy();
dbCopy.setName(HiveStringUtils.normalizeIdentifier(dbCopy.getName()));
// HiveMetaStore already checks for existence of the database, don't recheck
getHBase().putDb(dbCopy);
commit = true;
} catch (IOException e) {
LOG.error("Unable to create database ", e);
throw new MetaException("Unable to read from or write to hbase " + e.getMessage());
} finally {
commitOrRoleBack(commit);
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStore method dropIndex.
@Override
public boolean dropIndex(String dbName, String origTableName, String indexName) throws MetaException {
boolean commit = false;
openTransaction();
try {
getHBase().deleteIndex(HiveStringUtils.normalizeIdentifier(dbName), HiveStringUtils.normalizeIdentifier(origTableName), HiveStringUtils.normalizeIdentifier(indexName));
commit = true;
return true;
} catch (IOException e) {
LOG.error("Unable to delete index" + e);
throw new MetaException("Unable to drop index " + indexNameForErrorMsg(dbName, origTableName, indexName));
} finally {
commitOrRoleBack(commit);
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStore method getForeignKeys.
@Override
public List<SQLForeignKey> getForeignKeys(String parent_db_name, String parent_tbl_name, String foreign_db_name, String foreign_tbl_name) throws MetaException {
boolean commit = false;
openTransaction();
try {
List<SQLForeignKey> fks = getHBase().getForeignKeys(foreign_db_name, foreign_tbl_name);
if (fks == null || fks.size() == 0)
return null;
List<SQLForeignKey> result = new ArrayList<>(fks.size());
for (SQLForeignKey fkcol : fks) {
if ((parent_db_name == null || fkcol.getPktable_db().equals(parent_db_name)) && (parent_tbl_name == null || fkcol.getPktable_name().equals(parent_tbl_name))) {
result.add(fkcol);
}
}
commit = true;
return result;
} catch (IOException e) {
LOG.error("Unable to get foreign key", e);
throw new MetaException("Error reading db " + e.getMessage());
} finally {
commitOrRoleBack(commit);
}
}
Aggregations