diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 9a4c46666c9..ecfb7665437 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -1067,7 +1067,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, // Make sure there is at least one logger installed. if (auditLoggers.isEmpty()) { - auditLoggers.add(new DefaultAuditLogger()); + DefaultAuditLogger defaultAuditLogger = new DefaultAuditLogger(); + defaultAuditLogger.initialize(conf); + auditLoggers.add(defaultAuditLogger); } // Add audit logger to calculate top users diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/HdfsAuditLogger.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/HdfsAuditLogger.java index 894c4df1945..0a355d0ec3e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/HdfsAuditLogger.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/HdfsAuditLogger.java @@ -61,13 +61,10 @@ public abstract class HdfsAuditLogger implements AuditLogger { * @param dtSecretManager The token secret manager, or null if not logging * token tracking information */ - public void logAuditEvent(boolean succeeded, String userName, + public abstract void logAuditEvent(boolean succeeded, String userName, InetAddress addr, String cmd, String src, String dst, FileStatus stat, CallerContext callerContext, UserGroupInformation ugi, - DelegationTokenSecretManager dtSecretManager) { - logAuditEvent(succeeded, userName, addr, cmd, src, dst, stat, - ugi, dtSecretManager); - } + DelegationTokenSecretManager dtSecretManager); /** * Same as diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java index cc5999f7af5..18cd1b6399e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hdfs.server.namenode; +import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_CALLER_CONTEXT_ENABLED_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY; import static org.hamcrest.CoreMatchers.either; @@ -242,10 +243,14 @@ public class TestFSNamesystem { conf.set(DFSConfigKeys.DFS_NAMENODE_AUDIT_LOGGERS_KEY, ""); // Disable top logger conf.setBoolean(DFSConfigKeys.NNTOP_ENABLED_KEY, false); + conf.setBoolean(HADOOP_CALLER_CONTEXT_ENABLED_KEY, true); fsn = new FSNamesystem(conf, fsImage); auditLoggers = fsn.getAuditLoggers(); assertTrue(auditLoggers.size() == 1); assertTrue(auditLoggers.get(0) instanceof FSNamesystem.DefaultAuditLogger); + FSNamesystem.DefaultAuditLogger defaultAuditLogger = + (FSNamesystem.DefaultAuditLogger) auditLoggers.get(0); + assertTrue(defaultAuditLogger.getCallerContextEnabled()); // Not to specify any audit loggers in config conf.set(DFSConfigKeys.DFS_NAMENODE_AUDIT_LOGGERS_KEY, "");