HBASE-17390 Added master and backup masters to online update of configuration

Signed-off-by: Jerry He <jerryjch@apache.org>
This commit is contained in:
Jan Hentschel 2016-12-29 18:55:22 +01:00 committed by Jerry He
parent 20a7ae2865
commit dba103e1b6
2 changed files with 45 additions and 1 deletions

View File

@ -3033,6 +3033,12 @@ public class HBaseAdmin implements Admin {
for (ServerName server : this.getClusterStatus().getServers()) {
updateConfiguration(server);
}
updateConfiguration(this.getClusterStatus().getMaster());
for (ServerName server : this.getClusterStatus().getBackupMasters()) {
updateConfiguration(server);
}
}
@Override

View File

@ -43,7 +43,7 @@ public class TestUpdateConfiguration {
@BeforeClass
public static void setup() throws Exception {
TEST_UTIL.startMiniCluster();
TEST_UTIL.startMiniCluster(2, 1);
}
@Test
@ -74,4 +74,42 @@ public class TestUpdateConfiguration {
// restore hbase-site.xml
Files.copy(cnf3Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
}
@Test
public void testAllOnlineConfigChange() throws IOException {
LOG.debug("Starting the test");
Admin admin = TEST_UTIL.getAdmin();
admin.updateConfiguration();
}
@Test
public void testAllCustomOnlineConfigChange() throws IOException {
LOG.debug("Starting the test");
Path cnfPath = FileSystems.getDefault().getPath("target/test-classes/hbase-site.xml");
Path cnf2Path = FileSystems.getDefault().getPath("target/test-classes/hbase-site2.xml");
Path cnf3Path = FileSystems.getDefault().getPath("target/test-classes/hbase-site3.xml");
// make a backup of hbase-site.xml
Files.copy(cnfPath, cnf3Path, StandardCopyOption.REPLACE_EXISTING);
// update hbase-site.xml by overwriting it
Files.copy(cnf2Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
Admin admin = TEST_UTIL.getAdmin();
admin.updateConfiguration();
// Check the configuration of the Masters
Configuration masterConfiguration = TEST_UTIL.getMiniHBaseCluster().getMaster(0).getConfiguration();
int custom = masterConfiguration.getInt("hbase.custom.config", 0);
assertEquals(custom, 1000);
Configuration backupMasterConfiguration = TEST_UTIL.getMiniHBaseCluster().getMaster(1).getConfiguration();
custom = backupMasterConfiguration.getInt("hbase.custom.config", 0);
assertEquals(custom, 1000);
// Check the configuration of the RegionServer
Configuration regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0).getConfiguration();
custom = regionServerConfiguration.getInt("hbase.custom.config", 0);
assertEquals(custom, 1000);
// restore hbase-site.xml
Files.copy(cnf3Path, cnfPath, StandardCopyOption.REPLACE_EXISTING);
}
}