From ef02f9b233116a10cf9274b3753fe0b8dcbe8d92 Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Wed, 15 Aug 2018 09:22:24 -0700 Subject: [PATCH] HDFS-13217. Audit log all EC policy names during addErasureCodingPolicies. Contributed by liaoyuxiangqin. --- .../hadoop/hdfs/server/namenode/FSNamesystem.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 ecf7fce28be..cdd7d480933 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 @@ -7538,9 +7538,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, ErasureCodingPolicy[] policies, final boolean logRetryCache) throws IOException { final String operationName = "addErasureCodingPolicies"; - String addECPolicyName = ""; + List addECPolicyNames = new ArrayList<>(policies.length); checkOperation(OperationCategory.WRITE); - List responses = new ArrayList<>(); + List responses = + new ArrayList<>(policies.length); boolean success = false; writeLock(); try { @@ -7551,7 +7552,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, ErasureCodingPolicy newPolicy = FSDirErasureCodingOp.addErasureCodingPolicy(this, policy, logRetryCache); - addECPolicyName = newPolicy.getName(); + addECPolicyNames.add(newPolicy.getName()); responses.add(new AddErasureCodingPolicyResponse(newPolicy)); } catch (HadoopIllegalArgumentException e) { responses.add(new AddErasureCodingPolicyResponse(policy, e)); @@ -7564,7 +7565,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, if (success) { getEditLog().logSync(); } - logAuditEvent(success, operationName, addECPolicyName, null, null); + logAuditEvent(success, operationName, addECPolicyNames.toString(), + null, null); } }