From dba103e1b6e27330a960513c65af49254d56078b Mon Sep 17 00:00:00 2001 From: Jan Hentschel Date: Thu, 29 Dec 2016 18:55:22 +0100 Subject: [PATCH] HBASE-17390 Added master and backup masters to online update of configuration Signed-off-by: Jerry He --- .../hadoop/hbase/client/HBaseAdmin.java | 6 +++ .../hbase/client/TestUpdateConfiguration.java | 40 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) 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 89d1b493bb7..3c849295625 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 @@ -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 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 73e493bfb3e..731e02fb627 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.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); + } }