From 3b56a5aa9e82b5ef4fbafa832947eb80b77f0976 Mon Sep 17 00:00:00 2001 From: Zhe Zhang Date: Mon, 13 Apr 2015 11:15:02 -0700 Subject: [PATCH] HDFS-8114. Erasure coding: Add auditlog FSNamesystem#createErasureCodingZone if this operation fails. Contributed by Rakesh R. --- .../hdfs/server/namenode/FSNamesystem.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 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 3a865718a6..a7d43881ef 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 @@ -7531,11 +7531,19 @@ void createErasureCodingZone(final String srcArg, final ECSchema schema, SafeModeException, AccessControlException { String src = srcArg; HdfsFileStatus resultingStat = null; - checkSuperuserPrivilege(); - checkOperation(OperationCategory.WRITE); - final byte[][] pathComponents = - FSDirectory.getPathComponentsForReservedPath(src); - FSPermissionChecker pc = getPermissionChecker(); + FSPermissionChecker pc = null; + byte[][] pathComponents = null; + boolean success = false; + try { + checkSuperuserPrivilege(); + checkOperation(OperationCategory.WRITE); + pathComponents = + FSDirectory.getPathComponentsForReservedPath(src); + pc = getPermissionChecker(); + } catch (Throwable e) { + logAuditEvent(success, "createErasureCodingZone", srcArg); + throw e; + } writeLock(); try { checkSuperuserPrivilege(); @@ -7549,11 +7557,12 @@ void createErasureCodingZone(final String srcArg, final ECSchema schema, getEditLog().logSetXAttrs(src, xAttrs, logRetryCache); final INodesInPath iip = dir.getINodesInPath4Write(src, false); resultingStat = dir.getAuditFileInfo(iip); + success = true; } finally { writeUnlock(); } getEditLog().logSync(); - logAuditEvent(true, "createErasureCodingZone", srcArg, null, resultingStat); + logAuditEvent(success, "createErasureCodingZone", srcArg, null, resultingStat); } /**