From dc12dce20362869feb30f905a26ebab6c09a9b8e Mon Sep 17 00:00:00 2001 From: Vivek Ratnavel Subramanian Date: Mon, 10 Aug 2020 19:37:26 -0700 Subject: [PATCH 1/3] HDFS-15496. Add UI for deleted snapshots --- .../hadoop/hdfs/protocol/SnapshotInfo.java | 39 +++++++++++++++++-- .../namenode/snapshot/SnapshotManager.java | 14 +++++-- .../src/main/webapps/hdfs/dfshealth.html | 10 +++++ 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java index 676e8276f258e..0d7336a1eb8aa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java @@ -82,21 +82,36 @@ public String toString() { } public static class Bean { - private final String snapshotID; + private final int snapshotID; + private final String snapshotName; private final String snapshotDirectory; private final long modificationTime; + private final short permission; + private final String owner; + private final String group; + private final String status; - public Bean(String snapshotID, String snapshotDirectory, - long modificationTime) { + public Bean(int snapshotID, String snapshotName, String snapshotDirectory, + long modificationTime, short permission, String owner, String group, + boolean isMarkedAsDeleted) { this.snapshotID = snapshotID; + this.snapshotName = snapshotName; this.snapshotDirectory = snapshotDirectory; this.modificationTime = modificationTime; + this.permission = permission; + this.owner = owner; + this.group = group; + this.status = isMarkedAsDeleted ? "DELETED" : "ACTIVE"; } - public String getSnapshotID() { + public int getSnapshotID() { return snapshotID; } + public String getSnapshotName() { + return snapshotName; + } + public String getSnapshotDirectory() { return snapshotDirectory; } @@ -104,5 +119,21 @@ public String getSnapshotDirectory() { public long getModificationTime() { return modificationTime; } + + public short getPermission() { + return permission; + } + + public String getOwner() { + return owner; + } + + public String getGroup() { + return group; + } + + public String getStatus() { + return status; + } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java index 7569fc64e6666..a92f6d2d28f6c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java @@ -746,16 +746,22 @@ public static SnapshottableDirectoryStatus.Bean toBean(INodeDirectory d) { d.getDirectorySnapshottableFeature().getNumSnapshots(), d.getDirectorySnapshottableFeature().getSnapshotQuota(), d.getModificationTime(), - Short.valueOf(Integer.toOctalString( - d.getFsPermissionShort())), + Short.parseShort(Integer.toOctalString(d.getFsPermissionShort())), d.getUserName(), d.getGroupName()); } public static SnapshotInfo.Bean toBean(Snapshot s) { + Snapshot.Root dir = s.getRoot(); return new SnapshotInfo.Bean( - s.getRoot().getLocalName(), s.getRoot().getFullPathName(), - s.getRoot().getModificationTime()); + s.getId(), + dir.getLocalName(), dir.getFullPathName(), + dir.getModificationTime(), + Short.parseShort(Integer.toOctalString(dir.getFsPermissionShort())), + dir.getUserName(), + dir.getGroupName(), + dir.isMarkedAsDeleted() + ); } private List getSnapshottableDirsForGc() { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html index fcf4e0d058613..982f421517028 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html @@ -285,15 +285,25 @@ Snapshot ID + Snapshot Name Snapshot Directory Modification Time + Permission + Owner + Group + Status {#Snapshots} {snapshotID} + {snapshotName} {snapshotDirectory} {modificationTime|date_tostring} + {permission|helper_to_permission} + {owner} + {group} + {status} {/Snapshots} From fc9deadcb572c55683b03f61277d0da430b26cd6 Mon Sep 17 00:00:00 2001 From: Vivek Ratnavel Subramanian Date: Tue, 11 Aug 2020 13:54:28 -0700 Subject: [PATCH 2/3] Address review comments --- .../hadoop/hdfs/protocol/SnapshotStatus.java | 54 ------------------- .../hadoop/hdfs/protocol/SnapshotInfo.java | 8 +-- .../namenode/snapshot/SnapshotManager.java | 2 +- .../src/main/webapps/hdfs/dfshealth.html | 2 - 4 files changed, 2 insertions(+), 64 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotStatus.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotStatus.java index 8c0dabd34ad42..3e2a7ae4453b3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotStatus.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotStatus.java @@ -174,60 +174,6 @@ private static int maxLength(int n, Object value) { return Math.max(n, String.valueOf(value).length()); } - /** - * To be used to for collection of snapshot jmx. - */ - public static class Bean { - private final String path; - private final int snapshotID; - private final long modificationTime; - private final short permission; - private final String owner; - private final String group; - private final boolean isDeleted; - - - public Bean(String path, int snapshotID, long - modificationTime, short permission, String owner, String group, - boolean isDeleted) { - this.path = path; - this.snapshotID = snapshotID; - this.modificationTime = modificationTime; - this.permission = permission; - this.owner = owner; - this.group = group; - this.isDeleted = isDeleted; - } - - public String getPath() { - return path; - } - - public int getSnapshotID() { - return snapshotID; - } - - public long getModificationTime() { - return modificationTime; - } - - public short getPermission() { - return permission; - } - - public String getOwner() { - return owner; - } - - public String getGroup() { - return group; - } - - public boolean isDeleted() { - return isDeleted; - } - } - static String getSnapshotPath(String snapshottableDir, String snapshotRelativePath) { String parentFullPathStr = diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java index 0d7336a1eb8aa..12cd46ea84122 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java @@ -83,7 +83,6 @@ public String toString() { public static class Bean { private final int snapshotID; - private final String snapshotName; private final String snapshotDirectory; private final long modificationTime; private final short permission; @@ -91,11 +90,10 @@ public static class Bean { private final String group; private final String status; - public Bean(int snapshotID, String snapshotName, String snapshotDirectory, + public Bean(int snapshotID, String snapshotDirectory, long modificationTime, short permission, String owner, String group, boolean isMarkedAsDeleted) { this.snapshotID = snapshotID; - this.snapshotName = snapshotName; this.snapshotDirectory = snapshotDirectory; this.modificationTime = modificationTime; this.permission = permission; @@ -108,10 +106,6 @@ public int getSnapshotID() { return snapshotID; } - public String getSnapshotName() { - return snapshotName; - } - public String getSnapshotDirectory() { return snapshotDirectory; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java index a92f6d2d28f6c..38f7339f4a957 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java @@ -755,7 +755,7 @@ public static SnapshotInfo.Bean toBean(Snapshot s) { Snapshot.Root dir = s.getRoot(); return new SnapshotInfo.Bean( s.getId(), - dir.getLocalName(), dir.getFullPathName(), + dir.getFullPathName(), dir.getModificationTime(), Short.parseShort(Integer.toOctalString(dir.getFsPermissionShort())), dir.getUserName(), diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html index 982f421517028..e9eb028011004 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html @@ -285,7 +285,6 @@ Snapshot ID - Snapshot Name Snapshot Directory Modification Time Permission @@ -297,7 +296,6 @@ {#Snapshots} {snapshotID} - {snapshotName} {snapshotDirectory} {modificationTime|date_tostring} {permission|helper_to_permission} From 4b63f62fc2452b19df0101042e84fdaeeb7d98db Mon Sep 17 00:00:00 2001 From: Vivek Ratnavel Subramanian Date: Wed, 12 Aug 2020 13:29:25 -0700 Subject: [PATCH 3/3] Address review comments --- .../hadoop/hdfs/protocol/SnapshotInfo.java | 21 +------------------ .../namenode/snapshot/SnapshotManager.java | 3 --- .../src/main/webapps/hdfs/dfshealth.html | 6 ------ 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java index 12cd46ea84122..ef547788f1ac7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java @@ -85,20 +85,13 @@ public static class Bean { private final int snapshotID; private final String snapshotDirectory; private final long modificationTime; - private final short permission; - private final String owner; - private final String group; private final String status; public Bean(int snapshotID, String snapshotDirectory, - long modificationTime, short permission, String owner, String group, - boolean isMarkedAsDeleted) { + long modificationTime, boolean isMarkedAsDeleted) { this.snapshotID = snapshotID; this.snapshotDirectory = snapshotDirectory; this.modificationTime = modificationTime; - this.permission = permission; - this.owner = owner; - this.group = group; this.status = isMarkedAsDeleted ? "DELETED" : "ACTIVE"; } @@ -114,18 +107,6 @@ public long getModificationTime() { return modificationTime; } - public short getPermission() { - return permission; - } - - public String getOwner() { - return owner; - } - - public String getGroup() { - return group; - } - public String getStatus() { return status; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java index 38f7339f4a957..3866125503325 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java @@ -757,9 +757,6 @@ public static SnapshotInfo.Bean toBean(Snapshot s) { s.getId(), dir.getFullPathName(), dir.getModificationTime(), - Short.parseShort(Integer.toOctalString(dir.getFsPermissionShort())), - dir.getUserName(), - dir.getGroupName(), dir.isMarkedAsDeleted() ); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html index e9eb028011004..8b03185d3d1d6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html @@ -287,9 +287,6 @@ Snapshot ID Snapshot Directory Modification Time - Permission - Owner - Group Status @@ -298,9 +295,6 @@ {snapshotID} {snapshotDirectory} {modificationTime|date_tostring} - {permission|helper_to_permission} - {owner} - {group} {status} {/Snapshots}