HDFS-13271. WebHDFS: Add constructor in SnapshottableDirectoryStatus with 
HdfsFileStatus as argument. Contributed by Lokesh Jain


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

Branch: refs/heads/HDFS-7240
Commit: b2b9ce585984a1791a8af3e2287c75c75b95586f
Parents: 0355ec2
Author: Chris Douglas <cdoug...@apache.org>
Authored: Tue Mar 13 09:43:22 2018 -0700
Committer: Chris Douglas <cdoug...@apache.org>
Committed: Tue Mar 13 09:43:22 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hdfs/protocol/HdfsFileStatus.java    | 27 +-------------------
 .../protocol/SnapshottableDirectoryStatus.java  |  8 ++++++
 .../apache/hadoop/hdfs/web/JsonUtilClient.java  | 10 +-------
 3 files changed, 10 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2b9ce58/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
 
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
index cb05c75..264e3f4 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
@@ -50,32 +50,7 @@ public interface HdfsFileStatus
     HAS_ACL,
     HAS_CRYPT,
     HAS_EC,
-    SNAPSHOT_ENABLED;
-
-    /**
-     * Generates an enum set of Flags from a set of attr flags.
-     * @param attr Set of attr flags
-     * @return EnumSet of Flags
-     */
-    public static EnumSet<Flags> convert(Set<AttrFlags> attr) {
-      if (attr.isEmpty()) {
-        return EnumSet.noneOf(Flags.class);
-      }
-      EnumSet<Flags> flags = EnumSet.noneOf(Flags.class);
-      if (attr.contains(AttrFlags.HAS_ACL)) {
-        flags.add(Flags.HAS_ACL);
-      }
-      if (attr.contains(AttrFlags.HAS_EC)) {
-        flags.add(Flags.HAS_EC);
-      }
-      if (attr.contains(AttrFlags.HAS_CRYPT)) {
-        flags.add(Flags.HAS_CRYPT);
-      }
-      if (attr.contains(AttrFlags.SNAPSHOT_ENABLED)) {
-        flags.add(Flags.SNAPSHOT_ENABLED);
-      }
-      return flags;
-    }
+    SNAPSHOT_ENABLED
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2b9ce58/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
 
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
index 6cdb2ee..0d35238 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
@@ -79,6 +79,14 @@ public class SnapshottableDirectoryStatus {
     this.parentFullPath = parentFullPath;
   }
 
+  public SnapshottableDirectoryStatus(HdfsFileStatus dirStatus,
+      int snapshotNumber, int snapshotQuota, byte[] parentFullPath) {
+    this.dirStatus = dirStatus;
+    this.snapshotNumber = snapshotNumber;
+    this.snapshotQuota = snapshotQuota;
+    this.parentFullPath = parentFullPath;
+  }
+
   /**
    * @return Number of snapshots that have been taken for the directory
    */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b2b9ce58/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
 
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
index aa79dc4..13c5226 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java
@@ -65,7 +65,6 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 class JsonUtilClient {
   static final DatanodeInfo[] EMPTY_DATANODE_INFO_ARRAY = {};
@@ -772,15 +771,8 @@ class JsonUtilClient {
     byte[] parentFullPath = toByteArray((String) json.get("parentFullPath"));
     HdfsFileStatus dirStatus =
         toFileStatus((Map<?, ?>) json.get("dirStatus"), false);
-    Set<FileStatus.AttrFlags> attrFlags = FileStatus
-        .attributes(dirStatus.hasAcl(), dirStatus.isEncrypted(),
-            dirStatus.isErasureCoded(), dirStatus.isSnapshotEnabled());
     SnapshottableDirectoryStatus snapshottableDirectoryStatus =
-        new SnapshottableDirectoryStatus(dirStatus.getModificationTime(),
-            dirStatus.getAccessTime(), dirStatus.getPermission(),
-            HdfsFileStatus.Flags.convert(attrFlags), dirStatus.getOwner(),
-            dirStatus.getGroup(), dirStatus.getLocalNameInBytes(),
-            dirStatus.getFileId(), dirStatus.getChildrenNum(), snapshotNumber,
+        new SnapshottableDirectoryStatus(dirStatus, snapshotNumber,
             snapshotQuota, parentFullPath);
     return snapshottableDirectoryStatus;
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to