hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asur...@apache.org
Subject hadoop git commit: HDFS-8091: ACLStatus and XAttributes should be presented to INodeAttributesProvider before returning to client (asuresh)
Date Thu, 09 Apr 2015 20:13:51 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 1ff3fd33e -> c846e84d5


HDFS-8091: ACLStatus and XAttributes should be presented to INodeAttributesProvider before
returning to client (asuresh)

(cherry picked from commit 922b7ed21d1f1460263ca42f709bb9f415d189c5)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c846e84d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c846e84d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c846e84d

Branch: refs/heads/branch-2
Commit: c846e84d55d677d2f8294298fd69a9a43d2d9d85
Parents: 1ff3fd3
Author: Arun Suresh <asuresh@apache.org>
Authored: Thu Apr 9 12:28:44 2015 -0700
Committer: Arun Suresh <asuresh@apache.org>
Committed: Thu Apr 9 13:13:23 2015 -0700

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 ++
 .../hadoop/hdfs/server/namenode/AclStorage.java | 11 ++++++
 .../hadoop/hdfs/server/namenode/FSDirAclOp.java |  3 +-
 .../hdfs/server/namenode/FSDirXAttrOp.java      |  3 +-
 .../hdfs/server/namenode/XAttrStorage.java      |  6 ++--
 .../namenode/TestINodeAttributeProvider.java    | 36 ++++++++++++++++----
 6 files changed, 50 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c846e84d/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 2b1acf5..e3f6372 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -101,6 +101,9 @@ Release 2.8.0 - UNRELEASED
 
   BUG FIXES
 
+    HDFS-8091: ACLStatus and XAttributes should be presented to
+    INodeAttributesProvider before returning to client (asuresh)
+
     HDFS-7501. TransactionsSinceLastCheckpoint can be negative on SBNs.
     (Gautam Gopalakrishnan via harsh)
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c846e84d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclStorage.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclStorage.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclStorage.java
index 4f6ce3a..abd3755 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclStorage.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclStorage.java
@@ -163,6 +163,17 @@ public final class AclStorage {
   }
 
   /**
+   * Reads the existing extended ACL entries of an INodeAttribute object.
+   *
+   * @param inodeAttr INode to read
+   * @return List<AclEntry> containing extended inode ACL entries
+   */
+  public static List<AclEntry> readINodeAcl(INodeAttributes inodeAttr) {
+    AclFeature f = inodeAttr.getAclFeature();
+    return getEntriesFromAclFeature(f);
+  }
+
+  /**
    * Build list of AclEntries from the AclFeature
    * @param aclFeature AclFeature
    * @return List of entries

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c846e84d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java
index dff1c2e..0c572b5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAclOp.java
@@ -172,7 +172,8 @@ class FSDirAclOp {
       }
       INode inode = FSDirectory.resolveLastINode(iip);
       int snapshotId = iip.getPathSnapshotId();
-      List<AclEntry> acl = AclStorage.readINodeAcl(inode, snapshotId);
+      List<AclEntry> acl = AclStorage.readINodeAcl(fsd.getAttributes(src,
+              inode.getLocalNameBytes(), inode, snapshotId));
       FsPermission fsPermission = inode.getFsPermission(snapshotId);
       return new AclStatus.Builder()
           .owner(inode.getUserName()).group(inode.getGroupName())

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c846e84d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
index d5c9124..53b9b41 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java
@@ -451,7 +451,8 @@ class FSDirXAttrOp {
       INodesInPath iip = fsd.getINodesInPath(srcs, true);
       INode inode = FSDirectory.resolveLastINode(iip);
       int snapshotId = iip.getPathSnapshotId();
-      return XAttrStorage.readINodeXAttrs(inode, snapshotId);
+      return XAttrStorage.readINodeXAttrs(fsd.getAttributes(src,
+              inode.getLocalNameBytes(), inode, snapshotId));
     } finally {
       fsd.readUnlock();
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c846e84d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/XAttrStorage.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/XAttrStorage.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/XAttrStorage.java
index 7e843d2..e38648d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/XAttrStorage.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/XAttrStorage.java
@@ -57,11 +57,11 @@ public class XAttrStorage {
    * <p/>
    * Must be called while holding the FSDirectory read lock.
    *
-   * @param inode INode to read.
+   * @param inodeAttr INodeAttributes to read.
    * @return List<XAttr> <code>XAttr</code> list.
    */
-  public static List<XAttr> readINodeXAttrs(INode inode) {
-    XAttrFeature f = inode.getXAttrFeature();
+  public static List<XAttr> readINodeXAttrs(INodeAttributes inodeAttr) {
+    XAttrFeature f = inodeAttr.getXAttrFeature();
     return f == null ? ImmutableList.<XAttr> of() : f.getXAttrs();
   }
   

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c846e84d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java
index 111c67c..c5f428b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java
@@ -20,16 +20,16 @@ package org.apache.hadoop.hdfs.server.namenode;
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
+import com.google.common.collect.ImmutableList;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.permission.AclEntry;
-import org.apache.hadoop.fs.permission.AclEntryType;
-import org.apache.hadoop.fs.permission.FsAction;
-import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.fs.XAttr;
+import org.apache.hadoop.fs.permission.*;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.hdfs.HdfsConfiguration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -131,7 +131,17 @@ public class TestINodeAttributeProvider {
 
         @Override
         public XAttrFeature getXAttrFeature() {
-          return (useDefault) ? inode.getXAttrFeature() : null;
+          XAttrFeature x;
+          if (useDefault) {
+            x = inode.getXAttrFeature();
+          } else {
+            x = new XAttrFeature(ImmutableList.copyOf(
+                    Lists.newArrayList(
+                            new XAttr.Builder().setName("test")
+                                    .setValue(new byte[] {1, 2})
+                                    .build())));
+          }
+          return x;
         }
 
         @Override
@@ -218,12 +228,24 @@ public class TestINodeAttributeProvider {
     FileStatus status = fs.getFileStatus(new Path("/user/xxx"));
     Assert.assertEquals(System.getProperty("user.name"), status.getOwner());
     Assert.assertEquals("supergroup", status.getGroup());
-    Assert.assertEquals(new FsPermission((short)0755), status.getPermission());
+    Assert.assertEquals(new FsPermission((short) 0755), status.getPermission());
     fs.mkdirs(new Path("/user/authz"));
-    status = fs.getFileStatus(new Path("/user/authz"));
+    Path p = new Path("/user/authz");
+    status = fs.getFileStatus(p);
     Assert.assertEquals("foo", status.getOwner());
     Assert.assertEquals("bar", status.getGroup());
     Assert.assertEquals(new FsPermission((short) 0770), status.getPermission());
+    AclStatus aclStatus = fs.getAclStatus(p);
+    Assert.assertEquals(1, aclStatus.getEntries().size());
+    Assert.assertEquals(AclEntryType.GROUP, aclStatus.getEntries().get(0)
+            .getType());
+    Assert.assertEquals("xxx", aclStatus.getEntries().get(0)
+            .getName());
+    Assert.assertEquals(FsAction.ALL, aclStatus.getEntries().get(0)
+            .getPermission());
+    Map<String, byte[]> xAttrs = fs.getXAttrs(p);
+    Assert.assertTrue(xAttrs.containsKey("user.test"));
+    Assert.assertEquals(2, xAttrs.get("user.test").length);
   }
 
 }


Mime
View raw message