From 42ab6e6247a0177874a013463b88f9265674a3fa Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Wed, 21 Aug 2013 18:18:45 +0000 Subject: [PATCH] svn merge -c 1516237 merging from trunk to branch-2 to fix HDFS-4994. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1516242 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hdfs/server/namenode/FSNamesystem.java | 23 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index bcfb9520b15..c891a91cb97 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -36,6 +36,8 @@ Release 2.3.0 - UNRELEASED HDFS-5068. Convert NNThroughputBenchmark to a Tool to allow generic options. (shv) + HDFS-4994. Audit log getContentSummary() calls. (Robert Parker via kihwal) + OPTIMIZATIONS BUG FIXES 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 7f774d28b73..d6d9ddcc0ce 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 @@ -3398,12 +3398,26 @@ public class FSNamesystem implements Namesystem, FSClusterStats, return true; } - ContentSummary getContentSummary(String src) throws AccessControlException, - FileNotFoundException, UnresolvedLinkException, StandbyException { + /** + * Get the content summary for a specific file/dir. + * + * @param src The string representation of the path to the file + * + * @throws AccessControlException if access is denied + * @throws UnresolvedLinkException if a symlink is encountered. + * @throws FileNotFoundException if no file exists + * @throws StandbyException + * @throws IOException for issues with writing to the audit log + * + * @return object containing information regarding the file + * or null if file not found + */ + ContentSummary getContentSummary(String src) throws IOException { FSPermissionChecker pc = getPermissionChecker(); checkOperation(OperationCategory.READ); byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src); readLock(); + boolean success = true; try { checkOperation(OperationCategory.READ); src = FSDirectory.resolvePath(src, pathComponents, dir); @@ -3411,8 +3425,13 @@ public class FSNamesystem implements Namesystem, FSClusterStats, checkPermission(pc, src, false, null, null, null, FsAction.READ_EXECUTE); } return dir.getContentSummary(src); + + } catch (AccessControlException ace) { + success = false; + throw ace; } finally { readUnlock(); + logAuditEvent(success, "contentSummary", src); } }