HDFS-8981. Adding revision to data node jmx getVersion() method. (Siqi Li via mingma)

This commit is contained in:
Ming Ma 2015-09-04 11:55:58 -07:00
parent 715b9c6499
commit 30db1adac3
4 changed files with 29 additions and 4 deletions

View File

@ -36,6 +36,9 @@ Trunk (Unreleased)
HDFS-8895. Remove deprecated BlockStorageLocation APIs. (wang) HDFS-8895. Remove deprecated BlockStorageLocation APIs. (wang)
HDFS-8981. Adding revision to data node jmx getVersion() method. (Siqi Li
via mingma)
NEW FEATURES NEW FEATURES
HDFS-3125. Add JournalService to enable Journal Daemon. (suresh) HDFS-3125. Add JournalService to enable Journal Daemon. (suresh)

View File

@ -2900,10 +2900,15 @@ public class DataNode extends ReconfigurableBase
return NetUtils.createSocketAddr( return NetUtils.createSocketAddr(
conf.getTrimmed(DFS_DATANODE_ADDRESS_KEY, DFS_DATANODE_ADDRESS_DEFAULT)); conf.getTrimmed(DFS_DATANODE_ADDRESS_KEY, DFS_DATANODE_ADDRESS_DEFAULT));
} }
@Override // DataNodeMXBean
public String getSoftwareVersion() {
return VersionInfo.getVersion();
}
@Override // DataNodeMXBean @Override // DataNodeMXBean
public String getVersion() { public String getVersion() {
return VersionInfo.getVersion(); return VersionInfo.getVersion() + ", r" + VersionInfo.getRevision();
} }
@Override // DataNodeMXBean @Override // DataNodeMXBean
@ -2917,7 +2922,11 @@ public class DataNode extends ReconfigurableBase
public String getHttpPort(){ public String getHttpPort(){
return this.getConf().get("dfs.datanode.info.port"); return this.getConf().get("dfs.datanode.info.port");
} }
public String getRevision() {
return VersionInfo.getRevision();
}
/** /**
* @return the datanode's http port * @return the datanode's http port
*/ */

View File

@ -36,7 +36,14 @@ public interface DataNodeMXBean {
* @return the version of Hadoop * @return the version of Hadoop
*/ */
public String getVersion(); 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. * Gets the rpc port.
* *

View File

@ -51,6 +51,12 @@ public class TestDataNodeMXBean {
// get attribute "Version" // get attribute "Version"
String version = (String)mbs.getAttribute(mxbeanName, "Version"); String version = (String)mbs.getAttribute(mxbeanName, "Version");
Assert.assertEquals(datanode.getVersion(),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" // get attribute "RpcPort"
String rpcPort = (String)mbs.getAttribute(mxbeanName, "RpcPort"); String rpcPort = (String)mbs.getAttribute(mxbeanName, "RpcPort");
Assert.assertEquals(datanode.getRpcPort(),rpcPort); Assert.assertEquals(datanode.getRpcPort(),rpcPort);