You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by rm...@apache.org on 2017/08/03 22:07:49 UTC
ranger git commit: RANGER-1501: Audit Flush to HDFS does not actually
cause the audit logs to be flushed to HDFS - improvement patch
Repository: ranger
Updated Branches:
refs/heads/master c12cfd977 -> 1befffcc1
RANGER-1501: Audit Flush to HDFS does not actually cause the audit logs to be flushed to HDFS - improvement patch
Signed-off-by: rmani <rm...@hortonworks.com>
Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/1befffcc
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/1befffcc
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/1befffcc
Branch: refs/heads/master
Commit: 1befffcc1c18679cdf2c6413496b2078f6d2a838
Parents: c12cfd9
Author: rmani <rm...@hortonworks.com>
Authored: Thu Aug 3 14:41:09 2017 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Thu Aug 3 15:07:37 2017 -0700
----------------------------------------------------------------------
.../ranger/audit/destination/HDFSAuditDestination.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ranger/blob/1befffcc/agents-audit/src/main/java/org/apache/ranger/audit/destination/HDFSAuditDestination.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/org/apache/ranger/audit/destination/HDFSAuditDestination.java b/agents-audit/src/main/java/org/apache/ranger/audit/destination/HDFSAuditDestination.java
index 1a15c30..66d8504 100644
--- a/agents-audit/src/main/java/org/apache/ranger/audit/destination/HDFSAuditDestination.java
+++ b/agents-audit/src/main/java/org/apache/ranger/audit/destination/HDFSAuditDestination.java
@@ -61,7 +61,7 @@ public class HDFSAuditDestination extends AuditDestination {
private String logFolder;
private PrintWriter logWriter = null;
- FSDataOutputStream ostream = null; // output stream wrapped in logWriter
+ volatile FSDataOutputStream ostream = null; // output stream wrapped in logWriter
private String currentFileName;
@@ -168,6 +168,7 @@ public class HDFSAuditDestination extends AuditDestination {
addDeferredCount(events.size());
out.close();
logWriter = null;
+ ostream = null;
return false;
}
} catch (Throwable t) {
@@ -187,10 +188,10 @@ public class HDFSAuditDestination extends AuditDestination {
@Override
public void flush() {
logger.info("Flush called. name=" + getName());
- if (logWriter != null) {
+ if (ostream != null) {
try {
synchronized (this) {
- if (logWriter != null)
+ if (ostream != null)
// 1) PrinterWriter does not have bufferring of its own so
// we need to flush its underlying stream
// 2) HDFS flush() does not really flush all the way to disk.
@@ -257,6 +258,7 @@ public class HDFSAuditDestination extends AuditDestination {
+ getName() + ", fileName=" + currentFileName);
}
logWriter = null;
+ ostream = null;
}
logStatus();
}
@@ -352,6 +354,7 @@ public class HDFSAuditDestination extends AuditDestination {
}
logWriter = null;
+ ostream = null;
currentFileName = null;
if (!rollOverByDuration) {