You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2015/05/27 04:52:27 UTC

[1/5] incubator-ranger git commit: RANGER-246 Revert format changes to RangerBasePlugin

Repository: incubator-ranger
Updated Branches:
  refs/heads/tag-policy 51fba28de -> f796d82bd


RANGER-246 Revert format changes to RangerBasePlugin

Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/48a2cd1e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/48a2cd1e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/48a2cd1e

Branch: refs/heads/tag-policy
Commit: 48a2cd1ec74e1b90fd606042646f62d60c331007
Parents: ec7ac83
Author: Don Bosco Durai <bo...@apache.org>
Authored: Tue May 26 11:22:18 2015 -0700
Committer: Don Bosco Durai <bo...@apache.org>
Committed: Tue May 26 11:22:18 2015 -0700

----------------------------------------------------------------------
 .../ranger/plugin/service/RangerBasePlugin.java | 177 +++++++------------
 1 file changed, 68 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/48a2cd1e/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
index 75ba6b9..8131ab6 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
@@ -43,23 +43,25 @@ import org.apache.ranger.plugin.util.GrantRevokeRequest;
 import org.apache.ranger.plugin.util.PolicyRefresher;
 import org.apache.ranger.plugin.util.ServicePolicies;
 
+
 public class RangerBasePlugin {
 	private static final Log LOG = LogFactory.getLog(RangerBasePlugin.class);
 
-	private String serviceType = null;
-	private String appId = null;
-	private String serviceName = null;
-	private PolicyRefresher refresher = null;
-	private RangerPolicyEngine policyEngine = null;
+	private String                    serviceType  = null;
+	private String                    appId        = null;
+	private String                    serviceName  = null;
+	private PolicyRefresher           refresher    = null;
+	private RangerPolicyEngine        policyEngine = null;
 	private RangerPolicyEngineOptions policyEngineOptions = new RangerPolicyEngineOptions();
 	private RangerAccessResultProcessor resultProcessor = null;
 
 	Map<String, LogHistory> logHistoryList = new Hashtable<String, RangerBasePlugin.LogHistory>();
 	int logInterval = 30000; // 30 seconds
 
+
 	public RangerBasePlugin(String serviceType, String appId) {
 		this.serviceType = serviceType;
-		this.appId = appId;
+		this.appId       = appId;
 	}
 
 	public String getServiceType() {
@@ -75,8 +77,7 @@ public class RangerBasePlugin {
 	public int getServiceDefId() {
 		RangerServiceDef serviceDef = getServiceDef();
 
-		return serviceDef != null && serviceDef.getId() != null ? serviceDef
-				.getId().intValue() : -1;
+		return serviceDef != null && serviceDef.getId() != null ? serviceDef.getId().intValue() : -1;
 	}
 
 	public String getAppId() {
@@ -90,50 +91,29 @@ public class RangerBasePlugin {
 	public void init() {
 		cleanup();
 
-		RangerConfiguration.getInstance().addResourcesForServiceType(
-				serviceType);
+		RangerConfiguration.getInstance().addResourcesForServiceType(serviceType);
 		RangerConfiguration.getInstance().initAudit(appId);
 
-		String propertyPrefix = "ranger.plugin." + serviceType;
-		long pollingIntervalMs = RangerConfiguration.getInstance().getLong(
-				propertyPrefix + ".policy.pollIntervalMs", 30 * 1000);
-		String cacheDir = RangerConfiguration.getInstance().get(
-				propertyPrefix + ".policy.cache.dir");
-
-		serviceName = RangerConfiguration.getInstance().get(
-				propertyPrefix + ".service.name");
-
-		policyEngineOptions.evaluatorType = RangerConfiguration.getInstance()
-				.get(propertyPrefix + ".policyengine.option.evaluator.type",
-						RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED);
-		policyEngineOptions.cacheAuditResults = RangerConfiguration
-				.getInstance().getBoolean(
-						propertyPrefix
-								+ ".policyengine.option.cache.audit.results",
-						true);
-		policyEngineOptions.disableContextEnrichers = RangerConfiguration
-				.getInstance()
-				.getBoolean(
-						propertyPrefix
-								+ ".policyengine.option.disable.context.enrichers",
-						false);
-		policyEngineOptions.disableCustomConditions = RangerConfiguration
-				.getInstance()
-				.getBoolean(
-						propertyPrefix
-								+ ".policyengine.option.disable.custom.conditions",
-						false);
+		String propertyPrefix    = "ranger.plugin." + serviceType;
+		long   pollingIntervalMs = RangerConfiguration.getInstance().getLong(propertyPrefix + ".policy.pollIntervalMs", 30 * 1000);
+		String cacheDir          = RangerConfiguration.getInstance().get(propertyPrefix + ".policy.cache.dir");
+
+		serviceName = RangerConfiguration.getInstance().get(propertyPrefix + ".service.name");
+
+		policyEngineOptions.evaluatorType           = RangerConfiguration.getInstance().get(propertyPrefix + ".policyengine.option.evaluator.type", RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED);
+		policyEngineOptions.cacheAuditResults       = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.cache.audit.results", true);
+		policyEngineOptions.disableContextEnrichers = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.disable.context.enrichers", false);
+		policyEngineOptions.disableCustomConditions = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.disable.custom.conditions", false);
+
 
 		RangerAdminClient admin = createAdminClient(propertyPrefix);
 
-		refresher = new PolicyRefresher(this, serviceType, appId, serviceName,
-				admin, pollingIntervalMs, cacheDir);
+		refresher = new PolicyRefresher(this, serviceType, appId, serviceName, admin, pollingIntervalMs, cacheDir);
 		refresher.startRefresher();
 	}
 
 	public void setPolicies(ServicePolicies policies) {
-		RangerPolicyEngine policyEngine = new RangerPolicyEngineImpl(policies,
-				policyEngineOptions);
+		RangerPolicyEngine policyEngine = new RangerPolicyEngineImpl(policies, policyEngineOptions);
 
 		this.policyEngine = policyEngine;
 	}
@@ -141,11 +121,11 @@ public class RangerBasePlugin {
 	public void cleanup() {
 		PolicyRefresher refresher = this.refresher;
 
-		this.serviceName = null;
+		this.serviceName  = null;
 		this.policyEngine = null;
-		this.refresher = null;
+		this.refresher    = null;
 
-		if (refresher != null) {
+		if(refresher != null) {
 			refresher.stopRefresher();
 		}
 	}
@@ -162,16 +142,14 @@ public class RangerBasePlugin {
 		return isAccessAllowed(request, resultProcessor);
 	}
 
-	public Collection<RangerAccessResult> isAccessAllowed(
-			Collection<RangerAccessRequest> requests) {
+	public Collection<RangerAccessResult> isAccessAllowed(Collection<RangerAccessRequest> requests) {
 		return isAccessAllowed(requests, resultProcessor);
 	}
 
-	public RangerAccessResult isAccessAllowed(RangerAccessRequest request,
-			RangerAccessResultProcessor resultProcessor) {
+	public RangerAccessResult isAccessAllowed(RangerAccessRequest request, RangerAccessResultProcessor resultProcessor) {
 		RangerPolicyEngine policyEngine = this.policyEngine;
 
-		if (policyEngine != null) {
+		if(policyEngine != null) {
 			policyEngine.enrichContext(request);
 
 			return policyEngine.isAccessAllowed(request, resultProcessor);
@@ -180,12 +158,10 @@ public class RangerBasePlugin {
 		return null;
 	}
 
-	public Collection<RangerAccessResult> isAccessAllowed(
-			Collection<RangerAccessRequest> requests,
-			RangerAccessResultProcessor resultProcessor) {
+	public Collection<RangerAccessResult> isAccessAllowed(Collection<RangerAccessRequest> requests, RangerAccessResultProcessor resultProcessor) {
 		RangerPolicyEngine policyEngine = this.policyEngine;
 
-		if (policyEngine != null) {
+		if(policyEngine != null) {
 			policyEngine.enrichContext(requests);
 
 			return policyEngine.isAccessAllowed(requests, resultProcessor);
@@ -197,26 +173,24 @@ public class RangerBasePlugin {
 	public RangerAccessResult createAccessResult(RangerAccessRequest request) {
 		RangerPolicyEngine policyEngine = this.policyEngine;
 
-		if (policyEngine != null) {
+		if(policyEngine != null) {
 			return policyEngine.createAccessResult(request);
 		}
 
 		return null;
 	}
 
-	public void grantAccess(GrantRevokeRequest request,
-			RangerAccessResultProcessor resultProcessor) throws Exception {
-		if (LOG.isDebugEnabled()) {
+	public void grantAccess(GrantRevokeRequest request, RangerAccessResultProcessor resultProcessor) throws Exception {
+		if(LOG.isDebugEnabled()) {
 			LOG.debug("==> RangerAdminRESTClient.grantAccess(" + request + ")");
 		}
 
-		PolicyRefresher refresher = this.refresher;
-		RangerAdminClient admin = refresher == null ? null : refresher
-				.getRangerAdminClient();
-		boolean isSuccess = false;
+		PolicyRefresher   refresher = this.refresher;
+		RangerAdminClient admin     = refresher == null ? null : refresher.getRangerAdminClient();
+		boolean           isSuccess = false;
 
 		try {
-			if (admin == null) {
+			if(admin == null) {
 				throw new Exception("ranger-admin client is null");
 			}
 
@@ -227,24 +201,22 @@ public class RangerBasePlugin {
 			auditGrantRevoke(request, "grant", isSuccess, resultProcessor);
 		}
 
-		if (LOG.isDebugEnabled()) {
+		if(LOG.isDebugEnabled()) {
 			LOG.debug("<== RangerAdminRESTClient.grantAccess(" + request + ")");
 		}
 	}
 
-	public void revokeAccess(GrantRevokeRequest request,
-			RangerAccessResultProcessor resultProcessor) throws Exception {
-		if (LOG.isDebugEnabled()) {
+	public void revokeAccess(GrantRevokeRequest request, RangerAccessResultProcessor resultProcessor) throws Exception {
+		if(LOG.isDebugEnabled()) {
 			LOG.debug("==> RangerAdminRESTClient.revokeAccess(" + request + ")");
 		}
 
-		PolicyRefresher refresher = this.refresher;
-		RangerAdminClient admin = refresher == null ? null : refresher
-				.getRangerAdminClient();
-		boolean isSuccess = false;
+		PolicyRefresher   refresher = this.refresher;
+		RangerAdminClient admin     = refresher == null ? null : refresher.getRangerAdminClient();
+		boolean           isSuccess = false;
 
 		try {
-			if (admin == null) {
+			if(admin == null) {
 				throw new Exception("ranger-admin client is null");
 			}
 
@@ -255,72 +227,59 @@ public class RangerBasePlugin {
 			auditGrantRevoke(request, "revoke", isSuccess, resultProcessor);
 		}
 
-		if (LOG.isDebugEnabled()) {
+		if(LOG.isDebugEnabled()) {
 			LOG.debug("<== RangerAdminRESTClient.revokeAccess(" + request + ")");
 		}
 	}
 
+
 	private RangerAdminClient createAdminClient(String propertyPrefix) {
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("==> RangerAdminRESTClient.createAdminClient("
-					+ propertyPrefix + ")");
+		if(LOG.isDebugEnabled()) {
+			LOG.debug("==> RangerAdminRESTClient.createAdminClient(" + propertyPrefix + ")");
 		}
 
 		RangerAdminClient ret = null;
 
 		String propertyName = propertyPrefix + ".policy.source.impl";
-		String policySourceImpl = RangerConfiguration.getInstance().get(
-				propertyName);
+		String policySourceImpl = RangerConfiguration.getInstance().get(propertyName);
 
-		if (StringUtils.isEmpty(policySourceImpl)) {
+		if(StringUtils.isEmpty(policySourceImpl)) {
 			if (LOG.isDebugEnabled()) {
-				LOG.debug(String
-						.format("Value for property[%s] was null or empty. Unxpected! Will use policy source of type[%s]",
-								propertyName,
-								RangerAdminRESTClient.class.getName()));
+				LOG.debug(String.format("Value for property[%s] was null or empty. Unxpected! 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));
+				LOG.debug(String.format("Value for property[%s] was [%s].", propertyName, policySourceImpl));
 			}
 			try {
 				@SuppressWarnings("unchecked")
-				Class<RangerAdminClient> adminClass = (Class<RangerAdminClient>) Class
-						.forName(policySourceImpl);
-
+				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);
+				LOG.error("failed to instantiate policy source of type '" + policySourceImpl + "'. Will use policy source of type '" + RangerAdminRESTClient.class.getName() + "'", excp);
 			}
 		}
 
-		if (ret == null) {
+		if(ret == null) {
 			ret = new RangerAdminRESTClient();
 		}
 
 		ret.init(serviceName, appId, propertyPrefix);
 
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("<== RangerAdminRESTClient.createAdminClient("
-					+ propertyPrefix + "): policySourceImpl="
-					+ policySourceImpl + ", client=" + ret);
+		if(LOG.isDebugEnabled()) {
+			LOG.debug("<== RangerAdminRESTClient.createAdminClient(" + propertyPrefix + "): policySourceImpl=" + policySourceImpl + ", client=" + ret);
 		}
 		return ret;
 	}
 
-	private void auditGrantRevoke(GrantRevokeRequest request, String action,
-			boolean isSuccess, RangerAccessResultProcessor resultProcessor) {
+	private void auditGrantRevoke(GrantRevokeRequest request, String action, boolean isSuccess, RangerAccessResultProcessor resultProcessor) {
 		RangerPolicyEngine policyEngine = this.policyEngine;
 
-		if (request != null && resultProcessor != null && policyEngine != null) {
+		if(request != null && resultProcessor != null && policyEngine != null) {
 			RangerAccessRequestImpl accessRequest = new RangerAccessRequestImpl();
-
-			accessRequest.setResource(new RangerAccessResourceImpl(request
-					.getResource()));
+	
+			accessRequest.setResource(new RangerAccessResourceImpl(request.getResource()));
 			accessRequest.setUser(request.getGrantor());
 			accessRequest.setAccessType(RangerPolicyEngine.ADMIN_ACCESS);
 			accessRequest.setAction(action);
@@ -330,14 +289,13 @@ public class RangerBasePlugin {
 			accessRequest.setSessionId(request.getSessionId());
 
 			// call isAccessAllowed() to determine if audit is enabled or not
-			RangerAccessResult accessResult = policyEngine.isAccessAllowed(
-					accessRequest, null);
+			RangerAccessResult accessResult = policyEngine.isAccessAllowed(accessRequest, null);
 
-			if (accessResult != null && accessResult.getIsAudited()) {
+			if(accessResult != null && accessResult.getIsAudited()) {
 				accessRequest.setAccessType(action);
 				accessResult.setIsAllowed(isSuccess);
 
-				if (!isSuccess) {
+				if(! isSuccess) {
 					accessResult.setPolicyId(-1);
 				}
 
@@ -345,7 +303,7 @@ public class RangerBasePlugin {
 			}
 		}
 	}
-
+	
 	public boolean logErrorMessage(String message) {
 		LogHistory log = logHistoryList.get(message);
 		if (log == null) {
@@ -365,4 +323,5 @@ public class RangerBasePlugin {
 		long lastLogTime;
 		String message;
 	}
+
 }


[3/5] incubator-ranger git commit: Removing unused globalCounter of messages

Posted by ma...@apache.org.
Removing unused globalCounter of messages

Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/5596d2ec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/5596d2ec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/5596d2ec

Branch: refs/heads/tag-policy
Commit: 5596d2ecda5e50a3d3883b97d5ec3eac298df6f9
Parents: 0d84793
Author: Don Bosco Durai <bo...@apache.org>
Authored: Tue May 26 13:55:07 2015 -0700
Committer: Don Bosco Durai <bo...@apache.org>
Committed: Tue May 26 13:55:07 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/ranger/plugin/service/RangerBasePlugin.java    | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5596d2ec/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
index 7af103d..574dd5b 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
@@ -310,7 +310,6 @@ public class RangerBasePlugin {
 			log = new LogHistory();
 			logHistoryList.put(message, log);
 		}
-		log.lifetimeCounter++;
 		if ((System.currentTimeMillis() - log.lastLogTime) > logInterval) {
 			log.lastLogTime = System.currentTimeMillis();
 			int counter = log.counter;
@@ -329,7 +328,6 @@ public class RangerBasePlugin {
 	static class LogHistory {
 		long lastLogTime = 0;
 		int counter=0;
-		int lifetimeCounter = 0;
 	}
 
 }


[5/5] incubator-ranger git commit: Merge branch 'master' into tag-policy

Posted by ma...@apache.org.
Merge branch 'master' into tag-policy


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/f796d82b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/f796d82b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/f796d82b

Branch: refs/heads/tag-policy
Commit: f796d82bdb3104dd3f74afa51d36c414e9e88041
Parents: 51fba28 80c46f2
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Tue May 26 19:52:06 2015 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue May 26 19:52:06 2015 -0700

----------------------------------------------------------------------
 .../ranger/plugin/service/RangerBasePlugin.java | 197 ++++++++-----------
 .../plugin/store/EmbeddedServiceDefsUtil.java   |  14 ++
 src/main/assembly/admin-web.xml                 |  65 ++++++
 3 files changed, 158 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f796d82b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
----------------------------------------------------------------------
diff --cc agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
index fc5b954,574dd5b..26ef659
--- a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
@@@ -90,43 -91,20 +91,20 @@@ public class RangerBasePlugin 
  	public void init() {
  		cleanup();
  
- 		RangerConfiguration.getInstance().addResourcesForServiceType(
- 				serviceType);
+ 		RangerConfiguration.getInstance().addResourcesForServiceType(serviceType);
  		RangerConfiguration.getInstance().initAudit(appId);
  
- 		String propertyPrefix = "ranger.plugin." + serviceType;
- 		long pollingIntervalMs = RangerConfiguration.getInstance().getLong(
- 				propertyPrefix + ".policy.pollIntervalMs", 30 * 1000);
- 		String cacheDir = RangerConfiguration.getInstance().get(
- 				propertyPrefix + ".policy.cache.dir");
- 
- 		serviceName = RangerConfiguration.getInstance().get(
- 				propertyPrefix + ".service.name");
- 
- 		policyEngineOptions.evaluatorType = RangerConfiguration.getInstance()
- 				.get(propertyPrefix + ".policyengine.option.evaluator.type",
- 						RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED);
- 		policyEngineOptions.cacheAuditResults = RangerConfiguration
- 				.getInstance().getBoolean(
- 						propertyPrefix
- 								+ ".policyengine.option.cache.audit.results",
- 						true);
- 		policyEngineOptions.disableContextEnrichers = RangerConfiguration
- 				.getInstance()
- 				.getBoolean(
- 						propertyPrefix
- 								+ ".policyengine.option.disable.context.enrichers",
- 						false);
- 		policyEngineOptions.disableCustomConditions = RangerConfiguration
- 				.getInstance()
- 				.getBoolean(
- 						propertyPrefix
- 								+ ".policyengine.option.disable.custom.conditions",
- 						false);
- 		policyEngineOptions.disableTagPolicyEvaluation = RangerConfiguration
- 				.getInstance().getBoolean(
- 						propertyPrefix
- 								+ ".policyengine.option.disable.tagpolicy.evaluation", false);
+ 		String propertyPrefix    = "ranger.plugin." + serviceType;
+ 		long   pollingIntervalMs = RangerConfiguration.getInstance().getLong(propertyPrefix + ".policy.pollIntervalMs", 30 * 1000);
+ 		String cacheDir          = RangerConfiguration.getInstance().get(propertyPrefix + ".policy.cache.dir");
+ 
+ 		serviceName = RangerConfiguration.getInstance().get(propertyPrefix + ".service.name");
+ 
+ 		policyEngineOptions.evaluatorType           = RangerConfiguration.getInstance().get(propertyPrefix + ".policyengine.option.evaluator.type", RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED);
+ 		policyEngineOptions.cacheAuditResults       = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.cache.audit.results", true);
+ 		policyEngineOptions.disableContextEnrichers = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.disable.context.enrichers", false);
+ 		policyEngineOptions.disableCustomConditions = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.disable.custom.conditions", false);
 -
++		policyEngineOptions.disableTagPolicyEvaluation = RangerConfiguration.getInstance().getBoolean(propertyPrefix + ".policyengine.option.disable.tagpolicy.evaluation", false);
  
  		RangerAdminClient admin = createAdminClient(propertyPrefix);
  

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f796d82b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
----------------------------------------------------------------------
diff --cc agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
index dcf6288,2115256..664f877
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
@@@ -92,9 -93,8 +96,11 @@@ public class EmbeddedServiceDefsUtil 
  			stormServiceDef = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_STORM_NAME);
  			yarnServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_YARN_NAME);
  			kmsServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KMS_NAME);
+ 			kafkaServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KAFKA_NAME);
+ 			solrServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_SOLR_NAME);
 +
 +			// Ensure that tag service def is updated with access types of all service defs
 +			store.updateTagServiceDefForAccessTypes();
  		} catch(Throwable excp) {
  			LOG.fatal("EmbeddedServiceDefsUtil.init(): failed", excp);
  		}


[2/5] incubator-ranger git commit: RANGER-246 Incorporated review feedback

Posted by ma...@apache.org.
RANGER-246 Incorporated review feedback

Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/0d847939
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/0d847939
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/0d847939

Branch: refs/heads/tag-policy
Commit: 0d8479394c4912d18ccad61979cd4e9bb8cc6713
Parents: 48a2cd1
Author: Don Bosco Durai <bo...@apache.org>
Authored: Tue May 26 12:40:01 2015 -0700
Committer: Don Bosco Durai <bo...@apache.org>
Committed: Tue May 26 12:40:01 2015 -0700

----------------------------------------------------------------------
 .../ranger/plugin/service/RangerBasePlugin.java   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0d847939/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
index 8131ab6..7af103d 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java
@@ -308,20 +308,28 @@ public class RangerBasePlugin {
 		LogHistory log = logHistoryList.get(message);
 		if (log == null) {
 			log = new LogHistory();
-			log.message = message;
-			log.lastLogTime = 0;
+			logHistoryList.put(message, log);
 		}
+		log.lifetimeCounter++;
 		if ((System.currentTimeMillis() - log.lastLogTime) > logInterval) {
 			log.lastLogTime = System.currentTimeMillis();
+			int counter = log.counter;
+			log.counter = 0;
+			if( counter > 0) {
+				message += ". Messages suppressed before: " + counter;
+			}
 			LOG.error(message);
 			return true;
+		} else {
+			log.counter++;
 		}
 		return false;
 	}
 
-	class LogHistory {
-		long lastLogTime;
-		String message;
+	static class LogHistory {
+		long lastLogTime = 0;
+		int counter=0;
+		int lifetimeCounter = 0;
 	}
 
 }


[4/5] incubator-ranger git commit: RANGER-246 Enable Kafka service by default

Posted by ma...@apache.org.
RANGER-246 Enable Kafka service by default

Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/80c46f22
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/80c46f22
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/80c46f22

Branch: refs/heads/tag-policy
Commit: 80c46f22f2790f8dfe5eea66d4fd433c469c2a0d
Parents: 5596d2e
Author: Don Bosco Durai <bo...@apache.org>
Authored: Tue May 26 16:51:09 2015 -0700
Committer: Don Bosco Durai <bo...@apache.org>
Committed: Tue May 26 16:51:09 2015 -0700

----------------------------------------------------------------------
 .../plugin/store/EmbeddedServiceDefsUtil.java   | 14 +++++
 src/main/assembly/admin-web.xml                 | 65 ++++++++++++++++++++
 2 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/80c46f22/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
index 2930606..2115256 100755
--- a/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/store/EmbeddedServiceDefsUtil.java
@@ -50,6 +50,8 @@ public class EmbeddedServiceDefsUtil {
 	public static final String EMBEDDED_SERVICEDEF_STORM_NAME = "storm";
 	public static final String EMBEDDED_SERVICEDEF_YARN_NAME  = "yarn";
 	public static final String EMBEDDED_SERVICEDEF_KMS_NAME  = "kms";
+	public static final String EMBEDDED_SERVICEDEF_KAFKA_NAME  = "kafka";
+	public static final String EMBEDDED_SERVICEDEF_SOLR_NAME  = "solr";
 	public static final String PROPERTY_CREATE_EMBEDDED_SERVICE_DEFS = "ranger.service.store.create.embedded.service-defs";
 
 	private static EmbeddedServiceDefsUtil instance = new EmbeddedServiceDefsUtil();
@@ -62,6 +64,8 @@ public class EmbeddedServiceDefsUtil {
 	private RangerServiceDef stormServiceDef = null;
 	private RangerServiceDef yarnServiceDef  = null;
 	private RangerServiceDef kmsServiceDef  = null;
+	private RangerServiceDef kafkaServiceDef  = null;
+	private RangerServiceDef solrServiceDef  = null;
 
 	private Gson gsonBuilder = null;
 
@@ -89,6 +93,8 @@ public class EmbeddedServiceDefsUtil {
 			stormServiceDef = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_STORM_NAME);
 			yarnServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_YARN_NAME);
 			kmsServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KMS_NAME);
+			kafkaServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_KAFKA_NAME);
+			solrServiceDef  = getOrCreateServiceDef(store, EMBEDDED_SERVICEDEF_SOLR_NAME);
 		} catch(Throwable excp) {
 			LOG.fatal("EmbeddedServiceDefsUtil.init(): failed", excp);
 		}
@@ -124,6 +130,14 @@ public class EmbeddedServiceDefsUtil {
 		return getId(kmsServiceDef);
 	}
 	
+	public long getKafkaServiceDefId() {
+		return getId(kafkaServiceDef);
+	}
+
+	public long getSolrServiceDefId() {
+		return getId(solrServiceDef);
+	}
+
 	private long getId(RangerServiceDef serviceDef) {
 		return serviceDef == null || serviceDef.getId() == null ? -1 : serviceDef.getId().longValue();
 	}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/80c46f22/src/main/assembly/admin-web.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/admin-web.xml b/src/main/assembly/admin-web.xml
index 9136418..4f34ef6 100644
--- a/src/main/assembly/admin-web.xml
+++ b/src/main/assembly/admin-web.xml
@@ -266,8 +266,73 @@
 	    <include>org.apache.ranger:jisql</include>
      </includes>
     </moduleSet>
+    
+    	     <moduleSet>
+     			<binaries>
+        			<includeDependencies>true</includeDependencies>
+        			<outputDirectory>/ews/webapp/WEB-INF/classes/ranger-plugins/kafka</outputDirectory>
+        			<unpack>false</unpack>
+        			<directoryMode>755</directoryMode>
+        			<fileMode>644</fileMode>
+     			</binaries>
+     			<includes>
+       				<include>security_plugins.ranger-kafka-plugin:ranger-kafka-plugin</include>
+     			</includes>
+    		</moduleSet>
+    		
+    		<moduleSet>
+     			<binaries>
+        			<includeDependencies>true</includeDependencies>
+        			<outputDirectory>/ews/webapp/WEB-INF/classes/ranger-plugins/solr</outputDirectory>
+        			<unpack>false</unpack>
+        			<directoryMode>755</directoryMode>
+        			<fileMode>644</fileMode>
+     			</binaries>
+     			<includes>
+       				<include>security_plugins.ranger-solr-plugin:ranger-solr-plugin</include>
+     			</includes>
+    		</moduleSet>
   </moduleSets> 	
 
+<!-- 
+  <profiles>
+      <profile>
+          <id>kafka-security</id>
+          <moduleSets>
+     		<moduleSet>
+     			<binaries>
+        			<includeDependencies>true</includeDependencies>
+        			<outputDirectory>/ews/webapp/WEB-INF/classes/ranger-plugins/kafka</outputDirectory>
+        			<unpack>false</unpack>
+        			<directoryMode>755</directoryMode>
+        			<fileMode>644</fileMode>
+     			</binaries>
+     			<includes>
+       				<include>security_plugins.ranger-kafka-plugin:ranger-kafka-plugin</include>
+     			</includes>
+    		</moduleSet>
+    	</moduleSets>
+      </profile>
+      <profile>
+          <id>solr-security</id>
+          <moduleSets>
+     		<moduleSet>
+     			<binaries>
+        			<includeDependencies>true</includeDependencies>
+        			<outputDirectory>/ews/webapp/WEB-INF/classes/ranger-plugins/solr</outputDirectory>
+        			<unpack>false</unpack>
+        			<directoryMode>755</directoryMode>
+        			<fileMode>644</fileMode>
+     			</binaries>
+     			<includes>
+       				<include>security_plugins.ranger-solr-plugin:ranger-solr-plugin</include>
+     			</includes>
+    		</moduleSet>
+    	</moduleSets>
+      </profile>
+      
+  </profiles>
+   -->
   <fileSets>
 	<fileSet>
 		<outputDirectory>/ews</outputDirectory>