HDFS-4116. Add auditlog for some snapshot operations. Contributed by Jing Zhao.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1404860 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2012-11-02 02:26:58 +00:00
parent 04b2adca05
commit 98c0f13b19
2 changed files with 20 additions and 4 deletions

View File

@ -40,3 +40,5 @@ Branch-2802 Snapshot (Unreleased)
HDFS-4133. Add testcases for testing basic snapshot functionalities.
(Jing Zhao via suresh)
HDFS-4116. Add auditlog for some snapshot operations. (Jing Zhao via suresh)

View File

@ -5519,7 +5519,8 @@ public void allowSnapshot(String path) throws SafeModeException, IOException {
try {
checkOperation(OperationCategory.WRITE);
if (isInSafeMode()) {
throw new SafeModeException("Cannot allow snapshot for " + path, safeMode);
throw new SafeModeException("Cannot allow snapshot for " + path,
safeMode);
}
checkOwner(path);
@ -5531,7 +5532,10 @@ public void allowSnapshot(String path) throws SafeModeException, IOException {
}
getEditLog().logSync();
//TODO: audit log
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
logAuditEvent(UserGroupInformation.getCurrentUser(), getRemoteIp(),
"allowSnapshot", path, null, null);
}
}
// Disallow snapshot on a directory.
@ -5539,6 +5543,11 @@ public void allowSnapshot(String path) throws SafeModeException, IOException {
public void disallowSnapshot(String snapshotRoot)
throws SafeModeException, IOException {
// TODO: implement
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
logAuditEvent(UserGroupInformation.getCurrentUser(), getRemoteIp(),
"disallowSnapshot", snapshotRoot, null, null);
}
}
/**
@ -5552,7 +5561,8 @@ public void createSnapshot(String snapshotName, String path)
try {
checkOperation(OperationCategory.WRITE);
if (isInSafeMode()) {
throw new SafeModeException("Cannot create snapshot for " + path, safeMode);
throw new SafeModeException("Cannot create snapshot for " + path,
safeMode);
}
checkOwner(path);
@ -5568,6 +5578,10 @@ public void createSnapshot(String snapshotName, String path)
}
getEditLog().logSync();
//TODO: audit log
if (auditLog.isInfoEnabled() && isExternalInvocation()) {
Path snapshotRoot = new Path(path, ".snapshot/" + snapshotName);
logAuditEvent(UserGroupInformation.getCurrentUser(), getRemoteIp(),
"createSnapshot", path, snapshotRoot.toString(), null);
}
}
}