소스 검색

HDFS-1428. HDFS federation : add cluster ID and block pool ID into Name node web UI

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/branches/HDFS-1052@1003708 13f79535-47bb-0310-9956-ffa450edef68
Boris Shkolnik 15 년 전
부모
커밋
f0d8a5db10

+ 3 - 0
CHANGES.txt

@@ -46,6 +46,9 @@ Trunk (unreleased changes)
     HDFS-1400. HDFS federation: DataTransferProtocol uses ExtendedBlockPool to 
     include BlockPoolID in the protocol. (suresh)
 
+    HDFS-1428. HDFS federation : add cluster ID and block pool ID into 
+    Name node web UI(tanping via boryas)
+
   IMPROVEMENTS
 
     HDFS-1304. Add a new unit test for HftpFileSystem.open(..).  (szetszwo)

+ 6 - 0
src/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -1976,4 +1976,10 @@ public class DataNode extends Configured
     }
     return JSON.toString(info);
   }
+  
+  @Override // DataNodeMXBean
+  public String getClusterId() {
+    return this.storage.clusterID;
+}
+
 }

+ 8 - 0
src/java/org/apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java

@@ -63,4 +63,12 @@ public interface DataNodeMXBean {
    * @return the volume info
    */
   public String getVolumeInfo();
+  
+  /**
+   * Gets the cluster id.
+   * 
+   * @return the cluster id
+   */
+  public String getClusterId();
+  
 }

+ 1 - 0
src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java

@@ -1043,6 +1043,7 @@ public class FSImage extends Storage {
 
     FSNamesystem fsNamesys = getFSNamesystem();
     FSDirectory fsDir = fsNamesys.dir;
+    fsNamesys.setBlockPoolId(this.getBlockPoolID());
 
     //
     // Load in bits

+ 14 - 0
src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -1528,6 +1528,10 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean, FSClusterSt
     return new ExtendedBlock(poolId, blk);
   }
 
+  void setBlockPoolId(String bpid) {
+    poolId = bpid;
+  }
+
   /**
    * The client would like to obtain an additional block for the indicated
    * filename (which is being written-to).  Return an array that consists
@@ -5219,6 +5223,16 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean, FSClusterSt
     return alivenode.getDfsUsed();
   }
 
+  @Override  // NameNodeMXBean
+  public String getClusterId() {
+    return dir.fsImage.getClusterID();
+  }
+  
+  @Override  // NameNodeMXBean
+  public String getBlockpoolId() {
+    return dir.fsImage.getBlockPoolID();
+  }
+  
   public String getPoolId() {
     return poolId;
   }

+ 15 - 0
src/java/org/apache/hadoop/hdfs/server/namenode/NameNodeMXBean.java

@@ -56,6 +56,7 @@ public interface NameNodeMXBean {
    */
   public long getTotal();
   
+  
   /**
    * Gets the safemode status
    * 
@@ -135,4 +136,18 @@ public interface NameNodeMXBean {
    * @return the decommissioning node information
    */
   public String getDecomNodes();
+  
+  /**
+   * Gets the cluster id.
+   * 
+   * @return the cluster id
+   */
+  public String getClusterId();
+  
+  /**
+   * Gets the block pool id.
+   * 
+   * @return the block pool id
+   */
+  public String getBlockpoolId();
 }

+ 6 - 1
src/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java

@@ -132,7 +132,12 @@ class NamenodeJspHelper {
         + "\n  <tr><td id='col1'>Compiled:</td><td>" + VersionInfo.getDate()
         + " by " + VersionInfo.getUser() + " from " + VersionInfo.getBranch()
         + "\n  <tr><td id='col1'>Upgrades:</td><td>"
-        + getUpgradeStatusText(fsn) + "\n</table></div>";
+        + getUpgradeStatusText(fsn) 
+        + "\n  <tr><td id='col1'>Cluster ID:</td><td>" + fsn.getClusterId()
+        + "</td></tr>\n" 
+        + "\n  <tr><td id='col1'>Block Pool ID:</td><td>" + fsn.getBlockpoolId()
+        + "</td></tr>\n" 
+        + "\n</table></div>";
   }
 
   static String getWarningText(FSNamesystem fsn) {

+ 3 - 0
src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java

@@ -44,6 +44,9 @@ public class TestDataNodeMXBean {
 
       MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
       ObjectName mxbeanName = new ObjectName("HadoopInfo:type=DataNodeInfo");
+      // get attribute "ClusterId"
+      String clusterId = (String) mbs.getAttribute(mxbeanName, "ClusterId");
+      Assert.assertEquals(datanode.getClusterId(), clusterId);
       // get attribute "Version"
       String version = (String)mbs.getAttribute(mxbeanName, "Version");
       Assert.assertEquals(datanode.getVersion(),version);

+ 6 - 0
src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java

@@ -46,6 +46,12 @@ public class TestNameNodeMXBean {
 
       MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
       ObjectName mxbeanName = new ObjectName("HadoopInfo:type=NameNodeInfo");
+      // get attribute "ClusterId"
+      String clusterId = (String) mbs.getAttribute(mxbeanName, "ClusterId");
+      Assert.assertEquals(fsn.getClusterId(), clusterId);
+      // get attribute "BlockpoolId"
+      String blockpoolId = (String) mbs.getAttribute(mxbeanName, "BlockpoolId");
+      Assert.assertEquals(fsn.getBlockpoolId(), blockpoolId);
       // get attribute "Version"
       String version = (String) mbs.getAttribute(mxbeanName, "Version");
       Assert.assertEquals(fsn.getVersion(), version);