HDFS-14685. DefaultAuditLogger doesn't print CallerContext. Contributed by xuzq.
This commit is contained in:
parent
eaf350c414
commit
b964b81f85
@ -1077,7 +1077,9 @@ private List<AuditLogger> initAuditLoggers(Configuration conf) {
|
||||
|
||||
// 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
|
||||
|
@ -61,13 +61,10 @@ public void logAuditEvent(boolean succeeded, String userName,
|
||||
* @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
|
||||
|
@ -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 void testInitAuditLoggers() throws IOException {
|
||||
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, "");
|
||||
|
Loading…
Reference in New Issue
Block a user