HDFS-12306. Add audit log for some erasure coding operations. Contributed by Huafeng Wang
This commit is contained in:
parent
b0fbf17965
commit
0b67436068
@ -7055,18 +7055,13 @@ void setErasureCodingPolicy(final String srcArg, final String ecPolicyName,
|
|||||||
resultingStat = FSDirErasureCodingOp.setErasureCodingPolicy(this,
|
resultingStat = FSDirErasureCodingOp.setErasureCodingPolicy(this,
|
||||||
srcArg, ecPolicyName, pc, logRetryCache);
|
srcArg, ecPolicyName, pc, logRetryCache);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (AccessControlException ace) {
|
|
||||||
logAuditEvent(success, operationName, srcArg, null,
|
|
||||||
resultingStat);
|
|
||||||
throw ace;
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock(operationName);
|
writeUnlock(operationName);
|
||||||
if (success) {
|
if (success) {
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
}
|
}
|
||||||
|
logAuditEvent(success, operationName, srcArg, null, resultingStat);
|
||||||
}
|
}
|
||||||
logAuditEvent(success, operationName, srcArg, null,
|
|
||||||
resultingStat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7074,9 +7069,9 @@ void setErasureCodingPolicy(final String srcArg, final String ecPolicyName,
|
|||||||
* @param policies The policies to add.
|
* @param policies The policies to add.
|
||||||
* @return The according result of add operation.
|
* @return The according result of add operation.
|
||||||
*/
|
*/
|
||||||
AddECPolicyResponse[] addECPolicies(ErasureCodingPolicy[] policies)
|
AddECPolicyResponse[] addErasureCodingPolicies(ErasureCodingPolicy[] policies)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final String operationName = "addECPolicies";
|
final String operationName = "addErasureCodingPolicies";
|
||||||
String addECPolicyName = "";
|
String addECPolicyName = "";
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
List<AddECPolicyResponse> responses = new ArrayList<>();
|
List<AddECPolicyResponse> responses = new ArrayList<>();
|
||||||
@ -7201,18 +7196,13 @@ void unsetErasureCodingPolicy(final String srcArg,
|
|||||||
resultingStat = FSDirErasureCodingOp.unsetErasureCodingPolicy(this,
|
resultingStat = FSDirErasureCodingOp.unsetErasureCodingPolicy(this,
|
||||||
srcArg, pc, logRetryCache);
|
srcArg, pc, logRetryCache);
|
||||||
success = true;
|
success = true;
|
||||||
} catch (AccessControlException ace) {
|
|
||||||
logAuditEvent(success, operationName, srcArg, null,
|
|
||||||
resultingStat);
|
|
||||||
throw ace;
|
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock(operationName);
|
writeUnlock(operationName);
|
||||||
if (success) {
|
if (success) {
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
}
|
}
|
||||||
|
logAuditEvent(success, operationName, srcArg, null, resultingStat);
|
||||||
}
|
}
|
||||||
logAuditEvent(success, operationName, srcArg, null,
|
|
||||||
resultingStat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7220,14 +7210,20 @@ void unsetErasureCodingPolicy(final String srcArg,
|
|||||||
*/
|
*/
|
||||||
ErasureCodingPolicy getErasureCodingPolicy(String src)
|
ErasureCodingPolicy getErasureCodingPolicy(String src)
|
||||||
throws AccessControlException, UnresolvedLinkException, IOException {
|
throws AccessControlException, UnresolvedLinkException, IOException {
|
||||||
|
final String operationName = "getErasureCodingPolicy";
|
||||||
|
boolean success = false;
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
FSPermissionChecker pc = getPermissionChecker();
|
FSPermissionChecker pc = getPermissionChecker();
|
||||||
readLock();
|
readLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
return FSDirErasureCodingOp.getErasureCodingPolicy(this, src, pc);
|
final ErasureCodingPolicy ret =
|
||||||
|
FSDirErasureCodingOp.getErasureCodingPolicy(this, src, pc);
|
||||||
|
success = true;
|
||||||
|
return ret;
|
||||||
} finally {
|
} finally {
|
||||||
readUnlock("getErasureCodingPolicy");
|
readUnlock(operationName);
|
||||||
|
logAuditEvent(success, operationName, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7235,13 +7231,19 @@ ErasureCodingPolicy getErasureCodingPolicy(String src)
|
|||||||
* Get available erasure coding polices
|
* Get available erasure coding polices
|
||||||
*/
|
*/
|
||||||
ErasureCodingPolicy[] getErasureCodingPolicies() throws IOException {
|
ErasureCodingPolicy[] getErasureCodingPolicies() throws IOException {
|
||||||
|
final String operationName = "getErasureCodingPolicies";
|
||||||
|
boolean success = false;
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
readLock();
|
readLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
return FSDirErasureCodingOp.getErasureCodingPolicies(this);
|
final ErasureCodingPolicy[] ret =
|
||||||
|
FSDirErasureCodingOp.getErasureCodingPolicies(this);
|
||||||
|
success = true;
|
||||||
|
return ret;
|
||||||
} finally {
|
} finally {
|
||||||
readUnlock("getErasureCodingPolicies");
|
readUnlock(operationName);
|
||||||
|
logAuditEvent(success, operationName, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7249,13 +7251,19 @@ ErasureCodingPolicy[] getErasureCodingPolicies() throws IOException {
|
|||||||
* Get available erasure coding codecs and corresponding coders.
|
* Get available erasure coding codecs and corresponding coders.
|
||||||
*/
|
*/
|
||||||
HashMap<String, String> getErasureCodingCodecs() throws IOException {
|
HashMap<String, String> getErasureCodingCodecs() throws IOException {
|
||||||
|
final String operationName = "getErasureCodingCodecs";
|
||||||
|
boolean success = false;
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
readLock();
|
readLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.READ);
|
checkOperation(OperationCategory.READ);
|
||||||
return FSDirErasureCodingOp.getErasureCodingCodecs(this);
|
final HashMap<String, String> ret =
|
||||||
|
FSDirErasureCodingOp.getErasureCodingCodecs(this);
|
||||||
|
success = true;
|
||||||
|
return ret;
|
||||||
} finally {
|
} finally {
|
||||||
readUnlock("getErasureCodingCodecs");
|
readUnlock(operationName);
|
||||||
|
logAuditEvent(success, operationName, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2298,7 +2298,7 @@ public AddECPolicyResponse[] addErasureCodingPolicies(
|
|||||||
ErasureCodingPolicy[] policies) throws IOException {
|
ErasureCodingPolicy[] policies) throws IOException {
|
||||||
checkNNStartup();
|
checkNNStartup();
|
||||||
namesystem.checkSuperuserPrivilege();
|
namesystem.checkSuperuserPrivilege();
|
||||||
return namesystem.addECPolicies(policies);
|
return namesystem.addErasureCodingPolicies(policies);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user