Repository: hbase Updated Branches: refs/heads/branch-1 db410ea7c -> a9bac6a49
HBASE-17390 Added master and backup masters to online update of configuration Signed-off-by: Jerry He <jerry...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a9bac6a4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a9bac6a4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a9bac6a4 Branch: refs/heads/branch-1 Commit: a9bac6a496f051ac47ce017ba588ada92d6c57c3 Parents: db410ea Author: Jan Hentschel <jan.hentsc...@ultratendency.com> Authored: Thu Dec 29 18:55:22 2016 +0100 Committer: Jerry He <jerry...@apache.org> Committed: Wed Jan 4 22:25:22 2017 -0800 ---------------------------------------------------------------------- .../apache/hadoop/hbase/client/HBaseAdmin.java | 6 +++ .../hbase/client/TestUpdateConfiguration.java | 40 +++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/a9bac6a4/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index a963921..cbc83dc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -4491,6 +4491,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 http://git-wip-us.apache.org/repos/asf/hbase/blob/a9bac6a4/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java index e2af1ab..226c9e7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestUpdateConfiguration.java @@ -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.getHBaseAdmin(); + 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.getHBaseAdmin(); + 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); + } }