You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2014/10/12 23:25:13 UTC

[3/4] git commit: - added a flag to not overwrite existing HDFS file (thanks Alok for the review) - added explicit flush after every write if buffer size is specified as 0.

- added a flag to not overwrite existing HDFS file (thanks Alok for the
review)
- added explicit flush after every write if buffer size is specified as
0.

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

Branch: refs/heads/master
Commit: b5dbed684be615864e22c39cd6761f499af89b7a
Parents: 5f4053e
Author: mneethiraj <mn...@hortonworks.com>
Authored: Sun Oct 12 14:15:13 2014 -0700
Committer: mneethiraj <mn...@hortonworks.com>
Committed: Sun Oct 12 14:15:13 2014 -0700

----------------------------------------------------------------------
 .../java/com/xasecure/audit/provider/LocalFileLogBuffer.java  | 4 ++++
 .../com/xasecure/audit/provider/hdfs/HdfsLogDestination.java  | 7 ++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b5dbed68/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java b/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
index 0d1c42e..9dc7327 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
@@ -192,6 +192,10 @@ public class LocalFileLogBuffer<T> implements LogBuffer<T> {
 			if(writer != null) {
 				try {
 					writer.write(msg + MiscUtil.LINE_SEPARATOR);
+					
+					if(mFileBufferSizeBytes <= 0) {
+						writer.flush();
+					}
 	
 					ret = true;
 				} catch(IOException excp) {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/b5dbed68/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java b/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
index a5ec60b..5f69567 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
@@ -183,6 +183,7 @@ public class HdfsLogDestination<T> implements LogDestination<T> {
 		FileSystem         fileSystem  = null;
 		Path               pathLogfile = null;
 		Configuration      conf        = null;
+		boolean            bOverwrite  = false;
 
 		try {
 			mLogger.debug("HdfsLogDestination.openFile(): opening file " + mHdfsFilename);
@@ -207,7 +208,7 @@ public class HdfsLogDestination<T> implements LogDestination<T> {
 
 				// if file does not exist or if mIsAppend==false, create the file
 				if(ostream == null) {
-					ostream = fileSystem.create(pathLogfile);
+					ostream = fileSystem.create(pathLogfile, bOverwrite);
 				}
 			} catch(IOException excp) {
 				// append may not be supported by the filesystem; or the file might already be open by another application. Try a different filename - with current timestamp
@@ -216,14 +217,14 @@ public class HdfsLogDestination<T> implements LogDestination<T> {
 			}
 
 			if(ostream == null){
-				ostream = fileSystem.create(pathLogfile);
+				ostream = fileSystem.create(pathLogfile, bOverwrite);
 			}
 		} catch(IOException ex) {
 			Path parentPath = pathLogfile.getParent();
 
 			try {
 				if(parentPath != null&& fileSystem != null && !fileSystem.exists(parentPath) && fileSystem.mkdirs(parentPath)) {
-					ostream = fileSystem.create(pathLogfile);
+					ostream = fileSystem.create(pathLogfile, bOverwrite);
 				} else {
 					logException("HdfsLogDestination.openFile() failed", ex);
 				}