use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStore method revokeRole.
@Override
public boolean revokeRole(Role role, String userName, PrincipalType principalType, boolean grantOption) throws MetaException, NoSuchObjectException {
boolean commit = false;
openTransaction();
// then we need to remove the userName from the role altogether.
try {
if (grantOption) {
// If this is a grant only change, we don't need to rebuild the user mappings.
getHBase().dropPrincipalFromRole(role.getRoleName(), userName, principalType, grantOption);
} else {
Set<String> usersToRemap = findUsersToRemapRolesFor(role, userName, principalType);
getHBase().dropPrincipalFromRole(role.getRoleName(), userName, principalType, grantOption);
for (String user : usersToRemap) {
getHBase().buildRoleMapForUser(user);
}
}
commit = true;
return true;
} catch (IOException e) {
LOG.error("Unable to revoke role " + role.getRoleName() + " from " + userName, e);
throw new MetaException("Unable to revoke role " + e.getMessage());
} finally {
commitOrRoleBack(commit);
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class DDLTask method preInsertWork.
private int preInsertWork(Hive db, PreInsertTableDesc preInsertTableDesc) throws HiveException {
try {
HiveMetaHook hook = preInsertTableDesc.getTable().getStorageHandler().getMetaHook();
if (hook == null || !(hook instanceof DefaultHiveMetaHook)) {
return 0;
}
DefaultHiveMetaHook hiveMetaHook = (DefaultHiveMetaHook) hook;
hiveMetaHook.preInsertTable(preInsertTableDesc.getTable().getTTable(), preInsertTableDesc.isOverwrite());
} catch (MetaException e) {
throw new HiveException(e);
}
return 0;
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HBaseStorageHandler method commitDropTable.
@Override
public void commitDropTable(Table tbl, boolean deleteData) throws MetaException {
try {
String tableName = getHBaseTableName(tbl);
boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
if (deleteData && !isExternal) {
if (getHBaseAdmin().isTableEnabled(tableName)) {
getHBaseAdmin().disableTable(tableName);
}
getHBaseAdmin().deleteTable(tableName);
}
} catch (IOException ie) {
throw new MetaException(StringUtils.stringifyException(ie));
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HCatClientHMSImpl method dropPartitions.
@Override
public void dropPartitions(String dbName, String tableName, Map<String, String> partitionSpec, boolean ifExists, boolean deleteData) throws HCatException {
LOG.info("HCatClient dropPartitions(db=" + dbName + ",table=" + tableName + ", partitionSpec: [" + partitionSpec + "]).");
try {
dbName = checkDB(dbName);
Table table = hmsClient.getTable(dbName, tableName);
if (hiveConfig.getBoolVar(HiveConf.ConfVars.METASTORE_CLIENT_DROP_PARTITIONS_WITH_EXPRESSIONS)) {
try {
dropPartitionsUsingExpressions(table, partitionSpec, ifExists, deleteData);
} catch (SemanticException parseFailure) {
LOG.warn("Could not push down partition-specification to back-end, for dropPartitions(). Resorting to iteration.", parseFailure);
dropPartitionsIteratively(dbName, tableName, partitionSpec, ifExists, deleteData);
}
} else {
// Not using expressions.
dropPartitionsIteratively(dbName, tableName, partitionSpec, ifExists, deleteData);
}
} catch (NoSuchObjectException e) {
throw new ObjectNotFoundException("NoSuchObjectException while dropping partition. " + "Either db(" + dbName + ") or table(" + tableName + ") missing.", e);
} catch (MetaException e) {
throw new HCatException("MetaException while dropping partition.", e);
} catch (TException e) {
throw new ConnectionFailureException("TException while dropping partition.", e);
}
}
use of org.apache.hadoop.hive.metastore.api.MetaException in project hive by apache.
the class HCatClientHMSImpl method listPartitionsByFilter.
@Override
public List<HCatPartition> listPartitionsByFilter(String dbName, String tblName, String filter) throws HCatException {
List<HCatPartition> hcatPtns = new ArrayList<HCatPartition>();
try {
HCatTable table = getTable(dbName, tblName);
List<Partition> hivePtns = hmsClient.listPartitionsByFilter(table.getDbName(), table.getTableName(), filter, (short) -1);
for (Partition ptn : hivePtns) {
hcatPtns.add(new HCatPartition(table, ptn));
}
} catch (MetaException e) {
throw new HCatException("MetaException while fetching partitions.", e);
} catch (NoSuchObjectException e) {
throw new ObjectNotFoundException("NoSuchObjectException while fetching partitions.", e);
} catch (TException e) {
throw new ConnectionFailureException("TException while fetching partitions.", e);
}
return hcatPtns;
}
Aggregations