Skip to content

Commit 78b6013

Browse files
committed
HDFS-16944 Add audit log for RouterAdminServer to save privileged operation log seperately.
We found that in other components (like namenode in hdfs or resourcemanager in yarn), debug log and audit log are record seperately, except RouterAdminServer.
1 parent 487368c commit 78b6013

File tree

1 file changed

+12
-10
lines changed
  • hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router

1 file changed

+12
-10
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public class RouterAdminServer extends AbstractService
112112

113113
private static final Logger LOG =
114114
LoggerFactory.getLogger(RouterAdminServer.class);
115+
private static final Logger AUDITLOG =
116+
LoggerFactory.getLogger(RouterAdminServer.class.getName() + ".audit");
115117

116118
private Configuration conf;
117119

@@ -514,11 +516,11 @@ public EnterSafeModeResponse enterSafeMode(EnterSafeModeRequest request)
514516
safeModeService.setManualSafeMode(true);
515517
success = verifySafeMode(true);
516518
if (success) {
517-
LOG.info("STATE* Safe mode is ON.\n" + "It was turned on manually. "
519+
AUDITLOG.info("STATE* Safe mode is ON.\n" + "It was turned on manually. "
518520
+ "Use \"hdfs dfsrouteradmin -safemode leave\" to turn"
519521
+ " safe mode off.");
520522
} else {
521-
LOG.error("Unable to enter safemode.");
523+
AUDITLOG.error("Unable to enter safemode.");
522524
}
523525
}
524526
return EnterSafeModeResponse.newInstance(success);
@@ -535,9 +537,9 @@ public LeaveSafeModeResponse leaveSafeMode(LeaveSafeModeRequest request)
535537
safeModeService.setManualSafeMode(false);
536538
success = verifySafeMode(false);
537539
if (success) {
538-
LOG.info("STATE* Safe mode is OFF.\n" + "It was turned off manually.");
540+
AUDITLOG.info("STATE* Safe mode is OFF.\n" + "It was turned off manually.");
539541
} else {
540-
LOG.error("Unable to leave safemode.");
542+
AUDITLOG.error("Unable to leave safemode.");
541543
}
542544
}
543545
return LeaveSafeModeResponse.newInstance(success);
@@ -676,12 +678,12 @@ public DisableNameserviceResponse disableNameservice(
676678
if (namespaceExists(nsId)) {
677679
success = getDisabledNameserviceStore().disableNameservice(nsId);
678680
if (success) {
679-
LOG.info("Nameservice {} disabled successfully.", nsId);
681+
AUDITLOG.info("Nameservice {} disabled successfully.", nsId);
680682
} else {
681-
LOG.error("Unable to disable Nameservice {}", nsId);
683+
AUDITLOG.error("Unable to disable Nameservice {}", nsId);
682684
}
683685
} else {
684-
LOG.error("Cannot disable {}, it does not exists", nsId);
686+
AUDITLOG.error("Cannot disable {}, it does not exists", nsId);
685687
}
686688
return DisableNameserviceResponse.newInstance(success);
687689
}
@@ -711,12 +713,12 @@ public EnableNameserviceResponse enableNameservice(
711713
if (disabled.contains(nsId)) {
712714
success = store.enableNameservice(nsId);
713715
if (success) {
714-
LOG.info("Nameservice {} enabled successfully.", nsId);
716+
AUDITLOG.info("Nameservice {} enabled successfully.", nsId);
715717
} else {
716-
LOG.error("Unable to enable Nameservice {}", nsId);
718+
AUDITLOG.error("Unable to enable Nameservice {}", nsId);
717719
}
718720
} else {
719-
LOG.error("Cannot enable {}, it was not disabled", nsId);
721+
AUDITLOG.error("Cannot enable {}, it was not disabled", nsId);
720722
}
721723
return EnableNameserviceResponse.newInstance(success);
722724
}

0 commit comments

Comments
 (0)