ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [1/3] git commit: ARGUS-35: fix for the issue of knox and storm audit events being logged synchronously even if audit is configured for asynchronous logging.
Date Thu, 04 Sep 2014 23:56:20 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 933bae568 -> ea17097a2


ARGUS-35: fix for the issue of knox and storm audit events being logged
synchronously even if audit is configured for asynchronous logging.

This incorrect behaviour was due to missed override of 2 methods in
AsyncAuditProvider. Updated the AuditProvider interface to not require
such override in the hierarchy for addition of audit event types.





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

Branch: refs/heads/master
Commit: 914f0bae342ebdb0dab403d87272f84c9062cb35
Parents: 933bae5
Author: mneethiraj <mneethiraj@hortonworks.com>
Authored: Thu Sep 4 13:26:55 2014 -0700
Committer: mneethiraj <mneethiraj@hortonworks.com>
Committed: Thu Sep 4 13:26:55 2014 -0700

----------------------------------------------------------------------
 .../com/xasecure/audit/dao/DaoManagerBase.java  | 51 ++++++++++++--------
 .../xasecure/audit/model/AuditEventBase.java    |  4 +-
 .../xasecure/audit/model/HBaseAuditEvent.java   |  8 +--
 .../xasecure/audit/model/HdfsAuditEvent.java    |  8 +--
 .../xasecure/audit/model/HiveAuditEvent.java    |  8 +--
 .../xasecure/audit/model/KnoxAuditEvent.java    |  9 ++--
 .../xasecure/audit/model/StormAuditEvent.java   |  9 ++--
 .../audit/provider/AsyncAuditProvider.java      | 24 ++-------
 .../xasecure/audit/provider/AuditProvider.java  | 12 +----
 .../audit/provider/DbAuditProvider.java         | 46 ++----------------
 .../audit/provider/DummyAuditProvider.java      | 23 +--------
 .../audit/provider/Log4jAuditProvider.java      | 40 +--------------
 .../audit/provider/MultiDestAuditProvider.java  | 50 +++----------------
 .../com/xasecure/audit/test/TestEvents.java     | 38 +++++++--------
 lookup-client/src/scripts/run-audit-test.sh     | 10 ++--
 15 files changed, 98 insertions(+), 242 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/dao/DaoManagerBase.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/dao/DaoManagerBase.java b/agents-audit/src/main/java/com/xasecure/audit/dao/DaoManagerBase.java
index ddd8cfb..f1cfea8 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/dao/DaoManagerBase.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/dao/DaoManagerBase.java
@@ -27,45 +27,54 @@ public abstract class DaoManagerBase {
 	final static Logger logger = Logger.getLogger(DaoManagerBase.class);
 
 	abstract public EntityManager getEntityManager();
+	
+	private XAHBaseAuditEventDao mHBaseDao = null;
+	private XAHdfsAuditEventDao  mHdfsDao  = null;
+	private XAHiveAuditEventDao  mHiveDao  = null;
+	private XAKnoxAuditEventDao  mKnoxDao  = null;
+	private XAStormAuditEventDao mStormDao = null;
 
     public DaoManagerBase() {
 	}
 
-	public BaseDao<?> getDaoForClassName(String className) {
-		if (className.equals("XAHBaseAuditEvent")) {
-			return getXAHBaseAuditEvent();
-		} else if (className.equals("XAHdfsAuditEvent")) {
-			return getXAHdfsAuditEvent();
-		} else if (className.equals("XAHiveAuditEvent")) {
-			return getXAHiveAuditEvent();
-		} else if (className.equals("XAKnoxAuditEvent")) {
-			return getXAKnoxAuditEvent();
-		} else if (className.equals("XAStormAuditEvent")) {
-			return getXAStormAuditEvent();
+	public XAHBaseAuditEventDao getXAHBaseAuditEvent() {
+		if(mHBaseDao == null) {
+			mHBaseDao = new XAHBaseAuditEventDao(this);
 		}
 
-		logger.error("No DaoManager found for className=" + className, new Throwable());
-		return null;
-	}
-
-	public XAHBaseAuditEventDao getXAHBaseAuditEvent() {
-		return new XAHBaseAuditEventDao(this);
+		return mHBaseDao;
 	}
 
 	public XAHdfsAuditEventDao getXAHdfsAuditEvent() {
-		return new XAHdfsAuditEventDao(this);
+		if(mHdfsDao == null) {
+			mHdfsDao = new XAHdfsAuditEventDao(this);
+		}
+
+		return mHdfsDao;
 	}
 
 	public XAHiveAuditEventDao getXAHiveAuditEvent() {
-		return new XAHiveAuditEventDao(this);
+		if(mHiveDao == null) {
+			mHiveDao = new XAHiveAuditEventDao(this);
+		}
+
+		return mHiveDao;
 	}
 	
 	public XAKnoxAuditEventDao getXAKnoxAuditEvent() {
-		return new XAKnoxAuditEventDao(this);
+		if(mKnoxDao == null) {
+			mKnoxDao = new XAKnoxAuditEventDao(this);
+		}
+
+		return mKnoxDao;
 	}
 	
 	public XAStormAuditEventDao getXAStormAuditEvent() {
-		return new XAStormAuditEventDao(this);
+		if(mStormDao == null) {
+			mStormDao = new XAStormAuditEventDao(this);
+		}
+
+		return mStormDao;
 	}
 	
 	

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java b/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
index f31c0a3..8830e58 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/AuditEventBase.java
@@ -2,7 +2,7 @@ package com.xasecure.audit.model;
 
 import java.util.Date;
 
-import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.dao.DaoManager;
 
 
 
@@ -257,7 +257,7 @@ public abstract class AuditEventBase {
 		this.action = action;
 	}
 
-	public abstract void logEvent(AuditProvider provider);
+	public abstract void persist(DaoManager daoManager);
 	
 	@Override
 	public String toString() {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/model/HBaseAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/HBaseAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/HBaseAuditEvent.java
index cc25030..8a703ac 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/HBaseAuditEvent.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/HBaseAuditEvent.java
@@ -2,7 +2,8 @@ package com.xasecure.audit.model;
 
 import java.util.Date;
 
-import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.dao.DaoManager;
+import com.xasecure.audit.entity.XXHBaseAuditEvent;
 
 public class HBaseAuditEvent extends AuditEventBase {
 	protected String resourcePath;
@@ -10,6 +11,7 @@ public class HBaseAuditEvent extends AuditEventBase {
 	protected String requestData;
 
 	public HBaseAuditEvent() {
+		this.repositoryType = EnumRepositoryType.HBASE;
 	}
 
 	public HBaseAuditEvent(String agentId,
@@ -79,8 +81,8 @@ public class HBaseAuditEvent extends AuditEventBase {
 	}
 
 	@Override
-	public void logEvent(AuditProvider provider) {
-		provider.log(this);
+	public void persist(DaoManager daoManager) {
+		daoManager.getXAHBaseAuditEvent().create(new XXHBaseAuditEvent(this));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/model/HdfsAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/HdfsAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/HdfsAuditEvent.java
index 1a595da..b037988 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/HdfsAuditEvent.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/HdfsAuditEvent.java
@@ -2,13 +2,15 @@ package com.xasecure.audit.model;
 
 import java.util.Date;
 
-import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.dao.DaoManager;
+import com.xasecure.audit.entity.XXHdfsAuditEvent;
 
 public class HdfsAuditEvent extends AuditEventBase {
 	protected String resourcePath;
 	protected String resourceType;
 
 	public HdfsAuditEvent() {
+		this.repositoryType = EnumRepositoryType.HDFS;
 	}
 
 	public HdfsAuditEvent(String agentId,
@@ -62,8 +64,8 @@ public class HdfsAuditEvent extends AuditEventBase {
 	}
 
 	@Override
-	public void logEvent(AuditProvider provider) {
-		provider.log(this);
+	public void persist(DaoManager daoManager) {
+		daoManager.getXAHdfsAuditEvent().create(new XXHdfsAuditEvent(this));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
index f064481..d7538aa 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
@@ -2,7 +2,8 @@ package com.xasecure.audit.model;
 
 import java.util.Date;
 
-import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.dao.DaoManager;
+import com.xasecure.audit.entity.XXHiveAuditEvent;
 
 public class HiveAuditEvent extends AuditEventBase {
 	protected String resourcePath;
@@ -10,6 +11,7 @@ public class HiveAuditEvent extends AuditEventBase {
 	protected String requestData;
 
 	public HiveAuditEvent() {
+		this.repositoryType = EnumRepositoryType.HIVE;
 	}
 
 	public HiveAuditEvent(String agentId,
@@ -79,8 +81,8 @@ public class HiveAuditEvent extends AuditEventBase {
 	}
 
 	@Override
-	public void logEvent(AuditProvider provider) {
-		provider.log(this);
+	public void persist(DaoManager daoManager) {
+		daoManager.getXAHiveAuditEvent().create(new XXHiveAuditEvent(this));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
index 56be88c..fe0aa50 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
@@ -1,8 +1,8 @@
 package com.xasecure.audit.model;
 
-import java.util.Date;
 
-import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.dao.DaoManager;
+import com.xasecure.audit.entity.XXKnoxAuditEvent;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,6 +27,7 @@ public class KnoxAuditEvent extends AuditEventBase {
 	protected String requestData;
 
 	public KnoxAuditEvent() {
+		this.repositoryType = EnumRepositoryType.KNOX;
 	}
 
 	/**
@@ -73,8 +74,8 @@ public class KnoxAuditEvent extends AuditEventBase {
 	}
 
 	@Override
-	public void logEvent(AuditProvider provider) {
-		provider.log(this);
+	public void persist(DaoManager daoManager) {
+		daoManager.getXAKnoxAuditEvent().create(new XXKnoxAuditEvent(this));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/model/StormAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/StormAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/StormAuditEvent.java
index c65b7d6..ac9e4ac 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/model/StormAuditEvent.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/StormAuditEvent.java
@@ -1,8 +1,8 @@
 package com.xasecure.audit.model;
 
-import java.util.Date;
 
-import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.dao.DaoManager;
+import com.xasecure.audit.entity.XXStormAuditEvent;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,6 +27,7 @@ public class StormAuditEvent extends AuditEventBase {
 	protected String requestData;
 
 	public StormAuditEvent() {
+		this.repositoryType = EnumRepositoryType.STORM;
 	}
 
 	/**
@@ -73,8 +74,8 @@ public class StormAuditEvent extends AuditEventBase {
 	}
 
 	@Override
-	public void logEvent(AuditProvider provider) {
-		provider.log(this);
+	public void persist(DaoManager daoManager) {
+		daoManager.getXAStormAuditEvent().create(new XXStormAuditEvent(this));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
index 08f2982..6b30fe8 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
@@ -1,6 +1,5 @@
 package com.xasecure.audit.provider;
 
-import java.util.Date;
 import java.util.LinkedList;
 import java.util.Queue;
 
@@ -8,9 +7,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import com.xasecure.audit.model.AuditEventBase;
-import com.xasecure.audit.model.HBaseAuditEvent;
-import com.xasecure.audit.model.HdfsAuditEvent;
-import com.xasecure.audit.model.HiveAuditEvent;
 
 public class AsyncAuditProvider extends MultiDestAuditProvider implements
 		Runnable {
@@ -67,22 +63,8 @@ public class AsyncAuditProvider extends MultiDestAuditProvider implements
 	}
 
 	@Override
-	public void log(HBaseAuditEvent event) {
-		LOG.debug("AsyncAuditProvider.log(HBaseAuditEvent)");
-
-		queueEvent(event);
-	}
-
-	@Override
-	public void log(HdfsAuditEvent event) {
-		LOG.debug("AsyncAuditProvider.log(HdfsAuditEvent)");
-
-		queueEvent(event);
-	}
-
-	@Override
-	public void log(HiveAuditEvent event) {
-		LOG.debug("AsyncAuditProvider.log(HiveAuditEvent)");
+	public void log(AuditEventBase event) {
+		LOG.debug("AsyncAuditProvider.logEvent(AuditEventBase)");
 
 		queueEvent(event);
 	}
@@ -131,7 +113,7 @@ public class AsyncAuditProvider extends MultiDestAuditProvider implements
 				AuditEventBase event = dequeueEvent();
 
 				if (event != null) {
-					logEvent(event);
+					super.log(event);
 				} else {
 					flush();
 				}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
index 3f79640..9460de3 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
@@ -18,18 +18,10 @@
 
 package com.xasecure.audit.provider;
 
-import com.xasecure.audit.model.HBaseAuditEvent;
-import com.xasecure.audit.model.HdfsAuditEvent;
-import com.xasecure.audit.model.HiveAuditEvent;
-import com.xasecure.audit.model.KnoxAuditEvent;
-import com.xasecure.audit.model.StormAuditEvent;
+import com.xasecure.audit.model.AuditEventBase;
 
 public interface AuditProvider {
-    public void log(HBaseAuditEvent event);
-    public void log(HdfsAuditEvent event);
-    public void log(HiveAuditEvent event);
-    public void log(KnoxAuditEvent event);
-    public void log(StormAuditEvent event);
+	public void log(AuditEventBase event);
     
     public void start();
     public void stop();

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
index 4122bfa..b489128 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
@@ -77,51 +77,11 @@ public class DbAuditProvider implements AuditProvider {
 	}
 
 	@Override
-	public void log(HBaseAuditEvent event) {
-		LOG.debug("DbAuditProvider.log(HBaseAuditEvent)");
+	public void log(AuditEventBase event) {
+		LOG.debug("DbAuditProvider.log()");
 
 		if(preCreate(event)) {
-			hbaseDao.create(new XXHBaseAuditEvent(event));
-			postCreate(event);
-		}
-	}
-
-	@Override
-	public void log(HdfsAuditEvent event) {
-		LOG.debug("DbAuditProvider.log(HdfsAuditEvent)");
-
-		if(preCreate(event)) {
-			hdfsDao.create(new XXHdfsAuditEvent(event));
-			postCreate(event);
-		}
-	}
-
-	@Override
-	public void log(HiveAuditEvent event) {
-		LOG.debug("DbAuditProvider.log(HiveAuditEvent)");
-		
-		if(preCreate(event)) {
-			hiveDao.create(new XXHiveAuditEvent(event));
-			postCreate(event);
-		}
-	}
-	
-	@Override
-	public void log(KnoxAuditEvent event) {
-		LOG.debug("DbAuditProvider.log(KnoxAuditEvent)");
-		
-		if(preCreate(event)) {
-			knoxDao.create(new XXKnoxAuditEvent(event));
-			postCreate(event);
-		}
-	}
-
-	@Override
-	public void log(StormAuditEvent event) {
-		LOG.debug("DbAuditProvider.log(StormAuditEvent)");
-		
-		if(preCreate(event)) {
-			stormDao.create(new XXStormAuditEvent(event));
+			event.persist(daoManager);
 			postCreate(event);
 		}
 	}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
index 7f8d3f2..ecf25b1 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
@@ -1,5 +1,6 @@
 package com.xasecure.audit.provider;
 
+import com.xasecure.audit.model.AuditEventBase;
 import com.xasecure.audit.model.HBaseAuditEvent;
 import com.xasecure.audit.model.HdfsAuditEvent;
 import com.xasecure.audit.model.HiveAuditEvent;
@@ -27,27 +28,7 @@ import com.xasecure.audit.model.StormAuditEvent;
 public class DummyAuditProvider implements AuditProvider {
 
 	@Override
-	public void log(HBaseAuditEvent event) {
-		// intentionally left empty
-	}
-
-	@Override
-	public void log(HdfsAuditEvent event) {
-		// intentionally left empty
-	}
-
-	@Override
-	public void log(HiveAuditEvent event) {
-		// intentionally left empty
-	}
-
-	@Override
-	public void log(KnoxAuditEvent event) {
-		// intentionally left empty
-	}
-
-	@Override
-	public void log(StormAuditEvent event) {
+	public void log(AuditEventBase event) {
 		// intentionally left empty
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
index e4a0e07..e9c7bd4 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
@@ -21,11 +21,7 @@ package com.xasecure.audit.provider;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import com.xasecure.audit.model.HBaseAuditEvent;
-import com.xasecure.audit.model.HdfsAuditEvent;
-import com.xasecure.audit.model.HiveAuditEvent;
-import com.xasecure.audit.model.KnoxAuditEvent;
-import com.xasecure.audit.model.StormAuditEvent;
+import com.xasecure.audit.model.AuditEventBase;
 
 
 public class Log4jAuditProvider implements AuditProvider {
@@ -39,39 +35,7 @@ public class Log4jAuditProvider implements AuditProvider {
 	}
 
 	@Override
-	public void log(HBaseAuditEvent event) {
-		if(! AUDITLOG.isInfoEnabled())
-			return;
-
-		AUDITLOG.info(event.toString());
-	}
-
-	@Override
-	public void log(HdfsAuditEvent event) {
-		if(! AUDITLOG.isInfoEnabled())
-			return;
-
-		AUDITLOG.info(event.toString());
-	}
-
-	@Override
-	public void log(HiveAuditEvent event) {
-		if(! AUDITLOG.isInfoEnabled())
-			return;
-
-		AUDITLOG.info(event.toString());
-	}
-
-	@Override
-	public void log(KnoxAuditEvent event) {
-		if(! AUDITLOG.isInfoEnabled())
-			return;
-
-		AUDITLOG.info(event.toString());
-	}
-
-	@Override
-	public void log(StormAuditEvent event) {
+	public void log(AuditEventBase event) {
 		if(! AUDITLOG.isInfoEnabled())
 			return;
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
index bec0632..9181d0d 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
@@ -65,42 +65,18 @@ public class MultiDestAuditProvider implements AuditProvider {
 		}
 	}
 
-	@Override
-	public void log(HBaseAuditEvent event) {
-		LOG.debug("MultiDestAuditProvider.log(HBaseAuditEvent)");
-
-		logEvent(event);
-	}
-
-	@Override
-	public void log(HdfsAuditEvent event) {
-		LOG.debug("MultiDestAuditProvider.log(HdfsAuditEvent)");
-
-		logEvent(event);
-	}
-
-	@Override
-	public void log(HiveAuditEvent event) {
-		LOG.debug("MultiDestAuditProvider.log(HiveAuditEvent)");
-
-		logEvent(event);
-	}
-	
-	@Override
-	public void log(KnoxAuditEvent event) {
-		LOG.debug("MultiDestAuditProvider.log(KnoxAuditEvent)");
-
-		logEvent(event);
-	}
 	
 	@Override
-	public void log(StormAuditEvent event) {
-		LOG.debug("MultiDestAuditProvider.log(StormAuditEvent)");
-
-		logEvent(event);
+	public void log(AuditEventBase event) {
+		try {
+            for(AuditProvider provider : mProviders) {
+            	provider.log(event);
+            }
+		} catch(Throwable excp) {
+			LOG.error("failed to log event { " + event.toString() + " }", excp);
+		}
 	}
 
-
 	@Override
 	public void start() {
 		for(AuditProvider provider : mProviders) {
@@ -159,14 +135,4 @@ public class MultiDestAuditProvider implements AuditProvider {
 			LOG.error("AsyncAuditProvider.flush(): failed to flush events", excp);
 		}
 	}
-	
-	protected void logEvent(AuditEventBase event) {
-		try {
-            for(AuditProvider provider : mProviders) {
-                event.logEvent(provider);
-            }
-		} catch(Throwable excp) {
-			LOG.error("failed to log event { " + event.toString() + " }", excp);
-		}
-	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/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 f31aa66..073a356 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
@@ -3,15 +3,18 @@ import org.apache.commons.logging.Log;
 import org.apache.log4j.xml.DOMConfigurator;
 import org.apache.commons.logging.LogFactory;
 
-
 import java.io.File;
 import java.io.FileInputStream;
+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;
+import com.xasecure.audit.model.KnoxAuditEvent;
+import com.xasecure.audit.model.StormAuditEvent;
 import com.xasecure.audit.provider.AuditProvider;
 import com.xasecure.audit.provider.AuditProviderFactory;
 
@@ -63,27 +66,22 @@ public class TestEvents {
         	
         	String strEventCount = args.length > 0 ? args[0] : auditProperties.getProperty("xasecure.audit.test.event.count");
         	
-        	int eventCount = (strEventCount == null) ? 1024 : Integer.parseInt(strEventCount);
       		
+        	int eventCount = (strEventCount == null) ? 1024 : Integer.parseInt(strEventCount);
         	
-        	int count = 0;
-        	for(int i = 0; i < eventCount / 3; i++) {
-	            HBaseAuditEvent hbaseEvent = new HBaseAuditEvent();
-	            hbaseEvent.setRepositoryType(EnumRepositoryType.HBASE);
-
-	            HdfsAuditEvent hdfsEvent = new HdfsAuditEvent();
-	            hdfsEvent.setRepositoryType(EnumRepositoryType.HDFS);
-
-	            HiveAuditEvent hiveEvent = new HiveAuditEvent();
-	            hiveEvent.setRepositoryType(EnumRepositoryType.HIVE);
-
-	            LOG.info("==> TestEvents.main(" + (++count) + "): adding HBaseAuditEvent");
-	            provider.log(hbaseEvent);
+        	AuditEventBase[] auditEvents = {
+	            new HBaseAuditEvent(),
+	            new HdfsAuditEvent(),
+	            new HiveAuditEvent(),
+	            new KnoxAuditEvent(),
+	            new StormAuditEvent(),
+        	};
+        	
+        	for(int i = 0; i < eventCount; i++) {
+        		AuditEventBase event = auditEvents[i % auditEvents.length];
 
-	            LOG.info("==> TestEvents.main(" + (++count) + "): adding HdfsAuditEvent");
-	            provider.log(hdfsEvent);
-	
-	            LOG.info("==> TestEvents.main(" + (++count) + "): adding HiveAuditEvent");
-	            provider.log(hiveEvent);
+	            LOG.info("==> TestEvents.main(" + (i+1) + "): adding " + event.getClass().getName());
+        		event.setEventTime(new Date());
+        		provider.log(event);
 	            
 	            if(i != 0 && ((i % 100) == 0))
 	            	Thread.sleep(100);

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/914f0bae/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 6725328..d1a944f 100755
--- a/lookup-client/src/scripts/run-audit-test.sh
+++ b/lookup-client/src/scripts/run-audit-test.sh
@@ -1,13 +1,9 @@
 #!/bin/bash
 
-XA_AGENTS_DIR=$HOME/Hortonworks/git/xa-agents-2.1
+HADOOP_DIR=/usr/lib/hadoop
+HADOOP_CONF_DIR=/etc/hadoop/conf
 
-CONF_DIR=$XA_AGENTS_DIR/conf/hadoop
-HADOOP_LIB_DIR=$XA_AGENTS_DIR/lib/hadoop-hdp-2.0
-JPA_LIB_DIR=$XA_AGENTS_DIR/lib/jpa
-MYSQL_LIB_DIR=$XA_AGENTS_DIR/lib/mysql
-
-cp="$CONF_DIR:$HADOOP_LIB_DIR/*:$JPA_LIB_DIR/*:$MYSQL_LIB_DIR/*:$XA_AGENTS_DIR/dist/xasecure-audit.jar"
+cp="$HADOOP_CONF_DIR:$HADOOP_DIR/lib/*:$HADOOP_DIR/client/hadoop-common.jar"
 export cp
 
 java -Xmx1024M -Xms1024M -cp "${cp}" com.xasecure.audit.test.TestEvents $*


Mime
View raw message