Browse Source

HDFS-11003. Expose XmitsInProgress through DataNodeMXBean. Contributed By Brahma Reddy Battula

(cherry picked from commit 5f4ae85bd8a20510948696467873498723b06477)
Brahma Reddy Battula 8 years ago
parent
commit
314f09d17e

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -8,6 +8,9 @@ Release 2.7.6 - UNRELEASED
 
   IMPROVEMENTS
 
+    HDFS-11003. Expose XmitsInProgress through DataNodeMXBean.
+    (Brahma Reddy Battula)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -1882,8 +1882,9 @@ public class DataNode extends ReconfigurableBase
       }
     }
   }
-  
-  int getXmitsInProgress() {
+
+  @Override //DataNodeMXBean
+  public int getXmitsInProgress() {
     return xmitsInProgress.get();
   }
 

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

@@ -79,6 +79,12 @@ public interface DataNodeMXBean {
    */
   public int getXceiverCount();
 
+  /**
+   * Returns an estimate of the number of data replication/reconstruction tasks
+   * running currently.
+   */
+  public int getXmitsInProgress();
+
   /**
    * Gets the network error counts on a per-Datanode basis.
    */

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

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