use of org.apache.ranger.admin.client.RangerAdminRESTClient in project ranger by apache.
the class RangerBasePlugin method createAdminClient.
public static RangerAdminClient createAdminClient(String rangerServiceName, String applicationId, String propertyPrefix) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerBasePlugin.createAdminClient(" + rangerServiceName + ", " + applicationId + ", " + propertyPrefix + ")");
}
RangerAdminClient ret = null;
String propertyName = propertyPrefix + ".policy.source.impl";
String policySourceImpl = RangerConfiguration.getInstance().get(propertyName);
if (StringUtils.isEmpty(policySourceImpl)) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Value for property[%s] was null or empty. Unexpected! Will use policy source of type[%s]", propertyName, RangerAdminRESTClient.class.getName()));
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Value for property[%s] was [%s].", propertyName, policySourceImpl));
}
try {
@SuppressWarnings("unchecked") Class<RangerAdminClient> adminClass = (Class<RangerAdminClient>) Class.forName(policySourceImpl);
ret = adminClass.newInstance();
} catch (Exception excp) {
LOG.error("failed to instantiate policy source of type '" + policySourceImpl + "'. Will use policy source of type '" + RangerAdminRESTClient.class.getName() + "'", excp);
}
}
if (ret == null) {
ret = new RangerAdminRESTClient();
}
ret.init(rangerServiceName, applicationId, propertyPrefix);
if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerBasePlugin.createAdminClient(" + rangerServiceName + ", " + applicationId + ", " + propertyPrefix + "): policySourceImpl=" + policySourceImpl + ", client=" + ret);
}
return ret;
}
Aggregations