HDFS-10438. When NameNode HA is configured to use the lifeline RPC server, it should log the address of that server. Contributed by Chris Nauroth.

(cherry picked from commit 500e946729)
This commit is contained in:
Chris Nauroth 2016-05-20 13:01:43 -07:00
parent d38f2090fa
commit e7b56cf93c
3 changed files with 17 additions and 2 deletions

View File

@ -163,7 +163,7 @@ public class NNHAServiceTarget extends HAServiceTarget {
@Override
public String toString() {
return "NameNode at " + addr;
return "NameNode at " + (lifelineAddr != null ? lifelineAddr : addr);
}
public String getNameServiceId() {

View File

@ -1182,6 +1182,11 @@ public class MiniDFSCluster {
hdfsConf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTPS_ADDRESS_KEY,
nameserviceId, nnId), NetUtils.getHostPortString(nn.getHttpsAddress()));
}
if (hdfsConf.get(DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY) != null) {
hdfsConf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY,
nameserviceId, nnId),
hdfsConf.get(DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY));
}
copyKeys(hdfsConf, conf, nameserviceId, nnId);
DFSUtil.setGenericConf(hdfsConf, nameserviceId, nnId,
DFS_NAMENODE_HTTP_ADDRESS_KEY);

View File

@ -20,7 +20,7 @@ package org.apache.hadoop.hdfs.server.namenode.ha;
import static org.apache.hadoop.fs.CommonConfigurationKeys.HA_HM_RPC_TIMEOUT_DEFAULT;
import static org.apache.hadoop.fs.CommonConfigurationKeys.HA_HM_RPC_TIMEOUT_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import java.io.IOException;
@ -85,6 +85,16 @@ public class TestNNHealthCheck {
NNHAServiceTarget haTarget = new NNHAServiceTarget(conf,
DFSUtil.getNamenodeNameServiceId(conf), "nn1");
final String expectedTargetString;
if (conf.get(DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY + "." +
DFSUtil.getNamenodeNameServiceId(conf) + ".nn1") != null) {
expectedTargetString = haTarget.getHealthMonitorAddress().toString();
} else {
expectedTargetString = haTarget.getAddress().toString();
}
assertTrue("Expected haTarget " + haTarget + " containing " +
expectedTargetString,
haTarget.toString().contains(expectedTargetString));
HAServiceProtocol rpc = haTarget.getHealthMonitorProxy(conf, conf.getInt(
HA_HM_RPC_TIMEOUT_KEY, HA_HM_RPC_TIMEOUT_DEFAULT));