hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whe...@apache.org
Subject svn commit: r1582849 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/org/apache/hadoop/hdfs/protocol/ src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/ src/main/webapps/hdfs/ src/test/java/org/apache...
Date Fri, 28 Mar 2014 18:11:58 GMT
Author: wheat9
Date: Fri Mar 28 18:11:57 2014
New Revision: 1582849

URL: http://svn.apache.org/r1582849
Log:
HDFS-6156. Merge r1582847 from trunk.

Modified:
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotStatsMXBean.java
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotStatsMXBean.java

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Mar 28
18:11:57 2014
@@ -41,6 +41,9 @@ Release 2.5.0 - UNRELEASED
     HDFS-6162. Format strings should use platform independent line separator.
     (suresh)
 
+    HDFS-6156. Simplify the JMX API that provides snapshot information.
+    (wheat9)
+
 Release 2.4.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshotInfo.java
Fri Mar 28 18:11:57 2014
@@ -86,10 +86,11 @@ public class SnapshotInfo {
     private final String snapshotDirectory;
     private final long modificationTime;
 
-    public Bean(Snapshot s) {
-      this.snapshotID = s.getRoot().getLocalName();
-      this.snapshotDirectory = s.getRoot().getFullPathName();
-      this.modificationTime = s.getRoot().getModificationTime();
+    public Bean(String snapshotID, String snapshotDirectory,
+        long modificationTime) {
+      this.snapshotID = snapshotID;
+      this.snapshotDirectory = snapshotDirectory;
+      this.modificationTime = modificationTime;
     }
 
     public String getSnapshotID() {

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/SnapshottableDirectoryStatus.java
Fri Mar 28 18:11:57 2014
@@ -176,16 +176,15 @@ public class SnapshottableDirectoryStatu
     private final String owner;
     private final String group;
 
-    public Bean(SnapshottableDirectoryStatus s) {
-      this.path = s.getFullPath().toString();
-      this.snapshotNumber = s.getSnapshotNumber();
-      this.snapshotQuota = s.getSnapshotQuota();
-      this.modificationTime = s.getDirStatus().getModificationTime();
-      this.permission =
-          Short.valueOf(Integer.toOctalString(
-              s.getDirStatus().getPermission().toShort()));
-      this.owner = s.getDirStatus().getOwner();
-      this.group = s.getDirStatus().getGroup();
+    public Bean(String path, int snapshotNumber, int snapshotQuota,
+        long modificationTime, short permission, String owner, String group) {
+      this.path = path;
+      this.snapshotNumber = snapshotNumber;
+      this.snapshotQuota = snapshotQuota;
+      this.modificationTime = modificationTime;
+      this.permission = permission;
+      this.owner = owner;
+      this.group = group;
     }
 
     public String getPath() {

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java
Fri Mar 28 18:11:57 2014
@@ -387,44 +387,43 @@ public class SnapshotManager implements 
   }
 
   @Override // SnapshotStatsMXBean
-  public SnapshotDirectoryMXBean getSnapshotStats() {
-    SnapshottableDirectoryStatus[] stats = getSnapshottableDirListing(null);
-    if (stats == null) {
-      return null;
-    }
-    return new SnapshotDirectoryMXBean(stats);
-  }
-
-  public class SnapshotDirectoryMXBean {
-    private List<SnapshottableDirectoryStatus.Bean> directory =
+  public SnapshottableDirectoryStatus.Bean[]
+    getSnapshottableDirectories() {
+    List<SnapshottableDirectoryStatus.Bean> beans =
         new ArrayList<SnapshottableDirectoryStatus.Bean>();
-    private List<SnapshotInfo.Bean> snapshots =
-        new ArrayList<SnapshotInfo.Bean>();
-
-    public SnapshotDirectoryMXBean(SnapshottableDirectoryStatus[] stats) {
-      set(stats);
+    for (INodeDirectorySnapshottable d : getSnapshottableDirs()) {
+      beans.add(toBean(d));
     }
+    return beans.toArray(new SnapshottableDirectoryStatus.Bean[beans.size()]);
+  }
 
-    public void set(SnapshottableDirectoryStatus[] stats) {
-      for (SnapshottableDirectoryStatus s : stats) {
-        directory.add(new SnapshottableDirectoryStatus.Bean(s));
-        try {
-          for (Snapshot shot : getSnapshottableRoot(
-              s.getFullPath().toString()).getSnapshotList()) {
-            snapshots.add(new SnapshotInfo.Bean(shot));
-          }
-        } catch (IOException e) {
-          continue;
-        }
+  @Override // SnapshotStatsMXBean
+  public SnapshotInfo.Bean[] getSnapshots() {
+    List<SnapshotInfo.Bean> beans = new ArrayList<SnapshotInfo.Bean>();
+    for (INodeDirectorySnapshottable d : getSnapshottableDirs()) {
+      for (Snapshot s : d.getSnapshotList()) {
+        beans.add(toBean(s));
       }
     }
+    return beans.toArray(new SnapshotInfo.Bean[beans.size()]);
+  }
 
-    public List<SnapshottableDirectoryStatus.Bean> getDirectory() {
-      return directory;
-    }
+  public static SnapshottableDirectoryStatus.Bean toBean(
+      INodeDirectorySnapshottable d) {
+    return new SnapshottableDirectoryStatus.Bean(
+        d.getFullPathName(),
+        d.getNumSnapshots(),
+        d.getSnapshotQuota(),
+        d.getModificationTime(),
+        Short.valueOf(Integer.toOctalString(
+            d.getFsPermissionShort())),
+        d.getUserName(),
+        d.getGroupName());
+  }
 
-    public List<SnapshotInfo.Bean> getSnapshots() {
-      return snapshots;
-    }
+  public static SnapshotInfo.Bean toBean(Snapshot s) {
+    return new SnapshotInfo.Bean(
+        s.getRoot().getLocalName(), s.getRoot().getFullPathName(),
+        s.getRoot().getModificationTime());
   }
 }

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotStatsMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotStatsMXBean.java?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotStatsMXBean.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotStatsMXBean.java
Fri Mar 28 18:11:57 2014
@@ -17,7 +17,8 @@
  */
 package org.apache.hadoop.hdfs.server.namenode.snapshot;
 
-import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotManager.SnapshotDirectoryMXBean;
+import org.apache.hadoop.hdfs.protocol.SnapshotInfo;
+import org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus;
 
 /**
  * This is an interface used to retrieve statistic information related to
@@ -30,5 +31,13 @@ public interface SnapshotStatsMXBean {
    *
    * @return the list of snapshottable directories
    */
-  public SnapshotDirectoryMXBean getSnapshotStats();
+  public SnapshottableDirectoryStatus.Bean[] getSnapshottableDirectories();
+
+  /**
+   * Return the list of snapshots
+   *
+   * @return the list of snapshots
+   */
+  public SnapshotInfo.Bean[] getSnapshots();
+
 }

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
Fri Mar 28 18:11:57 2014
@@ -189,7 +189,7 @@
 
 <script type="text/x-dust-template" id="tmpl-snapshot">
 <div class="page-header"><h1>Snapshot Summary</h1></div>
-<div class="page-header"><h1><small>Snapshottable directories: {@size key=SnapshotStats.directory}{/size}</small></div>
+<div class="page-header"><h1><small>Snapshottable directories: {@size key=SnapshottableDirectories}{/size}</small></div>
 <small>
 <table class="table">
   <thead>
@@ -203,7 +203,7 @@
       <th>Group</th>
     </tr>
   </thead>
-  {#SnapshotStats.directory}
+  {#SnapshottableDirectories}
   <tr>
     <td>{path}</td>
     <td>{snapshotNumber}</td>
@@ -213,11 +213,11 @@
     <td>{owner}</td>
     <td>{group}</td>
   </tr>
-  {/SnapshotStats.directory}
+  {/SnapshottableDirectories}
 </table>
 </small>
 
-<div class="page-header"><h1><small>Snapshotted directories: {@size key=SnapshotStats.snapshots}{/size}</small></div>
+<div class="page-header"><h1><small>Snapshotted directories: {@size key=Snapshots}{/size}</small></div>
 
 <small>
 <table class="table">
@@ -228,13 +228,13 @@
       <th>Modification Time</th>
     </tr>
   </thead>
-  {#SnapshotStats.snapshots}
+  {#Snapshots}
   <tr>
     <td>{snapshotID}</td>
     <td>{snapshotDirectory}</td>
     <td>{modificationTime|date_tostring}</td>
   </tr>
-  {/SnapshotStats.snapshots}
+  {/Snapshots}
 </table>
 </small>
 </script>

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotStatsMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotStatsMXBean.java?rev=1582849&r1=1582848&r2=1582849&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotStatsMXBean.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotStatsMXBean.java
Fri Mar 28 18:11:57 2014
@@ -59,17 +59,20 @@ public class TestSnapshotStatsMXBean {
       ObjectName mxbeanName = new ObjectName(
           "Hadoop:service=NameNode,name=SnapshotInfo");
 
-      CompositeData statsbean =
-          (CompositeData) mbs.getAttribute(mxbeanName, "SnapshotStats");
-      int numDirectories = Array.getLength(statsbean.get("directory"));
+      CompositeData[] directories =
+          (CompositeData[]) mbs.getAttribute(
+              mxbeanName, "SnapshottableDirectories");
+      int numDirectories = Array.getLength(directories);
       assertEquals(sm.getNumSnapshottableDirs(), numDirectories);
-      int numSnapshots = Array.getLength(statsbean.get("snapshots"));
+      CompositeData[] snapshots =
+          (CompositeData[]) mbs.getAttribute(mxbeanName, "Snapshots");
+      int numSnapshots = Array.getLength(snapshots);
       assertEquals(sm.getNumSnapshots(), numSnapshots);
 
-      CompositeData directory = (CompositeData) Array.get(statsbean.get("directory"), 0);
-      CompositeData snapshots = (CompositeData) Array.get(statsbean.get("snapshots"), 0);
-      assertTrue(((String) directory.get("path")).contains(pathName));
-      assertTrue(((String) snapshots.get("snapshotDirectory")).contains(pathName));
+      CompositeData d = (CompositeData) Array.get(directories, 0);
+      CompositeData s = (CompositeData) Array.get(snapshots, 0);
+      assertTrue(((String) d.get("path")).contains(pathName));
+      assertTrue(((String) s.get("snapshotDirectory")).contains(pathName));
     } finally {
       if (cluster != null) {
         cluster.shutdown();



Mime
View raw message