ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [1/2] incubator-ranger git commit: RANGER-753: Optimized tag-download implementation. Instrumented policy download and policy evaluation for performance measurement.
Date Wed, 02 Dec 2015 05:14:42 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master 68ab77b29 -> 7a80c8e35


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/7a80c8e3/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
index d92fd41..7d41f07 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
@@ -168,11 +168,10 @@ public class ServiceREST {
 		RangerServiceDef ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.createServiceDef(serviceDefName="
+ serviceDef.getName() + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.createServiceDef(serviceDefName="
+ serviceDef.getName() + ")");
+			}
 			RangerServiceDefValidator validator = validatorFactory.getServiceDefValidator(svcStore);
 			validator.validate(serviceDef, Action.CREATE);
 
@@ -209,11 +208,10 @@ public class ServiceREST {
 		RangerServiceDef ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updateServiceDef(" + serviceDef.getName()
+ ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updateServiceDef(" + serviceDef.getName()
+ ")");
+			}
 			RangerServiceDefValidator validator = validatorFactory.getServiceDefValidator(svcStore);
 			validator.validate(serviceDef, Action.UPDATE);
 
@@ -249,11 +247,10 @@ public class ServiceREST {
 
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.deleteServiceDef(serviceDefId="
+ id + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.deleteServiceDef(serviceDefId="
+ id + ")");
+			}
 			RangerServiceDefValidator validator = validatorFactory.getServiceDefValidator(svcStore);
 			validator.validate(id, Action.DELETE);
 
@@ -295,11 +292,10 @@ public class ServiceREST {
 		RangerServiceDef ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDef(serviceDefId="
+ id + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDef(serviceDefId="
+ id + ")");
+			}
 			XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(id);
 			if (!bizUtil.hasAccess(xServiceDef, null)) {
 				throw restErrorUtil.createRESTException(
@@ -341,11 +337,10 @@ public class ServiceREST {
 		RangerServiceDef ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDefByName(", name,
")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDefByName(" +
name + ")");
+			}
 			XXServiceDef xServiceDef = daoManager.getXXServiceDef().findByName(name);
 			if (xServiceDef != null) {
 				if (!bizUtil.hasAccess(xServiceDef, null)) {
@@ -389,15 +384,14 @@ public class ServiceREST {
 		RangerServiceDefList ret  = null;
 		RangerPerfTracer     perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDefs()");
-		}
-
 		PList<RangerServiceDef> paginatedSvcDefs = null;
 
 		SearchFilter filter = searchUtil.getSearchFilter(request, serviceDefService.sortFields);
 
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServiceDefs()");
+			}
 			paginatedSvcDefs = svcStore.getPaginatedServiceDefs(filter);
 
 			if(paginatedSvcDefs != null) {
@@ -439,11 +433,10 @@ public class ServiceREST {
 		RangerService    ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.createService(serviceName="
+ service.getName() + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.createService(serviceName="
+ service.getName() + ")");
+			}
 			RangerServiceValidator validator = validatorFactory.getServiceValidator(svcStore);
 			validator.validate(service, Action.CREATE);
 
@@ -485,11 +478,10 @@ public class ServiceREST {
 		RangerService    ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updateService(serviceName="
+ service.getName() + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updateService(serviceName="
+ service.getName() + ")");
+			}
 			RangerServiceValidator validator = validatorFactory.getServiceValidator(svcStore);
 			validator.validate(service, Action.UPDATE);
 
@@ -530,11 +522,10 @@ public class ServiceREST {
 
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.deleteService(serviceId="
+ id + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.deleteService(serviceId="
+ id + ")");
+			}
 			RangerServiceValidator validator = validatorFactory.getServiceValidator(svcStore);
 			validator.validate(id, Action.DELETE);
 
@@ -575,11 +566,10 @@ public class ServiceREST {
 		RangerService    ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getService(serviceId=" +
id + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getService(serviceId=" +
id + ")");
+			}
 			ret = svcStore.getService(id);
 		} catch(WebApplicationException excp) {
 			throw excp;
@@ -614,11 +604,10 @@ public class ServiceREST {
 		RangerService    ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getService(serviceName="
+ name + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getService(serviceName="
+ name + ")");
+			}
 			ret = svcStore.getServiceByName(name);
 		} catch(WebApplicationException excp) {
 			throw excp;
@@ -653,15 +642,14 @@ public class ServiceREST {
 		RangerServiceList ret  = null;
 		RangerPerfTracer  perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()");
-		}
-
 		PList<RangerService> paginatedSvcs = null;
 
 		SearchFilter filter = searchUtil.getSearchFilter(request, svcService.sortFields);
 
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()");
+			}
 			paginatedSvcs = svcStore.getPaginatedServices(filter);
 
 			if(paginatedSvcs != null) {
@@ -699,11 +687,10 @@ public class ServiceREST {
 		List<RangerService> ret  = null;
 		RangerPerfTracer    perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServices()");
+			}
 			ret = svcStore.getServices(filter);
 		} catch(WebApplicationException excp) {
 			throw excp;
@@ -735,11 +722,10 @@ public class ServiceREST {
 		Long             ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.countService()");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.countService()");
+			}
 			List<RangerService> services = getServices(request).getServices();
 			
 			ret = new Long(services == null ? 0 : services.size());
@@ -772,11 +758,10 @@ public class ServiceREST {
 		VXResponse       ret  = new VXResponse();
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.validateConfig(serviceName="
+ service.getName() + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.validateConfig(serviceName="
+ service.getName() + ")");
+			}
 			ret = serviceMgr.validateConfig(service, svcStore);
 		} catch(WebApplicationException excp) {
 			throw excp;
@@ -807,11 +792,10 @@ public class ServiceREST {
 		List<String>     ret  = new ArrayList<String>();
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.lookupResource(serviceName="
+ serviceName + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.lookupResource(serviceName="
+ serviceName + ")");
+			}
 			ret = serviceMgr.lookupResource(serviceName,context, svcStore);
 		} catch(WebApplicationException excp) {
 			throw excp;
@@ -841,13 +825,13 @@ public class ServiceREST {
 		RESTResponse     ret  = new RESTResponse();
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.grantAccess(serviceName="
+ serviceName + ")");
-		}
-			
 		if (serviceUtil.isValidateHttpsAuthentication(serviceName, request)) {
 
 			try {
+				if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+					perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.grantAccess(serviceName="
+ serviceName + ")");
+				}
+
 				String               userName   = grantRequest.getGrantor();
 				Set<String>          userGroups = userMgr.getGroupsForUser(userName);
 				RangerAccessResource resource   = new RangerAccessResourceImpl(grantRequest.getResource());
@@ -1000,13 +984,13 @@ public class ServiceREST {
 		RESTResponse     ret  = new RESTResponse();
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.revokeAccess(serviceName="
+ serviceName + ")");
-		}
-
 		if (serviceUtil.isValidateHttpsAuthentication(serviceName,request)) {
 
 			try {
+				if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+					perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.revokeAccess(serviceName="
+ serviceName + ")");
+				}
+
 				String               userName     = revokeRequest.getGrantor();
 				Set<String>          userGroups   =  userMgr.getGroupsForUser(userName);
 				RangerAccessResource resource     = new RangerAccessResourceImpl(revokeRequest.getResource());
@@ -1104,11 +1088,10 @@ public class ServiceREST {
 		RangerPolicy     ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.createPolicy(policyName="
+ policy.getName() + ")");
-		}
-		
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.createPolicy(policyName="
+ policy.getName() + ")");
+			}
 			// this needs to happen before validator is called
 			// set name of policy if unspecified
 			if (StringUtils.isBlank(policy.getName())) { // use of isBlank over isEmpty is deliberate
as a blank string does not strike us as a particularly useful policy name!
@@ -1160,11 +1143,10 @@ public class ServiceREST {
 		RangerPolicy     ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updatePolicy(policyId=" +
policy.getId() + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.updatePolicy(policyId="
+ policy.getId() + ")");
+			}
 			RangerPolicyValidator validator = validatorFactory.getPolicyValidator(svcStore);
 			validator.validate(policy, Action.UPDATE, bizUtil.isAdmin());
 
@@ -1198,11 +1180,10 @@ public class ServiceREST {
 
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.deletePolicy(policyId=" +
id + ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.deletePolicy(policyId="
+ id + ")");
+			}
 			RangerPolicyValidator validator = validatorFactory.getPolicyValidator(svcStore);
 			validator.validate(id, Action.DELETE);
 
@@ -1237,11 +1218,10 @@ public class ServiceREST {
 		RangerPolicy     ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getPolicy(policyId=" + id
+ ")");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getPolicy(policyId=" + id
+ ")");
+			}
 			ret = svcStore.getPolicy(id);
 
 			if(ret != null) {
@@ -1279,15 +1259,14 @@ public class ServiceREST {
 		RangerPolicyList ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getPolicies()");
-		}
-
 		PList<RangerPolicy> paginatedPolicies = null;
 
 		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
 
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getPolicies()");
+			}
 			paginatedPolicies = svcStore.getPaginatedPolicies(filter);
 
 			if(paginatedPolicies != null) {
@@ -1327,11 +1306,10 @@ public class ServiceREST {
 		List<RangerPolicy> ret  = null;
 		RangerPerfTracer   perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getPolicies()");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getPolicies()");
+			}
 			ret = svcStore.getPolicies(filter);
 
 			applyAdminAccessFilter(ret);
@@ -1363,11 +1341,10 @@ public class ServiceREST {
 		Long             ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.countPolicies()");
-		}
-
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.countPolicies()");
+			}
 			List<RangerPolicy> policies = getPolicies(request).getPolicies();
 
 			applyAdminAccessFilter(policies);
@@ -1402,15 +1379,14 @@ public class ServiceREST {
 		RangerPolicyList ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServicePolicies(serviceId="
+ serviceId + ")");
-		}
-
 		PList<RangerPolicy> paginatedPolicies = null;
 
 		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
 
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServicePolicies(serviceId="
+ serviceId + ")");
+			}
 			paginatedPolicies = svcStore.getPaginatedServicePolicies(serviceId, filter);
 
 			if(paginatedPolicies != null) {
@@ -1459,15 +1435,14 @@ public class ServiceREST {
 		RangerPolicyList ret  = null;
 		RangerPerfTracer perf = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServicePolicies(serviceName="
+ serviceName + ")");
-		}
-
 		PList<RangerPolicy> paginatedPolicies = null;
 
 		SearchFilter filter = searchUtil.getSearchFilter(request, policyService.sortFields);
 
 		try {
+			if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+				perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServicePolicies(serviceName="
+ serviceName + ")");
+			}
 			paginatedPolicies = svcStore.getPaginatedServicePolicies(serviceName, filter);
 
 			if(paginatedPolicies != null) {
@@ -1518,16 +1493,15 @@ public class ServiceREST {
 		String          logMsg   = null;
 		RangerPerfTracer perf    = null;
 
-		if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
-			perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServicePoliciesIfUpdated(serviceName="
+ serviceName + ", lastKnownVersion=" + lastKnownVersion + ")");
-		}
-
 		if (serviceUtil.isValidateHttpsAuthentication(serviceName, request)) {
 			if(lastKnownVersion == null) {
 				lastKnownVersion = new Long(-1);
 			}
 			
 			try {
+				if(RangerPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
+					perf = RangerPerfTracer.getPerfTracer(PERF_LOG, "ServiceREST.getServicePoliciesIfUpdated(serviceName="
+ serviceName + ",lastKnownVersion=" + lastKnownVersion + ")");
+				}
 				ret = svcStore.getServicePoliciesIfUpdated(serviceName, lastKnownVersion);
 	
 				if(ret == null) {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/7a80c8e3/security-admin/src/main/java/org/apache/ranger/rest/ServiceTagsProcessor.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/ServiceTagsProcessor.java
b/security-admin/src/main/java/org/apache/ranger/rest/ServiceTagsProcessor.java
index b1986be..1dcc242 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/ServiceTagsProcessor.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/ServiceTagsProcessor.java
@@ -412,32 +412,9 @@ public class ServiceTagsProcessor {
 
 		// TODO:
 		// This is an inefficient implementation. Replace by direct database deletes
+		boolean isResourePrivateTag = StringUtils.equals(serviceTags.getTagModel(), ServiceTags.TAGMODEL_RESOURCE_PRIVATE)
? true : false;
 
-		SearchFilter searchAll = new SearchFilter();
-
-		List<RangerTagResourceMap> allTagResourceMaps = tagStore.getTagResourceMaps(searchAll);
-		for (RangerTagResourceMap tagResourceMap : allTagResourceMaps) {
-			tagStore.deleteTagResourceMap(tagResourceMap.getId());
-		}
-
-		List<RangerServiceResource> allServiceResources = tagStore.getServiceResources(searchAll);
-		for (RangerServiceResource serviceResource : allServiceResources) {
-			tagStore.deleteServiceResource(serviceResource.getId());
-		}
-
-		List<RangerTag> allTags = tagStore.getTags(searchAll);
-		for (RangerTag tag : allTags) {
-			tagStore.deleteTag(tag.getId());
-		}
-
-		List<RangerTagDef> allTagDefs = tagStore.getTagDefs(searchAll);
-		for (RangerTagDef tagDef : allTagDefs) {
-			tagStore.deleteTagDef(tagDef.getId());
-		}
-
-		if (LOG.isDebugEnabled()) {
-			LOG.debug("ServiceTagsProcessor.replace() : All tag-related objects are removed now. Adding
objects specified in ServiceTags..");
-		}
+		tagStore.deleteAllTagObjectsForService(serviceTags.getServiceName(), isResourePrivateTag);
 
 		addOrUpdate(serviceTags);
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/7a80c8e3/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
----------------------------------------------------------------------
diff --git a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
index 4719fc9..ac1c87a 100644
--- a/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
+++ b/security-admin/src/main/resources/META-INF/jpa_named_queries.xml
@@ -664,9 +664,18 @@
 	<!-- Start ==> JPA Queries for Tag Based Policies  -->
 	
 	<named-query name="XXServiceResourceElement.findByResourceId">
-		<query>select obj from XXServiceResourceElement obj where obj.resourceId = :resourceId</query>
+		<query>select obj from XXServiceResourceElement obj where obj.resourceId = :resourceId
order by obj.resourceId, obj.id</query>
 	</named-query>
-	
+
+	<named-query name="XXServiceResourceElement.findByServiceId">
+		<query>select obj from XXServiceResourceElement obj where obj.resourceId in
+					(select serviceresource.id from XXServiceResource serviceresource where serviceresource.serviceId
= :serviceId and serviceresource.id in
+						(select tagResMap.resourceId from XXTagResourceMap tagResMap)
+					)
+			order by obj.resourceId, obj.id
+		</query>
+	</named-query>
+
 	<named-query name="XXServiceResourceElementValue.findByResElementId">
 		<query>select obj from XXServiceResourceElementValue obj where obj.resElementId =
:resElementId</query>
 	</named-query>
@@ -675,6 +684,21 @@
 		<query>select obj.value from XXServiceResourceElementValue obj where obj.resElementId
= :resElementId</query>
 	</named-query>
 
+	<named-query name="XXServiceResourceElementValue.findByServiceId">
+		<query>select obj from XXServiceResourceElementValue obj, XXServiceResourceElement
resElem where obj.resElementId = resElem.id and resElem.resourceId in
+					(select res.id from XXServiceResource res where res.serviceId = :serviceId and res.id
in
+						(select tagResMap.resourceId from XXTagResourceMap tagResMap)
+					)
+			order by resElem.resourceId, resElem.id
+		</query>
+	</named-query>
+
+	<named-query name="XXServiceResourceElementValue.findByResourceId">
+		<query>select obj from XXServiceResourceElementValue obj, XXServiceResourceElement
resElem where obj.resElementId = resElem.id and resElem.resourceId = :resourceId
+			order by resElem.resourceId, resElem.id
+		</query>
+	</named-query>
+
 	<named-query name="XXTagResourceMap.findByGuid">
 		<query>select obj from XXTagResourceMap obj where obj.guid = :guid</query>
 	</named-query>
@@ -711,7 +735,7 @@
 
 	<named-query name="XXTagResourceMap.getTagIdsForResourceId">
 		<query>select obj.tagId from XXTagResourceMap obj
-				where obj.resourceId = :resourceId
+				where obj.resourceId = :resourceId order by obj.id
 		</query>
 	</named-query>
 	
@@ -725,7 +749,16 @@
 	
 	<named-query name="XXTagDef.findByServiceId">
 		<query>select obj from XXTagDef obj where obj.id in
-				(select tag.type from XXTag tag, XXTagResourceMap tagRes, XXServiceResource resource
where tag.id = tagRes.tagId and tagRes.resourceId = resource.id and resource.serviceId = :serviceId)</query>
+				(select tag.type from XXTag tag, XXTagResourceMap tagRes, XXServiceResource resource
where tag.id = tagRes.tagId and tagRes.resourceId = resource.id and resource.serviceId = :serviceId)
+				order by obj.id
+		</query>
+	</named-query>
+
+	<named-query name="XXTagDef.findByResourceId">
+		<query>select obj from XXTagDef obj where obj.id in
+			(select tag.type from XXTag tag, XXTagResourceMap tagRes where tag.id = tagRes.tagId and
tagRes.resourceId = :resourceId)
+			order by obj.id
+		</query>
 	</named-query>
 
 	<named-query name="XXTagDef.getAllNames">
@@ -742,9 +775,22 @@
 		<query>select obj from XXTagAttributeDef obj where obj.tagDefId = :tagDefId</query>
 	</named-query>
 
-	
+	<named-query name="XXTagAttributeDef.findByServiceId">
+		<query>select obj from XXTagAttributeDef obj where obj.tagDefId in
+			(select tag.type from XXTag tag, XXTagResourceMap tagRes, XXServiceResource resource where
tag.id = tagRes.tagId and tagRes.resourceId = resource.id and resource.serviceId = :serviceId)
+			order by obj.tagDefId
+		</query>
+	</named-query>
+
+	<named-query name="XXTagAttributeDef.findByResourceId">
+		<query>select obj from XXTagAttributeDef obj where obj.tagDefId in
+			(select tag.type from XXTag tag, XXTagResourceMap tagRes where tag.id = tagRes.tagId and
tagRes.resourceId = :resourceId)
+			order by obj.tagDefId
+		</query>
+	</named-query>
+
 	<named-query name="XXTag.findByGuid">
-		<query>select obj from XXTag obj where obj.guid = :guid</query>
+		<query>select obj from XXTag obj where obj.guid = :guid order by obj.id</query>
 	</named-query>
 	
 	<named-query name="XXTag.findByName">
@@ -752,7 +798,7 @@
 	</named-query>
 
 	<named-query name="XXTag.findByResourceId">
-		<query>select obj from XXTag obj, XXTagResourceMap tagResMap where tagResMap.resourceId
= :resourceId and obj.id = tagResMap.tagId</query>
+		<query>select obj from XXTag obj, XXTagResourceMap tagResMap where tagResMap.resourceId
= :resourceId and obj.id = tagResMap.tagId order by obj.id</query>
 	</named-query>
 
 	<named-query name="XXTag.findByResourceGuid">
@@ -766,7 +812,9 @@
 	
 	<named-query name="XXTag.findByServiceId">
 		<query>select obj from XXTag obj where obj.id in
-			(select tagRes.tagId from XXTagResourceMap tagRes, XXServiceResource resource where tagRes.resourceId
= resource.id and resource.serviceId = :serviceId)</query>
+			(select tagRes.tagId from XXTagResourceMap tagRes, XXServiceResource resource where tagRes.resourceId
= resource.id and resource.serviceId = :serviceId)
+			order by obj.id
+		</query>
 	</named-query>
 
 	<named-query name="XXTag.updateTagVersionInService">
@@ -779,6 +827,19 @@
 		<query>select obj from XXTagAttribute obj where obj.tagId = :tagId</query>
 	</named-query>
 
+	<named-query name="XXTagAttribute.findByServiceId">
+		<query>select obj from XXTagAttribute obj where obj.tagId in
+			(select tagRes.tagId from XXTagResourceMap tagRes, XXServiceResource resource where tagRes.resourceId
= resource.id and resource.serviceId = :serviceId)
+			order by obj.tagId
+		</query>
+	</named-query>
+
+	<named-query name="XXTagAttribute.findByResourceId">
+		<query>select obj from XXTagAttribute obj where obj.tagId in
+			(select tagRes.tagId from XXTagResourceMap tagRes where tagRes.resourceId = :resourceId)
+			order by obj.tagId
+		</query>
+	</named-query>
 
 	<named-query name="XXServiceResource.findByGuid">
 		<query>select obj from XXServiceResource obj where obj.guid = :guid</query>

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/7a80c8e3/security-admin/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/security-admin/src/test/resources/log4j.properties b/security-admin/src/test/resources/log4j.properties
deleted file mode 100644
index cb409e8..0000000
--- a/security-admin/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-##-- To prevent junits from cluttering the build run by default all test runs send output
to null appender 
-log4j.appender.devnull=org.apache.log4j.varia.NullAppender
-ranger.root.logger=FATAL,devnull
-
-##-- uncomment the following line during during development/debugging so see debug messages
during test run to be emitted to console
-# ranger.root.logger=DEBUG,console
-
-log4j.rootLogger=${ranger.root.logger}
-
-# Logging Threshold
-log4j.threshold=ALL
-
-#
-# console
-# Add "console" to rootlogger above if you want to use this
-#
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.target=System.err
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/7a80c8e3/security-admin/src/test/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/security-admin/src/test/resources/log4j.xml b/security-admin/src/test/resources/log4j.xml
new file mode 100644
index 0000000..48ed214
--- /dev/null
+++ b/security-admin/src/test/resources/log4j.xml
@@ -0,0 +1,53 @@
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+    <appender name="console" class="org.apache.log4j.ConsoleAppender">
+        <param name="target" value="System.err" />
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{ISO8601} %-5p [%t] %c{2}: %m%n"
/>
+        </layout>
+    </appender>
+
+    <!--
+    <appender name="perf_appender" class="org.apache.log4j.DailyRollingFileAppender">
+        <param name="file" value="./ranger_admin_perf_test.log" />
+        <param name="datePattern" value="'.'yyyy-MM-dd" />
+        <param name="append" value="true" />
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d [%t] %m%n" />
+        </layout>
+    </appender>
+
+    <category name="ranger.perf" additivity="false">
+        <priority value="info" />
+        <appender-ref ref="perf_appender" />
+    </category>
+
+    <category name="ranger.perf.policy" additivity="false">
+        <priority value="warn" />
+        <appender-ref ref="perf_appender" />
+    </category>
+
+    <category name="ranger.perf.item" additivity="false">
+        <priority value="warn" />
+        <appender-ref ref="perf_appender" />
+    </category>
+
+    <category name="ranger.perf.condition" additivity="false">
+        <priority value="warn" />
+        <appender-ref ref="perf_appender" />
+    </category>
+
+    <category name="ranger.perf.enricher" additivity="false">
+        <priority value="warn" />
+        <appender-ref ref="perf_appender" />
+    </category>
+    -->
+
+    <root>
+        <priority value="warn" />
+        <appender-ref ref="console" />
+    </root>
+
+</log4j:configuration>


Mime
View raw message