Browse Source

HDFS-3647. Backport HDFS-2868 (Add number of active transfer threads to the DataNode status) to branch-1. Contributed by Harsh J. (harsh)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1361466 13f79535-47bb-0310-9956-ffa450edef68
Harsh J 13 years ago
parent
commit
dfbd09f533

+ 3 - 0
CHANGES.txt

@@ -38,6 +38,9 @@ Release 1.2.0 - unreleased
     HDFS-2465. Add HDFS support for fadvise readahead and drop-behind.
     (todd via suresh)
 
+    HDFS-3647. Backport HDFS-2868 (Add number of active transfer
+    threads to the DataNode status) to branch-1 (harsh)
+
   BUG FIXES
 
     HADOOP-8460. Document proper setting of HADOOP_PID_DIR and

+ 2 - 1
src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -928,7 +928,8 @@ public class DataNode extends Configured
   }
     
   /** Number of concurrent xceivers per node. */
-  int getXceiverCount() {
+  @Override // DataNodeMXBean
+  public int getXceiverCount() {
     return threadGroup == null ? 0 : threadGroup.activeCount();
   }
     

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

@@ -63,4 +63,10 @@ public interface DataNodeMXBean {
    * @return the volume info
    */
   public String getVolumeInfo();
+
+  /**
+  * Returns an estimate of the number of Datanode threads
+  * actively transferring blocks.
+  */
+  public int getXceiverCount();
 }

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

@@ -64,6 +64,11 @@ public class TestDataNodeMXBean {
       // get attribute "getVolumeInfo"
       String volumeInfo = (String)mbs.getAttribute(mxbeanName, "VolumeInfo");
       Assert.assertEquals(datanode.getVolumeInfo(),volumeInfo);
+      // Ensure mxbean's XceiverCount is same as the DataNode's
+      // live value.
+      int xceiverCount = (Integer)mbs.getAttribute(mxbeanName,
+          "XceiverCount");
+      Assert.assertEquals(datanode.getXceiverCount(), xceiverCount);
     } finally {
       if (cluster != null) {cluster.shutdown();}
     }