Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.StringUtils;
import org.apache.ranger.plugin.client.HadoopException;
import org.apache.ranger.plugin.service.ResourceLookupContext;
import org.apache.ranger.plugin.util.TimedEventUtil;
Expand All @@ -33,16 +34,16 @@
public class HBaseResourceMgr {

private static final Logger LOG = LoggerFactory.getLogger(HBaseResourceMgr.class);

private static final String TABLE = "table";
private static final String COLUMNFAMILY = "column-family";

public static Map<String, Object> connectionTest(String serviceName, Map<String, String> configs) throws Exception {
Map<String, Object> ret = null;
if(LOG.isDebugEnabled()) {
LOG.debug("<== HBaseResourceMgr.connectionTest() ServiceName: "+ serviceName + "Configs" + configs );
}
}

try {
ret = HBaseClient.connectionTest(serviceName, configs);
} catch (HadoopException e) {
Expand All @@ -51,12 +52,12 @@ public static Map<String, Object> connectionTest(String serviceName, Map<String,
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== HBaseResourceMgr.connectionTest() Result: "+ ret );
}
}
return ret;
}

public static List<String> getHBaseResource(String serviceName, String serviceType, Map<String, String> configs,ResourceLookupContext context) throws Exception{

String userInput = context.getUserInput();
String resource = context.getResourceName();
Map<String, List<String>> resourceMap = context.getResources();
Expand All @@ -65,12 +66,12 @@ public static List<String> getHBaseResource(String serviceName, String serviceTy
String columnFamilies = null;
List<String> tableList = null;
List<String> columnFamilyList = null;

if(LOG.isDebugEnabled()) {
LOG.debug("<== HBaseResourceMgr.getHBaseResource UserInput: \""+ userInput + "\" resource : " + resource + " resourceMap: " + resourceMap);
}
if ( userInput != null && resource != null) {
}

if (StringUtils.isNoneBlank(userInput) && resource != null) {
if ( resourceMap != null && !resourceMap.isEmpty() ) {
tableList = resourceMap.get(TABLE);
columnFamilyList = resourceMap.get(COLUMNFAMILY);
Expand All @@ -87,17 +88,17 @@ public static List<String> getHBaseResource(String serviceName, String serviceTy
}
}

if (serviceName != null && userInput != null) {
if (serviceName != null && StringUtils.isNoneBlank(userInput)) {
final List<String> finaltableList = tableList;
final List<String> finalcolumnFamilyList = columnFamilyList;

try {
if(LOG.isDebugEnabled()) {
LOG.debug("<== HBaseResourceMgr.getHBaseResource UserInput: \""+ userInput + "\" configs: " + configs + " context: " + context);
}
final HBaseClient hBaseClient = new HBaseConnectionMgr().getHBaseConnection(serviceName,serviceType,configs);
Callable<List<String>> callableObj = null;

if ( hBaseClient != null) {
if ( tableName != null && !tableName.isEmpty()) {
final String finalTableName;
Expand Down Expand Up @@ -141,18 +142,18 @@ public List<String> call() {
TimeUnit.SECONDS);
}
}

}
} catch (Exception e) {
LOG.error("Unable to get hbase resources.", e);
throw e;
}
}

if(LOG.isDebugEnabled()) {
LOG.debug("<== HBaseResourceMgr.getHBaseResource() Result :" + resultList);
}

return resultList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.StringUtils;
import org.apache.ranger.plugin.client.HadoopException;
import org.apache.ranger.plugin.service.ResourceLookupContext;
import org.apache.ranger.plugin.util.TimedEventUtil;
Expand All @@ -32,35 +33,35 @@
public class HiveResourceMgr {

private static final Logger LOG = LoggerFactory.getLogger(HiveResourceMgr.class);

private static final String DATABASE = "database";
private static final String TABLE = "table";
private static final String COLUMN = "column";


public static Map<String, Object> connectionTest(String serviceName, Map<String, String> configs) throws Exception {
Map<String, Object> ret = null;

if(LOG.isDebugEnabled()) {
LOG.debug("==> HiveResourceMgr.connectionTest ServiceName: "+ serviceName + "Configs" + configs );
}
}

try {
ret = HiveClient.connectionTest(serviceName, configs);
} catch (HadoopException e) {
LOG.error("<== HiveResourceMgr.connectionTest Error: " + e);
throw e;
}

if(LOG.isDebugEnabled()) {
LOG.debug("<== HiveResourceMgr.connectionTest Result : "+ ret );
}
}

return ret;
}

public static List<String> getHiveResources(String serviceName, String serviceType, Map<String, String> configs,ResourceLookupContext context) throws Exception {

String userInput = context.getUserInput();
String resource = context.getResourceName();
Map<String, List<String>> resourceMap = context.getResources();
Expand All @@ -72,12 +73,12 @@ public static List<String> getHiveResources(String serviceName, String serviceTy
String tableName = null;
String columnName = null;


if(LOG.isDebugEnabled()) {
LOG.debug("<== HiveResourceMgr.getHiveResources() UserInput: \""+ userInput + "\" resource : " + resource + " resourceMap: " + resourceMap);
}
if ( userInput != null && resource != null) {
}

if (StringUtils.isNoneBlank(userInput) && resource != null) {
if ( resourceMap != null && !resourceMap.isEmpty() ) {
databaseList = resourceMap.get(DATABASE);
tableList = resourceMap.get(TABLE);
Expand All @@ -97,27 +98,27 @@ public static List<String> getHiveResources(String serviceName, String serviceTy
break;
}
}
if (serviceName != null && userInput != null) {

if (serviceName != null && StringUtils.isNoneBlank(userInput)) {
try {

if(LOG.isDebugEnabled()) {
LOG.debug("==> HiveResourceMgr.getHiveResources() UserInput: "+ userInput + " configs: " + configs + " databaseList: " + databaseList + " tableList: "
+ tableList + " columnList: " + columnList );
}

final HiveClient hiveClient = new HiveConnectionMgr().getHiveConnection(serviceName, serviceType, configs);

Callable<List<String>> callableObj = null;
final String finalDbName;
final String finalColName;
final String finalTableName;

final List<String> finaldatabaseList = databaseList;
final List<String> finaltableList = tableList;
final List<String> finalcolumnList = columnList;


if ( hiveClient != null) {
if ( databaseName != null
&& !databaseName.isEmpty()){
Expand All @@ -133,7 +134,7 @@ public List<String> call() {
};
} else if ( tableName != null
&& !tableName.isEmpty()) {
// get ColumnList for given Input
// get ColumnList for given Input
tableName += "*";
finalTableName = tableName;
callableObj = new Callable<List<String>>() {
Expand Down Expand Up @@ -184,7 +185,7 @@ public List<String> call() {

}
return resultList;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.ranger.plugin.service.ResourceLookupContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,7 +31,7 @@
public class KnoxResourceMgr {

private static final Logger LOG = LoggerFactory.getLogger(KnoxResourceMgr.class);

private static final String TOPOLOGY = "topology";
private static final String SERVICE = "service";

Expand All @@ -45,16 +46,16 @@ public static Map<String, Object> validateConfig(String serviceName, Map<String,
LOG.error("<== KnoxResourceMgr.connectionTest Error: " + e);
throw e;
}

if(LOG.isDebugEnabled()) {
LOG.debug("<== KnoxResourceMgr.HdfsResourceMgr Result : "+ ret );
}
return ret;
}

public static List<String> getKnoxResources(String serviceName, Map<String, String> configs, ResourceLookupContext context) throws Exception {


String userInput = context.getUserInput();
String resource = context.getResourceName();
Map<String, List<String>> resourceMap = context.getResources();
Expand All @@ -63,8 +64,8 @@ public static List<String> getKnoxResources(String serviceName, Map<String, Stri
List<String> knoxServiceList = null;
String knoxTopologyName = null;
String knoxServiceName = null;
if ( userInput != null && resource != null) {

if (StringUtils.isNoneBlank(userInput) && resource != null) {
if ( resourceMap != null && !resourceMap.isEmpty() ) {
knoxTopologyList = resourceMap.get(TOPOLOGY);
knoxServiceList = resourceMap.get(SERVICE);
Expand All @@ -80,7 +81,7 @@ public static List<String> getKnoxResources(String serviceName, Map<String, Stri
break;
}
}

String knoxUrl = configs.get("knox.url");
String knoxAdminUser = configs.get("username");
String knoxAdminPassword = configs.get("password");
Expand All @@ -99,7 +100,7 @@ public static List<String> getKnoxResources(String serviceName, Map<String, Stri
if(LOG.isDebugEnabled()) {
LOG.debug("<== KnoxResourceMgr.getKnoxResources() knoxUrl: "+ knoxUrl + " knoxAdminUser: " + knoxAdminUser + " topologyName: " + knoxTopologyName + " KnoxServiceName: " + knoxServiceName);
}

final KnoxClient knoxClient = new KnoxConnectionMgr().getKnoxClient(knoxUrl, knoxAdminUser, knoxAdminPassword);
if ( knoxClient != null) {
synchronized(knoxClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.ranger.services.presto.client;

import org.apache.commons.lang.StringUtils;
import org.apache.ranger.plugin.service.ResourceLookupContext;
import org.apache.ranger.plugin.util.TimedEventUtil;
import org.slf4j.Logger;
Expand Down Expand Up @@ -78,7 +79,7 @@ public static List<String> getPrestoResources(String serviceName, String service
LOG.debug("<== PrestoResourceMgr.getPrestoResources() UserInput: \"" + userInput + "\" resource : " + resource + " resourceMap: " + resourceMap);
}

if (userInput != null && resource != null) {
if (StringUtils.isNotBlank(userInput) && resource != null) {
if (resourceMap != null && !resourceMap.isEmpty()) {
catalogList = resourceMap.get(CATALOG);
schemaList = resourceMap.get(SCHEMA);
Expand All @@ -102,7 +103,7 @@ public static List<String> getPrestoResources(String serviceName, String service
}
}

if (serviceName != null && userInput != null) {
if (serviceName != null && StringUtils.isNotBlank(userInput)) {
try {

if (LOG.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public List<String> getResources(ResourceLookupContext context) {
+ " resourceMap: " + resourceMap);
}

if (userInput != null && resource != null) {
if (StringUtils.isNotBlank(userInput) && resource != null) {
if (resourceMap != null && !resourceMap.isEmpty()) {
collectionList = resourceMap.get(RangerSolrConstants.COLLECTION_KEY);
fieldList = resourceMap.get(RangerSolrConstants.FIELD_KEY);
Expand All @@ -294,7 +294,7 @@ public List<String> getResources(ResourceLookupContext context) {
break;
}
}
if (userInput != null) {
if (StringUtils.isNotBlank(userInput)) {
try {
Callable<List<String>> callableObj = null;
final String userInputFinal = userInput;
Expand Down

This file was deleted.

Loading