HDFS-5683. Better audit log messages for caching operations. Contributed by Abhiraj Butala.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1595057 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Wang 2014-05-15 21:30:22 +00:00
parent 3a9110ac05
commit 81cf200155
2 changed files with 19 additions and 8 deletions

View File

@ -109,6 +109,9 @@ Release 2.5.0 - UNRELEASED
HDFS-6287. Add vecsum test of libhdfs read access times (cmccabe) HDFS-6287. Add vecsum test of libhdfs read access times (cmccabe)
HDFS-5683. Better audit log messages for caching operations.
(Abhiraj Butala via wang)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn) HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn)

View File

@ -7437,6 +7437,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
cacheManager.waitForRescanIfNeeded(); cacheManager.waitForRescanIfNeeded();
} }
writeLock(); writeLock();
String effectiveDirectiveStr = null;
Long result = null; Long result = null;
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
@ -7448,11 +7449,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
throw new IOException("addDirective: you cannot specify an ID " + throw new IOException("addDirective: you cannot specify an ID " +
"for this operation."); "for this operation.");
} }
CacheDirectiveInfo effectiveDirective = CacheDirectiveInfo effectiveDirective =
cacheManager.addDirective(directive, pc, flags); cacheManager.addDirective(directive, pc, flags);
getEditLog().logAddCacheDirectiveInfo(effectiveDirective, getEditLog().logAddCacheDirectiveInfo(effectiveDirective,
cacheEntry != null); cacheEntry != null);
result = effectiveDirective.getId(); result = effectiveDirective.getId();
effectiveDirectiveStr = effectiveDirective.toString();
success = true; success = true;
} finally { } finally {
writeUnlock(); writeUnlock();
@ -7460,7 +7462,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
getEditLog().logSync(); getEditLog().logSync();
} }
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "addCacheDirective", null, null, null); logAuditEvent(success, "addCacheDirective", effectiveDirectiveStr, null, null);
} }
RetryCache.setState(cacheEntry, success, result); RetryCache.setState(cacheEntry, success, result);
} }
@ -7497,7 +7499,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
getEditLog().logSync(); getEditLog().logSync();
} }
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "modifyCacheDirective", null, null, null); String idStr = "{id: " + directive.getId().toString() + "}";
logAuditEvent(success, "modifyCacheDirective", idStr, directive.toString(), null);
} }
RetryCache.setState(cacheEntry, success); RetryCache.setState(cacheEntry, success);
} }
@ -7525,7 +7528,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
} finally { } finally {
writeUnlock(); writeUnlock();
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "removeCacheDirective", null, null, String idStr = "{id: " + id.toString() + "}";
logAuditEvent(success, "removeCacheDirective", idStr, null,
null); null);
} }
RetryCache.setState(cacheEntry, success); RetryCache.setState(cacheEntry, success);
@ -7550,7 +7554,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
} finally { } finally {
readUnlock(); readUnlock();
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "listCacheDirectives", null, null, logAuditEvent(success, "listCacheDirectives", filter.toString(), null,
null); null);
} }
} }
@ -7567,6 +7571,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
} }
writeLock(); writeLock();
boolean success = false; boolean success = false;
String poolInfoStr = null;
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
if (isInSafeMode()) { if (isInSafeMode()) {
@ -7577,12 +7582,13 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
pc.checkSuperuserPrivilege(); pc.checkSuperuserPrivilege();
} }
CachePoolInfo info = cacheManager.addCachePool(req); CachePoolInfo info = cacheManager.addCachePool(req);
poolInfoStr = info.toString();
getEditLog().logAddCachePool(info, cacheEntry != null); getEditLog().logAddCachePool(info, cacheEntry != null);
success = true; success = true;
} finally { } finally {
writeUnlock(); writeUnlock();
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "addCachePool", req.getPoolName(), null, null); logAuditEvent(success, "addCachePool", poolInfoStr, null, null);
} }
RetryCache.setState(cacheEntry, success); RetryCache.setState(cacheEntry, success);
} }
@ -7615,7 +7621,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
} finally { } finally {
writeUnlock(); writeUnlock();
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "modifyCachePool", req.getPoolName(), null, null); String poolNameStr = "{poolName: " + req.getPoolName() + "}";
logAuditEvent(success, "modifyCachePool", poolNameStr, req.toString(), null);
} }
RetryCache.setState(cacheEntry, success); RetryCache.setState(cacheEntry, success);
} }
@ -7648,7 +7655,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
} finally { } finally {
writeUnlock(); writeUnlock();
if (isAuditEnabled() && isExternalInvocation()) { if (isAuditEnabled() && isExternalInvocation()) {
logAuditEvent(success, "removeCachePool", cachePoolName, null, null); String poolNameStr = "{poolName: " + cachePoolName + "}";
logAuditEvent(success, "removeCachePool", poolNameStr, null, null);
} }
RetryCache.setState(cacheEntry, success); RetryCache.setState(cacheEntry, success);
} }