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/16 21:20:26 UTC
svn commit: r1483527 - in /hbase/branches/0.89-fb: bin/reload_rs_config.rb
src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Author: liyin
Date: Thu May 16 19:20:26 2013
New Revision: 1483527
URL: http://svn.apache.org/r1483527
Log:
[HBASE-8544] Added a utility to reload configurations in Region Server
Author: gauravm
Summary: Created a utility to tell the Region Server to reload its configurations from disk. We need to fill in what happens when HRegion::updateConfiguration() and Store::updateConfiguration() are called. Currently it just updates the Configuration object, but we might be interested in updating certain other objects as well.
Test Plan: Unit tests
Reviewers: liyintang, aaiyer, rshroff, manukranthk
Reviewed By: rshroff
CC: hbase-eng@
Differential Revision: https://phabricator.fb.com/D806711
Task ID: 2258346
Added:
hbase/branches/0.89-fb/bin/reload_rs_config.rb
Modified:
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Added: hbase/branches/0.89-fb/bin/reload_rs_config.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/bin/reload_rs_config.rb?rev=1483527&view=auto
==============================================================================
--- hbase/branches/0.89-fb/bin/reload_rs_config.rb (added)
+++ hbase/branches/0.89-fb/bin/reload_rs_config.rb Thu May 16 19:20:26 2013
@@ -0,0 +1,111 @@
+#
+# 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 either the region server running on the
+# current host reload, or make all the region servers reload the configuration.
+#
+# To see usage for this script, run:
+#
+# ${HBASE_HOME}/bin/hbase org.jruby.Main ${HBASE_HOME}/bin/reload_rs_config.rb usage
+#
+include Java
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.hbase.ClusterStatus
+import org.apache.hadoop.hbase.HBaseConfiguration
+import org.apache.hadoop.hbase.HServerInfo
+import org.apache.hadoop.hbase.HServerAddress
+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
+import java.net.InetAddress
+
+# Name of this script
+NAME = "reload_rs_config"
+
+def usage
+ puts 'Usage %s.rb [reloadAll]' % NAME
+ puts 'Use reloadAll to make all the Region Servers reload their configurations'
+ exit!
+end
+
+reloadAll = false
+
+if ARGV.size > 1
+ usage
+elsif ARGV.size == 1
+ if ARGV[0] == 'reloadAll'
+ reloadAll = true
+ else
+ usage
+ end
+end
+
+# 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))
+
+# Get a logger instance.
+LOG = LogFactory.getLog(NAME)
+
+# get the admin interface
+admin = HBaseAdmin.new(c)
+
+hostname = InetAddress.getLocalHost().getHostName()
+port = c.getInt("hbase.regionserver.port", 0)
+
+if reloadAll
+ # get the cluster servers
+ servers = admin.getClusterStatus().getServerInfo()
+
+ servers.each do |server|
+ address = server.getServerAddress()
+ puts "Updating the configuration at host " + address.getHostname()
+ admin.updateConfiguration(address)
+ end
+else
+ if port > 0
+ address = HServerAddress.new(hostname, port)
+ else
+ address = nil
+
+ # get the cluster servers
+ servers = admin.getClusterStatus().getServerInfo()
+
+ servers.each do |server|
+ if server.getServerAddress().getHostname() == InetAddress.getLocalHost().getHostName()
+ address = server.getServerAddress()
+ break
+ end
+ end
+ end
+
+ if address == nil
+ puts "invalid server"
+ exit
+ end
+
+ admin.updateConfiguration(address)
+end
+
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1483527&r1=1483526&r2=1483527&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Thu May 16 19:20:26 2013
@@ -1375,7 +1375,8 @@ public class HBaseAdmin {
updateConfiguration(new HServerAddress(hostNameWithPort));
}
- private void updateConfiguration(HServerAddress address) throws IOException {
+ // Update configuration for region server at this address.
+ public void updateConfiguration(HServerAddress address) throws IOException {
HRegionInterface server = connection.getHRegionConnection(address);
server.updateConfiguration();
}
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1483527&r1=1483526&r2=1483527&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Thu May 16 19:20:26 2013
@@ -3782,7 +3782,11 @@ public class HRegionServer implements HR
return "RS-" + serverInfo.getServerName();
}
+ /**
+ * Reload the configuration from disk.
+ */
public void updateConfiguration() {
+ LOG.info("Reloading the configuration from disk.");
conf.reloadConfiguration();
for (HRegion r : onlineRegions.values()) {
r.updateConfiguration();