use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.
the class HiveHBaseTableInputFormat method getTimestampVal.
private long getTimestampVal(IndexSearchCondition sc) throws IOException {
long timestamp;
try {
ExprNodeConstantEvaluator eval = new ExprNodeConstantEvaluator(sc.getConstantDesc());
ObjectInspector inspector = eval.initialize(null);
Object value = eval.evaluate(null);
if (inspector instanceof LongObjectInspector) {
timestamp = ((LongObjectInspector) inspector).get(value);
} else {
PrimitiveObjectInspector primitive = (PrimitiveObjectInspector) inspector;
timestamp = PrimitiveObjectInspectorUtils.getTimestamp(value, primitive).getTime();
}
} catch (HiveException e) {
throw new IOException(e);
}
return timestamp;
}
use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.
the class ResourceMaps method setAuthorizerV2Config.
private void setAuthorizerV2Config() throws HiveException {
// avoid processing the same config multiple times, check marker
if (sessionConf.get(CONFIG_AUTHZ_SETTINGS_APPLIED_MARKER, "").equals(Boolean.TRUE.toString())) {
return;
}
String metastoreHook = sessionConf.get(ConfVars.METASTORE_FILTER_HOOK.name());
if (!ConfVars.METASTORE_FILTER_HOOK.getDefaultValue().equals(metastoreHook) && !AuthorizationMetaStoreFilterHook.class.getName().equals(metastoreHook)) {
LOG.warn(ConfVars.METASTORE_FILTER_HOOK.name() + " will be ignored, since hive.security.authorization.manager" + " is set to instance of HiveAuthorizerFactory.");
}
sessionConf.setVar(ConfVars.METASTORE_FILTER_HOOK, AuthorizationMetaStoreFilterHook.class.getName());
authorizerV2.applyAuthorizationConfigPolicy(sessionConf);
// update config in Hive thread local as well and init the metastore client
try {
Hive.get(sessionConf).getMSC();
} catch (Exception e) {
// that would cause ClassNoFoundException otherwise
throw new HiveException(e.getMessage(), e);
}
// set a marker that this conf has been processed.
sessionConf.set(CONFIG_AUTHZ_SETTINGS_APPLIED_MARKER, Boolean.TRUE.toString());
}
use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.
the class HiveV1Authorizer method getCurrentRoleNames.
@Override
public List<String> getCurrentRoleNames() throws HiveAuthzPluginException {
String userName = SessionState.get().getUserName();
if (userName == null) {
userName = SessionState.getUserFromAuthenticator();
}
if (userName == null) {
throw new HiveAuthzPluginException("Cannot resolve current user name");
}
try {
Hive hive = Hive.getWithFastCheck(this.conf);
List<String> roleNames = new ArrayList<String>();
for (Role role : hive.listRoles(userName, PrincipalType.USER)) {
roleNames.add(role.getRoleName());
}
return roleNames;
} catch (HiveException e) {
throw new HiveAuthzPluginException(e);
}
}
use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.
the class HiveV1Authorizer method dropRole.
@Override
public void dropRole(String roleName) throws HiveAuthzPluginException, HiveAccessControlException {
try {
Hive hive = Hive.getWithFastCheck(this.conf);
hive.dropRole(roleName);
} catch (HiveException e) {
throw new HiveAuthzPluginException(e);
}
}
use of org.apache.hadoop.hive.ql.metadata.HiveException in project hive by apache.
the class HiveV1Authorizer method createRole.
@Override
public void createRole(String roleName, HivePrincipal adminGrantor) throws HiveAuthzPluginException, HiveAccessControlException {
try {
Hive hive = Hive.getWithFastCheck(this.conf);
hive.createRole(roleName, adminGrantor == null ? null : adminGrantor.getName());
} catch (HiveException e) {
throw new HiveAuthzPluginException(e);
}
}
Aggregations