Source:
public void testDynamicMasterConfigurationRefresh() throws Exception { Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); String currentMasterAddrs = Preconditions.checkNotNull(conf.get(HConstants.MASTER_ADDRS_KEY)); HMaster activeMaster = TEST_UTIL.getHBaseCluster().getMaster(); String clusterId = activeMaster.getClusterId(); ServerName badServer = ServerName.valueOf("localhost", 1234, -1); conf.set(HConstants.MASTER_ADDRS_KEY, badServer.toShortString() + "," + currentMasterAddrs); conf.setInt(MasterRegistry.MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY, 4); try (MasterRegistry registry = new MasterRegistry(conf)) { final Set<ServerName> masters = registry.getParsedMasterServers(); assertTrue(masters.contains(badServer)); assertEquals(registry.getClusterId().get(), clusterId); TEST_UTIL.waitFor(5000, (Waiter.Predicate<Exception>) () -> !registry.getParsedMasterServers().equals(masters)); final Set<ServerName> newMasters = registry.getParsedMasterServers(); assertEquals(3, newMasters.size()); assertFalse(newMasters.contains(badServer)); activeMaster.stopMaster(); TEST_UTIL.waitFor(10000, () -> TEST_UTIL.getMiniHBaseCluster().getLiveMasterThreads().size() == 2); assertEquals(registry.getClusterId().get(), clusterId); TEST_UTIL.waitFor(100000, (Waiter.Predicate<Exception>) () -> registry.getParsedMasterServers().size() == 2); final Set<ServerName> newMasters2 = registry.getParsedMasterServers(); assertEquals(2, newMasters2.size()); assertFalse(newMasters2.contains(activeMaster)); } }

Target:
public void testDynamicMasterConfigurationRefresh() throws Exception { Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); String currentMasterAddrs = Preconditions.checkNotNull(conf.get(HConstants.MASTER_ADDRS_KEY)); HMaster activeMaster = TEST_UTIL.getHBaseCluster().getMaster(); String clusterId = activeMaster.getClusterId(); ServerName badServer = ServerName.valueOf("localhost", 1234, -1); conf.set(HConstants.MASTER_ADDRS_KEY, badServer.toShortString() + "," + currentMasterAddrs); conf.setInt(MasterRegistry.MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY, 4); conf.setLong(MasterAddressRefresher.MIN_SECS_BETWEEN_REFRESHES, 0); try (MasterRegistry registry = new MasterRegistry(conf)) { final Set<ServerName> masters = registry.getParsedMasterServers(); assertTrue(masters.contains(badServer)); assertEquals(registry.getClusterId().get(), clusterId); TEST_UTIL.waitFor(5000, (Waiter.Predicate<Exception>) () -> !registry.getParsedMasterServers().equals(masters)); final Set<ServerName> newMasters = registry.getParsedMasterServers(); assertEquals(3, newMasters.size()); assertFalse(newMasters.contains(badServer)); activeMaster.stopMaster(); TEST_UTIL.waitFor(10000, () -> TEST_UTIL.getMiniHBaseCluster().getLiveMasterThreads().size() == 2); TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(10000); TEST_UTIL.waitFor(10000, () -> registry.getMasters().get().size() == 2); TEST_UTIL.waitFor(20000, () -> registry.getParsedMasterServers().size() == 2); final Set<ServerName> newMasters2 = registry.getParsedMasterServers(); assertEquals(2, newMasters2.size()); assertFalse(newMasters2.contains(activeMaster.getServerName())); } finally { TEST_UTIL.getMiniHBaseCluster().startMaster(); } }