HDFS-14653. RBF: Correct the default value for dfs.federation.router.namenode.heartbeat.enable. Contributed by Ayush Saxena.

This commit is contained in:
Takanobu Asanuma 2019-07-18 10:16:20 +09:00
parent 5e6cc6fe8a
commit 9792f58662
2 changed files with 29 additions and 1 deletions

View File

@ -383,7 +383,7 @@
<property>
<name>dfs.federation.router.namenode.heartbeat.enable</name>
<value>true</value>
<value></value>
<description>
If true, get namenode heartbeats and send into the State Store.
If not explicitly specified takes the same value as for

View File

@ -33,6 +33,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
import org.apache.hadoop.hdfs.server.federation.MockResolver;
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
@ -260,4 +261,31 @@ public class TestRouter {
router.close();
}
@Test
public void testNamenodeHeartBeatEnableDefault() throws IOException {
checkNamenodeHeartBeatEnableDefault(true);
checkNamenodeHeartBeatEnableDefault(false);
}
/**
* Check the default value of dfs.federation.router.namenode.heartbeat.enable
* when it isn't explicitly defined.
* @param enable value for dfs.federation.router.heartbeat.enable.
*/
private void checkNamenodeHeartBeatEnableDefault(boolean enable)
throws IOException {
final Router router = new Router();
try {
Configuration config = new HdfsConfiguration();
config.setBoolean(RBFConfigKeys.DFS_ROUTER_HEARTBEAT_ENABLE, enable);
router.init(config);
if (enable) {
assertNotNull(router.getNamenodeHeartbeatServices());
} else {
assertNull(router.getNamenodeHeartbeatServices());
}
} finally {
router.close();
}
}
}