From ce01f2ab1d1967fc86e934b99f4f815abbf7e9bb Mon Sep 17 00:00:00 2001 From: Harsh J Date: Mon, 6 Feb 2012 05:37:36 +0000 Subject: [PATCH] HDFS-2868. svn merge -c 1240897 from trunk git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1240899 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 6 +----- .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 3 ++- .../apache/hadoop/hdfs/server/datanode/DataNodeMXBean.java | 7 ++++++- .../hadoop/hdfs/server/datanode/TestDataNodeMXBean.java | 5 +++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 7ba0131955f..724d06a27fa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -101,11 +101,7 @@ Release 0.23.1 - UNRELEASED HDFS-2814. NamenodeMXBean does not account for svn revision in the version information. (Hitesh Shah via jitendra) - HDFS-2784. Update hftp and hdfs for host-based token support. - (Kihwal Lee via jitendra) - - HDFS-2785. Update webhdfs and httpfs for host-based token support. - (Robert Joseph Evans via jitendra) + HDFS-2868. Expose xceiver counts via the DataNode MXBean. (harsh) OPTIMIZATIONS 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 007cabace48..abde548346e 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 @@ -1262,7 +1262,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(); } 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 b4f98625c30..8e80c587420 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 @@ -70,5 +70,10 @@ public interface DataNodeMXBean { * @return the cluster id */ public String getClusterId(); - + + /** + * Returns an estimate of the number of Datanode threads + * actively transferring blocks. + */ + public int getXceiverCount(); } 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 eb71d2e65b3..e2954855ea1 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 @@ -65,6 +65,11 @@ public class TestDataNodeMXBean { String volumeInfo = (String)mbs.getAttribute(mxbeanName, "VolumeInfo"); Assert.assertEquals(replaceDigits(datanode.getVolumeInfo()), replaceDigits(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();} }