HDFS-8114. Erasure coding: Add auditlog FSNamesystem#createErasureCodingZone if this operation fails. Contributed by Rakesh R.

This commit is contained in:
Zhe Zhang 2015-04-13 11:15:02 -07:00 committed by Zhe Zhang
parent a32c4dc38a
commit 3b56a5aa9e

View File

@ -7531,11 +7531,19 @@ void createErasureCodingZone(final String srcArg, final ECSchema schema,
SafeModeException, AccessControlException { SafeModeException, AccessControlException {
String src = srcArg; String src = srcArg;
HdfsFileStatus resultingStat = null; HdfsFileStatus resultingStat = null;
FSPermissionChecker pc = null;
byte[][] pathComponents = null;
boolean success = false;
try {
checkSuperuserPrivilege(); checkSuperuserPrivilege();
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
final byte[][] pathComponents = pathComponents =
FSDirectory.getPathComponentsForReservedPath(src); FSDirectory.getPathComponentsForReservedPath(src);
FSPermissionChecker pc = getPermissionChecker(); pc = getPermissionChecker();
} catch (Throwable e) {
logAuditEvent(success, "createErasureCodingZone", srcArg);
throw e;
}
writeLock(); writeLock();
try { try {
checkSuperuserPrivilege(); checkSuperuserPrivilege();
@ -7549,11 +7557,12 @@ void createErasureCodingZone(final String srcArg, final ECSchema schema,
getEditLog().logSetXAttrs(src, xAttrs, logRetryCache); getEditLog().logSetXAttrs(src, xAttrs, logRetryCache);
final INodesInPath iip = dir.getINodesInPath4Write(src, false); final INodesInPath iip = dir.getINodesInPath4Write(src, false);
resultingStat = dir.getAuditFileInfo(iip); resultingStat = dir.getAuditFileInfo(iip);
success = true;
} finally { } finally {
writeUnlock(); writeUnlock();
} }
getEditLog().logSync(); getEditLog().logSync();
logAuditEvent(true, "createErasureCodingZone", srcArg, null, resultingStat); logAuditEvent(success, "createErasureCodingZone", srcArg, null, resultingStat);
} }
/** /**