From 1c473898aa72b8bc41857b0a4435ca7e271780b5 Mon Sep 17 00:00:00 2001 From: Brahma Reddy Battula Date: Sat, 15 Oct 2016 22:28:33 +0530 Subject: [PATCH] HDFS-11003. Expose XmitsInProgress through DataNodeMXBean. Contributed By Brahma Reddy Battula (cherry picked from commit 5f4ae85bd8a20510948696467873498723b06477) --- .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 5 +++-- .../apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java | 6 ++++++ .../hadoop/hdfs/server/datanode/TestDataNodeMXBean.java | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 79742accbae..c31e5fdbf37 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -2066,8 +2066,9 @@ public class DataNode extends ReconfigurableBase } } } - - int getXmitsInProgress() { + + @Override //DataNodeMXBean + public int getXmitsInProgress() { return xmitsInProgress.get(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java index 6b5428bbe99..d56d8e6c453 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java @@ -93,6 +93,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. */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java index 50d190441e9..57993510db6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java @@ -80,7 +80,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); String bpActorInfo = (String)mbs.getAttribute(mxbeanName, "BPServiceActorInfo"); Assert.assertEquals(datanode.getBPServiceActorInfo(), bpActorInfo);