ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [4/5] git commit: ARGUS-5: audit test code/config updated to enable testing with HDFS audit store.
Date Tue, 23 Sep 2014 18:33:31 GMT
ARGUS-5: audit test code/config updated to enable testing with HDFS
audit store.

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

Branch: refs/heads/master
Commit: b6efd47136bf449ce12966af9cd2e9b398cf6415
Parents: 7201bf8
Author: mneethiraj <mneethiraj@hortonworks.com>
Authored: Tue Sep 23 11:12:35 2014 -0700
Committer: mneethiraj <mneethiraj@hortonworks.com>
Committed: Tue Sep 23 11:12:35 2014 -0700

----------------------------------------------------------------------
 .../audit/provider/hdfs/HdfsAuditProvider.java  | 17 -------------
 .../com/xasecure/audit/test/TestEvents.java     | 26 ++++++++++++++++----
 lookup-client/src/scripts/log4j.xml             |  1 +
 lookup-client/src/scripts/run-audit-test.sh     |  9 +++++--
 .../src/scripts/xasecure-audit.properties       |  5 ++++
 5 files changed, 34 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b6efd471/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsAuditProvider.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsAuditProvider.java
index 6ab78ea..3f3132c 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsAuditProvider.java
@@ -49,21 +49,4 @@ public class HdfsAuditProvider extends BufferedAuditProvider {
 		
 		setBufferAndDestination(mLocalFileBuffer, mHdfsDestination);
 	}
-
-	@Override
-	public void waitToComplete() {
-		while(getBuffer() != null && !getBuffer().isEmpty()) {
-			sleep(1000);
-		}
-	}
-	
-	private static void sleep(int timeInMs) {
-		try {
-			Thread.sleep(timeInMs);
-		} catch(InterruptedException excp) {
-			
-		}
-	}
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b6efd471/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java b/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
index dd7e035..8968093 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
@@ -28,7 +28,6 @@ import java.util.Date;
 import java.util.Properties;
 
 import com.xasecure.audit.model.AuditEventBase;
-import com.xasecure.audit.model.EnumRepositoryType;
 import com.xasecure.audit.model.HBaseAuditEvent;
 import com.xasecure.audit.model.HdfsAuditEvent;
 import com.xasecure.audit.model.HiveAuditEvent;
@@ -83,9 +82,13 @@ public class TestEvents {
 
         	LOG.info("provider=" + provider.toString());
 
-        	String strEventCount = args.length > 0 ? args[0] : auditProperties.getProperty("xasecure.audit.test.event.count");
+        	String strEventCount          = args.length > 0 ? args[0] : auditProperties.getProperty("xasecure.audit.test.event.count");
+        	String strEventPauseTimeInMs  = args.length > 1 ? args[1] : auditProperties.getProperty("xasecure.audit.test.event.pause.time.ms");
+        	String strSleepTimeBeforeExit = args.length > 2 ? args[2] : auditProperties.getProperty("xasecure.audit.test.sleep.time.before.exit.seconds");
 
-        	int eventCount = (strEventCount == null) ? 1024 : Integer.parseInt(strEventCount);
+        	int eventCount          = (strEventCount == null) ? 1024 : Integer.parseInt(strEventCount);
+        	int eventPauseTime      = (strEventPauseTimeInMs == null) ? 0 : Integer.parseInt(strEventPauseTimeInMs);
+        	int sleepTimeBeforeExit = ((strSleepTimeBeforeExit == null) ? 0 : Integer.parseInt(strSleepTimeBeforeExit))
* 1000;
 
         	for(int i = 0; i < eventCount; i++) {
         		AuditEventBase event = getTestEvent(i);
@@ -93,11 +96,24 @@ public class TestEvents {
 	            LOG.info("==> TestEvents.main(" + (i+1) + "): adding " + event.getClass().getName());
         		provider.log(event);
 
-                if(i != 0 && ((i % 100) == 0))
-                    Thread.sleep(100);
+        		if(eventPauseTime > 0) {
+        			Thread.sleep(eventPauseTime);
+        		}
         	}
 
             provider.waitToComplete();
+            
+            // incase of HdfsAuditProvider, logs are saved to local file system which gets
sent to HDFS asynchronusly in a separate thread.
+            // So, at this point it is possible that few local log files haven't made to
HDFS.
+            if(sleepTimeBeforeExit > 0) {
+            	LOG.info("waiting for " + sleepTimeBeforeExit + "ms before exiting..");
+
+            	try {
+	                Thread.sleep(sleepTimeBeforeExit);
+            	} catch(Exception excp) {
+                	LOG.info("error while waiting before exiting..");
+            	}
+            }
 
             provider.stop();
         } catch(Exception excp) {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b6efd471/lookup-client/src/scripts/log4j.xml
----------------------------------------------------------------------
diff --git a/lookup-client/src/scripts/log4j.xml b/lookup-client/src/scripts/log4j.xml
index 20bb2db..f31717d 100644
--- a/lookup-client/src/scripts/log4j.xml
+++ b/lookup-client/src/scripts/log4j.xml
@@ -20,6 +20,7 @@
 
   <root> 
     <priority value ="info" /> 
+    <appender-ref ref="console" /> 
     <appender-ref ref="logFile" /> 
   </root>
   

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b6efd471/lookup-client/src/scripts/run-audit-test.sh
----------------------------------------------------------------------
diff --git a/lookup-client/src/scripts/run-audit-test.sh b/lookup-client/src/scripts/run-audit-test.sh
index d1a944f..693aa5c 100755
--- a/lookup-client/src/scripts/run-audit-test.sh
+++ b/lookup-client/src/scripts/run-audit-test.sh
@@ -1,9 +1,14 @@
 #!/bin/bash
 
-HADOOP_DIR=/usr/lib/hadoop
+HADOOP_DIR=/usr/hdp/current/hadoop
 HADOOP_CONF_DIR=/etc/hadoop/conf
 
-cp="$HADOOP_CONF_DIR:$HADOOP_DIR/lib/*:$HADOOP_DIR/client/hadoop-common.jar"
+cp=
+for jar in $HADOOP_CONF_DIR $HADOOP_DIR/lib/* $HADOOP_DIR/client/*
+do
+  cp=${cp}:${jar}
+done
+
 export cp
 
 java -Xmx1024M -Xms1024M -cp "${cp}" com.xasecure.audit.test.TestEvents $*

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b6efd471/lookup-client/src/scripts/xasecure-audit.properties
----------------------------------------------------------------------
diff --git a/lookup-client/src/scripts/xasecure-audit.properties b/lookup-client/src/scripts/xasecure-audit.properties
index 904b19c..2b755f1 100644
--- a/lookup-client/src/scripts/xasecure-audit.properties
+++ b/lookup-client/src/scripts/xasecure-audit.properties
@@ -1,3 +1,8 @@
+xasecure.audit.test.event.count=1000
+xasecure.audit.test.event.pause.time.ms=100
+xasecure.audit.test.sleep.time.before.exit.seconds=60
+
+
 xasecure.audit.is.enabled=true
 
 


Mime
View raw message