From 30db1adac31b07b34ce8e8d426cc139fb8cfad02 Mon Sep 17 00:00:00 2001 From: Ming Ma Date: Fri, 4 Sep 2015 11:55:58 -0700 Subject: [PATCH] HDFS-8981. Adding revision to data node jmx getVersion() method. (Siqi Li via mingma) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/datanode/DataNode.java | 15 ++++++++++++--- .../hdfs/server/datanode/DataNodeMXBean.java | 9 ++++++++- .../hdfs/server/datanode/TestDataNodeMXBean.java | 6 ++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5226d33f67d..de4432478df 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -36,6 +36,9 @@ Trunk (Unreleased) HDFS-8895. Remove deprecated BlockStorageLocation APIs. (wang) + HDFS-8981. Adding revision to data node jmx getVersion() method. (Siqi Li + via mingma) + NEW FEATURES HDFS-3125. Add JournalService to enable Journal Daemon. (suresh) 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 e0adc6dee49..f72455db07f 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 @@ -2900,10 +2900,15 @@ public class DataNode extends ReconfigurableBase return NetUtils.createSocketAddr( conf.getTrimmed(DFS_DATANODE_ADDRESS_KEY, DFS_DATANODE_ADDRESS_DEFAULT)); } - + + @Override // DataNodeMXBean + public String getSoftwareVersion() { + return VersionInfo.getVersion(); + } + @Override // DataNodeMXBean public String getVersion() { - return VersionInfo.getVersion(); + return VersionInfo.getVersion() + ", r" + VersionInfo.getRevision(); } @Override // DataNodeMXBean @@ -2917,7 +2922,11 @@ public class DataNode extends ReconfigurableBase public String getHttpPort(){ return this.getConf().get("dfs.datanode.info.port"); } - + + public String getRevision() { + return VersionInfo.getRevision(); + } + /** * @return the datanode's http port */ 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 92abd886fee..0119dc8737e 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 @@ -36,7 +36,14 @@ public interface DataNodeMXBean { * @return the version of Hadoop */ public String getVersion(); - + + /** + * Get the version of software running on the DataNode + * + * @return a string representing the version + */ + public String getSoftwareVersion(); + /** * Gets the rpc port. * 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 b461e3a9f3a..a7d0a5ef7e1 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 @@ -51,6 +51,12 @@ public class TestDataNodeMXBean { // get attribute "Version" String version = (String)mbs.getAttribute(mxbeanName, "Version"); Assert.assertEquals(datanode.getVersion(),version); + // get attribute "SotfwareVersion" + String softwareVersion = + (String)mbs.getAttribute(mxbeanName, "SoftwareVersion"); + Assert.assertEquals(datanode.getSoftwareVersion(),softwareVersion); + Assert.assertEquals(version, softwareVersion + + ", r" + datanode.getRevision()); // get attribute "RpcPort" String rpcPort = (String)mbs.getAttribute(mxbeanName, "RpcPort"); Assert.assertEquals(datanode.getRpcPort(),rpcPort);