You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2013/05/22 20:18:20 UTC

svn commit: r1485319 - in /hbase/branches/0.89-fb: bin/reload_master_config.rb src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Author: liyin
Date: Wed May 22 18:18:20 2013
New Revision: 1485319

URL: http://svn.apache.org/r1485319
Log:
[HBASE-8587] Added a utility to make the HMaster reload its configuration from disk

Author: gauravm

Summary:
We have the ability to make the RegionServers reload their configurations, this diff will allow us to make the HMaster also reload its configuration.

The next step would involve making all the relevant classes observers and implementing their notifyOnChange() methods.

Test Plan: Unit Tests

Reviewers: liyintang, rshroff, manukranthk, adela, shaneh, aaiyer

Reviewed By: aaiyer

CC: hbase-eng@

Differential Revision: https://phabricator.fb.com/D820099

Task ID: 2258346

Added:
    hbase/branches/0.89-fb/bin/reload_master_config.rb
Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Added: hbase/branches/0.89-fb/bin/reload_master_config.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/bin/reload_master_config.rb?rev=1485319&view=auto
==============================================================================
--- hbase/branches/0.89-fb/bin/reload_master_config.rb (added)
+++ hbase/branches/0.89-fb/bin/reload_master_config.rb Wed May 22 18:18:20 2013
@@ -0,0 +1,57 @@
+#
+# Copyright 2013 The Apache Software Foundation
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This script can be used to make the HMaster reload its configuration 
+# from disk.
+#
+# To run this script, do:
+#  ${HBASE_HOME}/bin/hbase org.jruby.Main ${HBASE_HOME}/bin/reload_master_config.rb 
+#
+include Java
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.hbase.HBaseConfiguration
+import org.apache.hadoop.hbase.client.HBaseAdmin
+import org.apache.hadoop.hbase.util.Bytes
+import org.apache.hadoop.hbase.HConstants
+import org.apache.commons.logging.LogFactory
+
+# Get configuration to use.
+c = HBaseConfiguration.create()
+
+# Taken from add_table.rb script
+# Set hadoop filesystem configuration using the hbase.rootdir.
+# Otherwise, we'll always use localhost though the hbase.rootdir
+# might be pointing at hdfs location.
+c.set("fs.default.name", c.get(HConstants::HBASE_DIR))
+
+NAME = 'reload_master_config.rb'
+
+# Get a logger instance.
+LOG = LogFactory.getLog(NAME)
+
+# Get the admin interface
+admin = HBaseAdmin.new(c)
+
+# Get the HMaster
+master = admin.getMaster()
+
+# Make the HMaster update its configuration
+master.updateConfiguration()
+LOG.info("Asked the master to update its configuration by reloading it from disk.");
+

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java?rev=1485319&r1=1485318&r2=1485319&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java Wed May 22 18:18:20 2013
@@ -213,4 +213,9 @@ public interface HMasterInterface extend
    * @return true if the server is blacklist, else false.
    */
   public boolean isServerBlackListed(String hostAndPort);
+
+  /**
+   * Update the configuration from disk.
+   */
+  public void updateConfiguration();
 }

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1485319&r1=1485318&r2=1485319&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Wed May 22 18:18:20 2013
@@ -87,6 +87,7 @@ import org.apache.hadoop.hbase.client.Re
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.ServerConnection;
 import org.apache.hadoop.hbase.client.ServerConnectionManager;
+import org.apache.hadoop.hbase.conf.ConfigurationManager;
 import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
 import org.apache.hadoop.hbase.executor.HBaseExecutorService;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -252,6 +253,9 @@ public class HMaster extends HasThread i
   private ZKClusterStateRecovery clusterStateRecovery;
   
   private AtomicBoolean isLoadBalancerDisabled = new AtomicBoolean(false);
+
+  private ConfigurationManager configurationManager =
+      new ConfigurationManager();
   
   /**
    * Constructor
@@ -2346,5 +2350,12 @@ public class HMaster extends HasThread i
   public boolean isServerBlackListed(final String hostAndPort) {
     return ServerManager.isServerBlackListed(hostAndPort);
   }
+
+  @Override
+  public void updateConfiguration() {
+    LOG.info("Reloading the configuration from disk.");
+    conf.reloadConfiguration();
+    configurationManager.notifyAllObservers(conf);
+  }
 }