Repository: incubator-ranger
Updated Branches:
  refs/heads/master 17e37f0b6 -> 787457b58


RANGER-1134: Audit to Secure solr fails in case of Ranger Knox Plugin due to 
MDC context issue


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

Branch: refs/heads/master
Commit: 787457b588a6e4ddac7d5bd31bfe613ede6478d8
Parents: 17e37f0
Author: rmani <rm...@hortonworks.com>
Authored: Tue Aug 2 10:03:20 2016 -0700
Committer: rmani <rm...@hortonworks.com>
Committed: Tue Aug 2 10:03:20 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/ranger/audit/queue/AuditAsyncQueue.java | 4 ++++
 .../main/java/org/apache/ranger/audit/queue/AuditBatchQueue.java | 3 +++
 .../main/java/org/apache/ranger/audit/queue/AuditFileSpool.java  | 3 +++
 .../java/org/apache/ranger/audit/queue/AuditSummaryQueue.java    | 3 +++
 4 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/787457b5/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditAsyncQueue.java
----------------------------------------------------------------------
diff --git 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditAsyncQueue.java 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditAsyncQueue.java
index e7adef2..26c690e 100644
--- 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditAsyncQueue.java
+++ 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditAsyncQueue.java
@@ -26,6 +26,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.MDC;
 import org.apache.ranger.audit.model.AuditEventBase;
 import org.apache.ranger.audit.provider.AuditHandler;
 import org.apache.ranger.audit.provider.MiscUtil;
@@ -127,6 +128,8 @@ public class AuditAsyncQueue extends AuditQueue implements 
Runnable {
        @Override
        public void run() {
                try {
+                       //This is done to clear the MDC context to avoid issue 
with Ranger Auditing for Knox
+                       MDC.clear();
                        if (isConsumerDestination && MiscUtil.getUGILoginUser() 
!= null) {
                                PrivilegedAction<Void> action = new 
PrivilegedAction<Void>() {
                                        public Void run() {
@@ -140,6 +143,7 @@ public class AuditAsyncQueue extends AuditQueue implements 
Runnable {
                        } else {
                                runDoAs();
                        }
+
                } catch (Throwable t) {
                        logger.fatal("Exited thread abnormaly. queue=" + 
getName(), t);
                }

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/787457b5/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditBatchQueue.java
----------------------------------------------------------------------
diff --git 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditBatchQueue.java 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditBatchQueue.java
index 5b56c96..07c8819 100644
--- 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditBatchQueue.java
+++ 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditBatchQueue.java
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.MDC;
 import org.apache.ranger.audit.model.AuditEventBase;
 import org.apache.ranger.audit.provider.AuditHandler;
 import org.apache.ranger.audit.provider.MiscUtil;
@@ -211,6 +212,8 @@ public class AuditBatchQueue extends AuditQueue implements 
Runnable {
        @Override
        public void run() {
                try {
+                       //This is done to clear the MDC context to avoid issue 
with Ranger Auditing for Knox
+                       MDC.clear();
                        if (isConsumerDestination && MiscUtil.getUGILoginUser() 
!= null) {
                                PrivilegedAction<Void> action = new 
PrivilegedAction<Void>() {
                                        public Void run() {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/787457b5/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditFileSpool.java
----------------------------------------------------------------------
diff --git 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditFileSpool.java 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditFileSpool.java
index 8e3c992..fc4ff5d 100644
--- 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditFileSpool.java
+++ 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditFileSpool.java
@@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.MDC;
 import org.apache.ranger.audit.model.AuditEventBase;
 import org.apache.ranger.audit.provider.AuditHandler;
 import org.apache.ranger.audit.provider.MiscUtil;
@@ -753,6 +754,8 @@ public class AuditFileSpool implements Runnable {
        @Override
        public void run() {
                try {
+                       //This is done to clear the MDC context to avoid issue 
with Ranger Auditing for Knox
+                       MDC.clear();
                        if (MiscUtil.getUGILoginUser() != null) {
                                PrivilegedAction<Void> action = new 
PrivilegedAction<Void>() {
                                        public Void run() {

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/787457b5/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditSummaryQueue.java
----------------------------------------------------------------------
diff --git 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditSummaryQueue.java
 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditSummaryQueue.java
index 70c322d..14d0ab6 100644
--- 
a/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditSummaryQueue.java
+++ 
b/agents-audit/src/main/java/org/apache/ranger/audit/queue/AuditSummaryQueue.java
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.MDC;
 import org.apache.ranger.audit.model.AuditEventBase;
 import org.apache.ranger.audit.provider.AuditHandler;
 import org.apache.ranger.audit.provider.MiscUtil;
@@ -147,6 +148,8 @@ public class AuditSummaryQueue extends AuditQueue 
implements Runnable {
        @Override
        public void run() {
                try {
+                       //This is done to clear the MDC context to avoid issue 
with Ranger Auditing for Knox
+                       MDC.clear();
                        if (isConsumerDestination && MiscUtil.getUGILoginUser() 
!= null) {
                                PrivilegedAction<Void> action = new 
PrivilegedAction<Void>() {
                                        public Void run() {

Reply via email to