You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by sy...@apache.org on 2017/01/07 08:04:45 UTC

[03/16] hbase git commit: HBASE-17390 Added master and backup masters to online update of configuration

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

Signed-off-by: Jerry He <je...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/dba103e1
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/dba103e1
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/dba103e1

Branch: refs/heads/hbase-12439
Commit: dba103e1b6e27330a960513c65af49254d56078b
Parents: 20a7ae2
Author: Jan Hentschel <ja...@ultratendency.com>
Authored: Thu Dec 29 18:55:22 2016 +0100
Committer: Jerry He <je...@apache.org>
Committed: Wed Jan 4 22:08:05 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/dba103e1/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 89d1b49..3c84929 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

http://git-wip-us.apache.org/repos/asf/hbase/blob/dba103e1/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 73e493b..731e02f 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);
+  }
 }