ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [2/9] incubator-ranger git commit: RANGER-1107: Performance trace to measure policy download performance in plugins
Date Thu, 15 Sep 2016 19:52:06 GMT
RANGER-1107: Performance trace to measure policy download performance in plugins

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit 3c8b40fcf317235bc5597b4d6ffe535c7a5baa34)


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

Branch: refs/heads/ranger-0.6
Commit: caba857008b3e0087a276fc2030e13f951cde624
Parents: b323f90
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Thu Jul 14 17:17:58 2016 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Thu Sep 15 12:19:02 2016 -0700

----------------------------------------------------------------------
 .../policyengine/RangerPolicyEngineImpl.java    |   9 +
 .../ranger/plugin/util/PolicyRefresher.java     |  37 ++-
 ranger-tools/conf/log4j.properties              |   2 +-
 ranger-tools/scripts/README.txt                 |  13 +
 .../scripts/ranger-plugin-perftester.sh         |  32 +++
 .../policyengine/RangerPluginPerfTester.java    | 259 +++++++++++++++++++
 .../RangerPolicyenginePerfTester.java           |  34 ++-
 .../src/main/webapp/WEB-INF/log4j.xml           |   2 +-
 src/main/assembly/ranger-tools.xml              |   7 +
 9 files changed, 387 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
index 707b8a5..8d3deb6 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java
@@ -63,6 +63,9 @@ public class RangerPolicyEngineImpl implements RangerPolicyEngine {
 
 		if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) {
 			perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "RangerPolicyEngine.init(appId="
+ appId + ",hashCode=" + Integer.toHexString(System.identityHashCode(this)) + ")");
+			long freeMemory = Runtime.getRuntime().freeMemory();
+			long totalMemory = Runtime.getRuntime().totalMemory();
+			PERF_POLICYENGINE_INIT_LOG.debug("In-Use memory: " + (totalMemory - freeMemory) + ", Free
memory:" + freeMemory);
 		}
 
 		if (options == null) {
@@ -131,6 +134,12 @@ public class RangerPolicyEngineImpl implements RangerPolicyEngine {
 
 		RangerPerfTracer.log(perf);
 
+		if (PERF_POLICYENGINE_INIT_LOG.isDebugEnabled()) {
+			long freeMemory = Runtime.getRuntime().freeMemory();
+			long totalMemory = Runtime.getRuntime().totalMemory();
+			PERF_POLICYENGINE_INIT_LOG.debug("In-Use memory: " + (totalMemory - freeMemory) + ", Free
memory:" + freeMemory);
+		}
+
 		if (LOG.isDebugEnabled()) {
 			LOG.debug("<== RangerPolicyEngineImpl()");
 		}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
b/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
index f865a2a..38e05d9 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
@@ -179,6 +179,9 @@ public class PolicyRefresher extends Thread {
 
 		if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) {
 			perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "PolicyRefresher.loadPolicy(serviceName="
+ serviceName + ")");
+			long freeMemory = Runtime.getRuntime().freeMemory();
+			long totalMemory = Runtime.getRuntime().totalMemory();
+			PERF_POLICYENGINE_INIT_LOG.debug("In-Use memory: " + (totalMemory-freeMemory) + ", Free
memory:" + freeMemory);
 		}
 
 		//load policy from PolicyAdmin
@@ -195,6 +198,12 @@ public class PolicyRefresher extends Thread {
 
 		RangerPerfTracer.log(perf);
 
+		if (PERF_POLICYENGINE_INIT_LOG.isDebugEnabled()) {
+			long freeMemory = Runtime.getRuntime().freeMemory();
+			long totalMemory = Runtime.getRuntime().totalMemory();
+			PERF_POLICYENGINE_INIT_LOG.debug("In-Use memory: " + (totalMemory-freeMemory) + ", Free
memory:" + freeMemory);
+		}
+
 		if (svcPolicies != null) {
 			plugIn.setPolicies(svcPolicies);
 			policiesSetInPlugin = true;
@@ -213,6 +222,12 @@ public class PolicyRefresher extends Thread {
 
 		ServicePolicies svcPolicies = null;
 
+		RangerPerfTracer perf = null;
+
+		if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) {
+			perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "PolicyRefresher.loadPolicyFromPolicyAdmin(serviceName="
+ serviceName + ")");
+		}
+
 		try {
 			svcPolicies = rangerAdmin.getServicePoliciesIfUpdated(lastKnownVersion);
 
@@ -240,7 +255,9 @@ public class PolicyRefresher extends Thread {
    			LOG.error("PolicyRefresher(serviceName=" + serviceName + "): failed to refresh policies.
Will continue to use last known version of policies (" + lastKnownVersion + ")", excp);
    		 }
 
-		 if(LOG.isDebugEnabled()) {
+		RangerPerfTracer.log(perf);
+
+		if(LOG.isDebugEnabled()) {
 			LOG.debug("<== PolicyRefresher(serviceName=" + serviceName + ").loadPolicyfromPolicyAdmin()");
 		 }
 
@@ -261,6 +278,12 @@ public class PolicyRefresher extends Thread {
     	if(cacheFile != null && cacheFile.isFile() && cacheFile.canRead()) {
     		Reader reader = null;
 
+    		RangerPerfTracer perf = null;
+
+    		if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) {
+    			perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "PolicyRefresher.loadFromCache(serviceName="
+ serviceName + ")");
+    		}
+
     		try {
 	        	reader = new FileReader(cacheFile);
 
@@ -278,6 +301,8 @@ public class PolicyRefresher extends Thread {
 	        } catch (Exception excp) {
 	        	LOG.error("failed to load policies from cache file " + cacheFile.getAbsolutePath(),
excp);
 	        } finally {
+	        	RangerPerfTracer.log(perf);
+
 	        	if(reader != null) {
 	        		try {
 	        			reader.close();
@@ -320,6 +345,13 @@ public class PolicyRefresher extends Thread {
 			}
 			
 	    	if(cacheFile != null) {
+
+				RangerPerfTracer perf = null;
+
+				if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) {
+					perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "PolicyRefresher.saveToCache(serviceName="
+ serviceName + ")");
+				}
+
 				Writer writer = null;
 	
 				try {
@@ -337,6 +369,9 @@ public class PolicyRefresher extends Thread {
 		        		}
 		        	}
 		        }
+
+				RangerPerfTracer.log(perf);
+
 	    	}
 		} else {
 			LOG.info("policies is null. Nothing to save in cache");

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/ranger-tools/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/ranger-tools/conf/log4j.properties b/ranger-tools/conf/log4j.properties
index 21f7fad..4ead802 100644
--- a/ranger-tools/conf/log4j.properties
+++ b/ranger-tools/conf/log4j.properties
@@ -23,7 +23,7 @@ log4j.threshold=ALL
 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=%m%n
+log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n
 
 #
 # ranger.perf log level

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/ranger-tools/scripts/README.txt
----------------------------------------------------------------------
diff --git a/ranger-tools/scripts/README.txt b/ranger-tools/scripts/README.txt
index 7dc84e9..55170d5 100644
--- a/ranger-tools/scripts/README.txt
+++ b/ranger-tools/scripts/README.txt
@@ -67,3 +67,16 @@ This file describes how to build, setup, configure and run the performance
testi
 
 [RangerPolicyEngine.isAccessAllowed] execCount:64, totalTimeTaken:1873, maxTimeTaken:276,
minTimeTaken:4, avgTimeTaken:29
 
+
+RangerPluginPerfTester tool
+
+Steps 1 - 4 as above..
+
+Run the tool with
+
+	% ./ranger-plugin-perftester.sh -s <service-type>  -n <service-name> -a <app-id>
-r <ranger-admin-host> -t <socket-read-timeout-in-milliseconds> -p <policy-download-interval-in-milliseconds>
-c <local-policy-cache-dir> -e <policy-evaluator-type>
+
+	Example:
+	% ./ranger-plugin-perftester.sh -s hive -n cl1_hive -a test_hive_plugin -r http://ranger_admin_host
-t 30000 -p 30000 -c /tmp/hive/policycache -e nocache
+
+

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/ranger-tools/scripts/ranger-plugin-perftester.sh
----------------------------------------------------------------------
diff --git a/ranger-tools/scripts/ranger-plugin-perftester.sh b/ranger-tools/scripts/ranger-plugin-perftester.sh
new file mode 100755
index 0000000..eae2fdf
--- /dev/null
+++ b/ranger-tools/scripts/ranger-plugin-perftester.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+# 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.
+
+cdir=$(cd "$(dirname "$0")"; pwd)
+cp="${cdir}/dist/*:${cdir}/lib/*:${cdir}/conf:."
+
+if [ "${JAVA_HOME}" != "" ]
+then
+	export JAVA_HOME
+	PATH="${JAVA_HOME}/bin:${PATH}"
+	export PATH
+fi
+
+JAVA_CMD="java -cp ${cp} org.apache.ranger.policyengine.RangerPluginPerfTester"
+
+cd ${cdir}
+
+echo "JAVA command = $JAVA_CMD " "$@"
+$JAVA_CMD "$@"

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPluginPerfTester.java
----------------------------------------------------------------------
diff --git a/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPluginPerfTester.java
b/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPluginPerfTester.java
new file mode 100644
index 0000000..803d737
--- /dev/null
+++ b/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPluginPerfTester.java
@@ -0,0 +1,259 @@
+/*
+ * 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.
+ */
+
+package org.apache.ranger.policyengine;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.ranger.authorization.hadoop.config.RangerConfiguration;
+import org.apache.ranger.plugin.policyevaluator.RangerPolicyEvaluator;
+import org.apache.ranger.plugin.service.RangerBasePlugin;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.File;
+
+public class RangerPluginPerfTester {
+
+	static RangerBasePlugin plugin = null;
+
+	private static String serviceType;
+	private static String serviceName;
+	private static String appId;
+	private static String rangerHostName;
+	private static int socketReadTimeout = 30*1000;
+	private static int pollingInterval = 30*1000;
+	private static String policyCacheDir;
+	private static boolean useCachedPolicyEvaluator = false;
+
+	private static Options options = new Options();
+
+	public static void main(String[] args) {
+
+		if (!parseArguments(args)) {
+			System.err.println("Exiting.. ");
+			System.exit(-1);
+		}
+
+
+
+		System.out.println("Arguments:");
+		System.out.println("\t\tservice-type:\t\t\t" + serviceType);
+		System.out.println("\t\tservice-name:\t\t\t" + serviceName);
+		System.out.println("\t\tapp-id:\t\t\t\t" + appId);
+		System.out.println("\t\tranger-host:\t\t\t" + rangerHostName);
+		System.out.println("\t\tsocket-read-timeout:\t\t" + socketReadTimeout);
+		System.out.println("\t\tpolling-interval:\t\t" + pollingInterval);
+		System.out.println("\t\tpolicy-cache-dir:\t\t" + policyCacheDir);
+		System.out.println("\t\tuse-cached-policy-evaluator:\t" + useCachedPolicyEvaluator);
+		System.out.println("\n\n");
+
+
+		Path filePath = buildConfigurationFile();
+
+		if (filePath != null) {
+			RangerConfiguration rangerConfig = RangerConfiguration.getInstance();
+			rangerConfig.addResource(filePath);
+
+			plugin = new RangerBasePlugin(serviceType, appId);
+
+			Runtime runtime = Runtime.getRuntime();
+			runtime.gc();
+
+			long totalMemory = runtime.totalMemory();
+			long freeMemory = runtime.freeMemory();
+
+			System.out.println("Initial Memory Statistics:");
+			System.out.println("\t\tMaximum Memory available for the process:\t" + runtime.maxMemory());
+			System.out.println("\t\tInitial In-Use memory:\t\t\t\t" + (totalMemory-freeMemory));
+			System.out.println("\t\tInitial Free memory:\t\t\t\t" + freeMemory);
+
+			System.out.println("\n\n");
+
+			plugin.init();
+
+			while (true) {
+
+				runtime.gc();
+
+				freeMemory = runtime.freeMemory();
+				totalMemory = runtime.totalMemory();
+
+				System.out.println("Memory Statistics:");
+				System.out.println("\t\tCurrently In-Use memory:\t" + (totalMemory-freeMemory));
+				System.out.println("\t\tCurrently Free memory:\t\t" + freeMemory);
+
+				System.out.println("\n\n");
+
+				try {
+					Thread.sleep(60 * 1000);
+				} catch (InterruptedException e) {
+
+					System.err.println("Main thread interrupted..., exiting...");
+					break;
+				}
+			}
+		} else {
+			System.err.println("Failed to build configuration file");
+		}
+	}
+
+	static Path buildConfigurationFile() {
+
+		Path ret = null;
+
+		String propertyPrefix    = "ranger.plugin." + serviceType;
+		String policyEvaluatorType = useCachedPolicyEvaluator ? RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED
: RangerPolicyEvaluator.EVALUATOR_TYPE_OPTIMIZED;
+
+		try {
+
+			File file = File.createTempFile("ranger-plugin-test-site", ".xml") ;
+			file.deleteOnExit();
+
+			String filePathStr =  file.getAbsolutePath() ;
+
+			Path filePath = new Path(filePathStr);
+
+			FileSystem fs = filePath.getFileSystem(new Configuration());
+
+			FSDataOutputStream outStream = fs.create(filePath, true);
+
+			OutputStreamWriter writer = new OutputStreamWriter(outStream);
+
+			writer.write("<configuration>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".policy.pollIntervalMs</name>\n"
+
+					"                <value>" + pollingInterval + "</value>\n" +
+					"        </property>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".policy.cache.dir</name>\n"
+
+					"                <value>" + policyCacheDir + "</value>\n" +
+					"        </property>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".policy.rest.url</name>\n"
+
+					"                <value>" + rangerHostName + ":6080" + "</value>\n" +
+					"        </property>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".policy.source.impl</name>\n"
+
+					"                <value>org.apache.ranger.admin.client.RangerAdminRESTClient</value>\n"
+
+					"        </property>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".policy.rest.client.read.timeoutMs</name>\n"
+
+					"                <value>" + socketReadTimeout + "</value>\n" +
+					"        </property>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".policyengine.option.evaluator.type</name>\n"
+
+					"                <value>" + policyEvaluatorType + "</value>\n" +
+					"        </property>\n" +
+					"        <property>\n" +
+					"                <name>" + propertyPrefix + ".service.name</name>\n" +
+					"                <value>" + serviceName + "</value>\n" +
+					"        </property>\n" +
+
+					"        <property>\n" +
+					"                <name>xasecure.audit.is.enabled</name>\n" +
+					"                <value>false</value>\n" +
+					"        </property>\n" +
+					"</configuration>\n");
+
+			writer.close();
+			ret = filePath;
+
+		} catch (IOException exception) {
+			//Ignore
+		}
+
+		return ret;
+
+	}
+
+
+	static boolean parseArguments(final String[] args) {
+
+		boolean ret = false;
+
+		options.addOption("h", "help", false, "show help.");
+		options.addOption("s", "service-type", true, "Service-Type");
+		options.addOption("n", "service-name", true, "Ranger service-name ");
+		options.addOption("a", "app-id", true, "Application-Id");
+		options.addOption("r", "ranger-host", true, "Ranger host-name");
+		options.addOption("t", "socket-read-timeout", true, "Read timeout on socket in milliseconds");
+		options.addOption("p", "polling-interval", true, "Polling Interval in milliseconds");
+		options.addOption("c", "policy-cache-dir", true, "Policy-Cache directory ");
+		options.addOption("e", "policy-evaluator-type", true, "Policy-Evaluator-Type (Cached/Other");
+
+		DefaultParser commandLineParser = new DefaultParser();
+
+		try {
+			CommandLine commandLine = commandLineParser.parse(options, args);
+
+			if (commandLine.hasOption("h")) {
+				showUsage();
+				return false;
+			}
+
+			serviceType = commandLine.getOptionValue("s");
+			serviceName = commandLine.getOptionValue("n");
+			appId = commandLine.getOptionValue("a");
+			rangerHostName = commandLine.getOptionValue("r");
+			policyCacheDir = commandLine.getOptionValue("c");
+
+			try {
+				String pollingIntervalStr = commandLine.getOptionValue("p");
+				pollingInterval = Integer.parseInt(pollingIntervalStr);
+			} catch (NumberFormatException exception) {
+				// Ignore
+			}
+
+			String useCachedPolicyEvaluatorStr = commandLine.getOptionValue("e");
+			if (StringUtils.equalsIgnoreCase(useCachedPolicyEvaluatorStr, "cache")) {
+				useCachedPolicyEvaluator = true;
+			}
+
+			try {
+				String socketReadTimeoutStr = commandLine.getOptionValue("t");
+				socketReadTimeout = Integer.parseInt(socketReadTimeoutStr);
+			} catch (NumberFormatException exception) {
+				// Ignore
+			}
+
+			ret = true;
+
+		} catch (ParseException exception) {
+			System.err.println("Failed to parse arguments:" + exception);
+		}
+
+		return ret;
+	}
+
+    static void showUsage() {
+        HelpFormatter formater = new HelpFormatter();
+        formater.printHelp("plugin-tester", options);
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPolicyenginePerfTester.java
----------------------------------------------------------------------
diff --git a/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPolicyenginePerfTester.java
b/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPolicyenginePerfTester.java
index 42d7cde..e752c62 100644
--- a/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPolicyenginePerfTester.java
+++ b/ranger-tools/src/main/java/org/apache/ranger/policyengine/RangerPolicyenginePerfTester.java
@@ -83,6 +83,18 @@ public class RangerPolicyenginePerfTester {
                 LOG.debug("Number of perfTestClients=" + perfTestClients.size());
             }
 
+            Runtime runtime = Runtime.getRuntime();
+            runtime.gc();
+
+            long totalMemory = runtime.totalMemory();
+            long freeMemory = runtime.freeMemory();
+
+            LOG.info("Initial Memory Statistics:");
+            LOG.info("\t\tMaximum memory available for the process:\t" + runtime.maxMemory());
+            LOG.info("\t\tInitial In-Use memory:\t\t\t\t" + (totalMemory-freeMemory));
+            LOG.info("\t\tInitial Free memory:\t\t\t\t" + freeMemory);
+            LOG.info("\n\n");
+
             for (PerfTestClient client : perfTestClients) {
                 try {
                     client.start();
@@ -94,15 +106,27 @@ public class RangerPolicyenginePerfTester {
             LOG.info("Waiting for " + perfTestClients.size() + " clients to finish up");
 
             for (PerfTestClient client : perfTestClients) {
-                try {
-                    if (client.isAlive()) {
+                while (client.isAlive()) {
+                    try {
                         LOG.info("Waiting for " + client.getName() + " to finish up.");
-                        client.join();
+                        client.join(1000);
+
+                        runtime.gc();
+
+                        totalMemory = runtime.totalMemory();
+                        freeMemory = runtime.freeMemory();
+
+                        LOG.info("Memory Statistics:");
+                        LOG.info("\t\tCurrent In-Use memory:\t\t" + (totalMemory-freeMemory));
+                        LOG.info("\t\tCurrent Free memory:\t\t" + freeMemory);
+                        LOG.info("\n\n");
+
+                    } catch (InterruptedException interruptedException) {
+                        LOG.error("PerfTestClient.join() was interrupted");
                     }
-                } catch (InterruptedException interruptedException) {
-                    LOG.error("PerfTestClient.join() was interrupted");
                 }
             }
+
             if (LOG.isDebugEnabled()) {
                 LOG.debug("<== RangerPolicyenginePerfTester.main()");
             }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/security-admin/src/main/webapp/WEB-INF/log4j.xml
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/WEB-INF/log4j.xml b/security-admin/src/main/webapp/WEB-INF/log4j.xml
index 54abd06..359ed93 100644
--- a/security-admin/src/main/webapp/WEB-INF/log4j.xml
+++ b/security-admin/src/main/webapp/WEB-INF/log4j.xml
@@ -85,7 +85,7 @@
 
 	<!--
 	<category name="org.apache.ranger.perf" additivity="false">
-		<priority value="debug" />
+		<priority value="info" />
 		<appender-ref ref="perf_appender" />
 	</category>
 	-->

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/caba8570/src/main/assembly/ranger-tools.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/ranger-tools.xml b/src/main/assembly/ranger-tools.xml
index 0df339d..bcc9df9 100644
--- a/src/main/assembly/ranger-tools.xml
+++ b/src/main/assembly/ranger-tools.xml
@@ -39,6 +39,7 @@
                 <include>commons-lang:commons-lang</include>
                 <include>com.google.code.gson:gson</include>
                 <include>log4j:log4j</include>
+                <include>org.slf4j:slf4j-api:jar:${slf4j-api.version}</include>
                 <include>commons-configuration:commons-configuration:jar:${commons.configuration.version}</include>
                 <include>org.apache.hadoop:hadoop-common:jar:${hadoop-common.version}</include>
                 <include>org.apache.hadoop:hadoop-common-plus:jar:${hadoop-common.version}</include>
@@ -125,6 +126,12 @@
       <fileMode>755</fileMode>
     </file>
     <file>
+      <source>ranger-tools/scripts/ranger-plugin-perftester.sh</source>
+      <outputDirectory>/</outputDirectory>
+      <destName>ranger-plugin-perftester.sh</destName>
+      <fileMode>755</fileMode>
+    </file>
+    <file>
       <source>ranger-tools/scripts/README.txt</source>
       <outputDirectory>/</outputDirectory>
       <destName>README.txt</destName>


Mime
View raw message