hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbau...@apache.org
Subject svn commit: r1378330 - in /hbase/branches/0.89-fb/src/main: java/org/apache/hadoop/hbase/ java/org/apache/hadoop/hbase/client/ java/org/apache/hadoop/hbase/ipc/ java/org/apache/hadoop/hbase/master/ resources/hbase-webapps/master/ ruby/ ruby/hbase/ ruby...
Date Tue, 28 Aug 2012 20:51:57 GMT
Author: mbautin
Date: Tue Aug 28 20:51:57 2012
New Revision: 1378330

URL: http://svn.apache.org/viewvc?rev=1378330&view=rev
Log:
[master] Disable/Enable the load balancer from hbase shell

Author: liyintang

Summary:
Disable/Enable the load balancer from hbase shell
For example:
./bin/hbase shell
hbase(main):001:0> enable_loadbalancer
LoadBalacner disabled: false

hbase(main):002:0> disable_loadbalancer
LoadBalacner disabled: true

hbase(main):003:0> get_loadbalancer
LoadBalacner disabled: true

Test Plan: tested on dev cluster

Reviewers: kannan

Reviewed By: kannan

CC: hbase-eng@, hbase-ops@lists, paultuckfield

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

Added:
    hbase/branches/0.89-fb/src/main/ruby/shell/commands/disable_loadbalancer.rb
    hbase/branches/0.89-fb/src/main/ruby/shell/commands/enable_loadbalancer.rb
    hbase/branches/0.89-fb/src/main/ruby/shell/commands/get_loadbalancer.rb
Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java
    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/ipc/HMasterInterface.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java
    hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp
    hbase/branches/0.89-fb/src/main/ruby/hbase/admin.rb
    hbase/branches/0.89-fb/src/main/ruby/shell.rb

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java?rev=1378330&r1=1378329&r2=1378330&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HBaseConfiguration.java Tue
Aug 28 20:51:57 2012
@@ -75,7 +75,6 @@ public class HBaseConfiguration extends 
     Configuration conf = new Configuration();
     return addHbaseResources(conf);
   }
-
   /**
    * Creates a clone of passed configuration.
    * @param that Configuration to clone.

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=1378330&r1=1378329&r2=1378330&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 Tue
Aug 28 20:51:57 2012
@@ -90,6 +90,27 @@ public class HBaseAdmin {
     this.master = connection.getMaster();
   }
 
+  public void enableLoadBalancer() throws MasterNotRunningException {
+    if (this.master == null) {
+      throw new MasterNotRunningException("master has been shut down");
+    }
+    master.enableLoadBalancer();
+  }
+  
+  public void disableLoadBalancer() throws MasterNotRunningException {
+    if (this.master == null) {
+      throw new MasterNotRunningException("master has been shut down");
+    }
+    this.master.disableLoadBalancer();
+  }
+  
+  public boolean isLoadBalancerDisabled() throws MasterNotRunningException {
+    if (this.master == null) {
+      throw new MasterNotRunningException("master has been shut down");
+    }
+    return this.master.isLoadBalancerDisabled();
+  }
+  
   /** @return HConnection used by this object. */
   public HConnection getConnection() {
     return connection;

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=1378330&r1=1378329&r2=1378330&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
Tue Aug 28 20:51:57 2012
@@ -163,4 +163,10 @@ public interface HMasterInterface extend
    */
   public Pair<Integer, Integer> getAlterStatus(byte[] tableName)
       throws IOException;
+  
+  public void enableLoadBalancer();
+  
+  public void disableLoadBalancer();
+  
+  public boolean isLoadBalancerDisabled();
 }

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=1378330&r1=1378329&r2=1378330&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 Tue Aug
28 20:51:57 2012
@@ -251,7 +251,9 @@ public class HMaster extends HasThread i
   private String stopReason = "not stopping";
 
   private ZKClusterStateRecovery clusterStateRecovery;
-
+  
+  private AtomicBoolean isLoadBalancerDisabled = new AtomicBoolean(false);
+  
   /**
    * Constructor
    * @param conf configuration
@@ -385,6 +387,20 @@ public class HMaster extends HasThread i
       tableLockManager = null;
     }
   }
+  
+  public void enableLoadBalancer() {
+    this.isLoadBalancerDisabled.set(false);
+    LOG.info("Enable the load balancer");
+  }
+  
+  public void disableLoadBalancer() {
+    this.isLoadBalancerDisabled.set(true);
+    LOG.info("Disable the load balancer");
+  }
+  
+  public boolean isLoadBalancerDisabled() {
+    return this.isLoadBalancerDisabled.get();
+  }
 
   private void initRpcServer(HServerAddress address) throws IOException {
     if (this.rpcServer != null) {

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=1378330&r1=1378329&r2=1378330&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionManager.java
Tue Aug 28 20:51:57 2012
@@ -286,7 +286,8 @@ public class RegionManager {
     Set<RegionState> regionsToAssign = regionsAwaitingAssignment(regionServer);
 
     if (regionsToAssign.isEmpty() &&
-        master.getRegionServerOperationQueue().isEmpty()) {
+        master.getRegionServerOperationQueue().isEmpty() &&
+        !master.isLoadBalancerDisabled()) {
         // There are no regions waiting to be assigned.
         // load balance as before
         this.loadBalancer.loadBalancing(regionServer, mostLoadedRegions, returnMsgs);
@@ -357,7 +358,8 @@ public class RegionManager {
     if (regionsToAssign.isEmpty()) {
       // There are no regions waiting to be assigned.
       if (!assignmentByLocality
-          && master.getRegionServerOperationQueue().isEmpty()) {
+          && master.getRegionServerOperationQueue().isEmpty()
+          && !master.isLoadBalancerDisabled()) {
         // load balance as before
         this.loadBalancer.loadBalancing(info, mostLoadedRegions, returnMsgs);
       }

Modified: hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp?rev=1378330&r1=1378329&r2=1378330&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp (original)
+++ hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp Tue Aug 28 20:51:57
2012
@@ -39,7 +39,11 @@
 <body>
 <a id="logo" href="http://wiki.apache.org/lucene-hadoop/Hbase"><img src="/static/hbase_logo_med.gif"
alt="HBase Logo" title="HBase Logo" /></a>
 <h1 id="page_title">Master: <%=master.getMasterAddress().getHostname()%>:<%=master.getMasterAddress().getPort()%></h1>
-<p id="links_menu"><a href="/logs/">Local logs</a>, <a href="/stacks">Thread
Dump</a>, <a href="/logLevel">Log Level</a>, <a href="/taskmonitor">Task
Monitor</a>, <a href="/conf">HBase Configuration</a> <a href="assignmentPlan.jsp">HBase
Assignment Plan</a></p>
+<p id="links_menu"><a href="/logs/">Local logs</a>, <a href="/stacks">Thread
Dump</a>, <a href="/logLevel">Log Level</a>, <a href="/taskmonitor">Task
Monitor</a>, <a href="/conf">HBase Configuration</a> <a href="assignmentPlan.jsp">HBase
Assignment Plan</a>
+<% if (master.isLoadBalancerDisabled()) { %>
+  <div class="warning"> <b><font color="#FF0000"> The load balancer has
been disabled </font></b></div>
+<% } %>
+</p>
 
 <!-- Various warnings that cluster admins should be aware of -->
 <% if (JvmVersion.isBadJvmVersion()) { %>
@@ -74,6 +78,7 @@
         <tr><td>Fragmentation</td><td><%= frags.get("-TOTAL-")
!= null ? frags.get("-TOTAL-").intValue() + "%" : "n/a" %></td><td>Overall
fragmentation of all tables, including .META. and -ROOT-.</td></tr>
 <%  } %>
 <tr><td>Zookeeper Quorum</td><td><%= master.getZooKeeperWrapper().getQuorumServers()
%></td><td>Addresses of all registered ZK servers. For more, see <a href="/zk.jsp">zk
dump</a>.</td></tr>
+<tr><td>LoadBalancer Status</td><td>Disabled: <%= master.isLoadBalancerDisabled()
%></td><td>Whether the load balancer has been disabled</td></tr>
 </table>
 
 <h2>Catalog Tables</h2>

Modified: hbase/branches/0.89-fb/src/main/ruby/hbase/admin.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/ruby/hbase/admin.rb?rev=1378330&r1=1378329&r2=1378330&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/ruby/hbase/admin.rb (original)
+++ hbase/branches/0.89-fb/src/main/ruby/hbase/admin.rb Tue Aug 28 20:51:57 2012
@@ -122,6 +122,26 @@ module Hbase
     end
 
     #----------------------------------------------------------------------------------------------
+    # enable_loadbalancer
+    def enable_loadbalancer
+      @admin.enableLoadBalancer
+      get_loadbalancer
+    end
+	
+	#----------------------------------------------------------------------------------------------
+    # disable_loadbalancer
+    def disable_loadbalancer
+      @admin.disableLoadBalancer
+      get_loadbalancer
+    end
+	
+	#----------------------------------------------------------------------------------------------
+    # Shuts hbase down
+    def get_loadbalancer
+      print "LoadBalacner disabled: %s \n " % @admin.isLoadBalancerDisabled
+    end
+	
+	#----------------------------------------------------------------------------------------------
     # Shuts hbase down
     def shutdown
       @admin.shutdown

Modified: hbase/branches/0.89-fb/src/main/ruby/shell.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/ruby/shell.rb?rev=1378330&r1=1378329&r2=1378330&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/ruby/shell.rb (original)
+++ hbase/branches/0.89-fb/src/main/ruby/shell.rb Tue Aug 28 20:51:57 2012
@@ -273,6 +273,9 @@ Shell.load_command_group(
     split
     zk
     zk_dump
+    enable_loadbalancer
+    disable_loadbalancer
+    get_loadbalancer
   ]
 )
 

Added: hbase/branches/0.89-fb/src/main/ruby/shell/commands/disable_loadbalancer.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/ruby/shell/commands/disable_loadbalancer.rb?rev=1378330&view=auto
==============================================================================
--- hbase/branches/0.89-fb/src/main/ruby/shell/commands/disable_loadbalancer.rb (added)
+++ hbase/branches/0.89-fb/src/main/ruby/shell/commands/disable_loadbalancer.rb Tue Aug 28
20:51:57 2012
@@ -0,0 +1,36 @@
+#
+# Copyright 2012 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.
+#
+
+
+module Shell
+  module Commands
+    class DisableLoadbalancer < Command
+      def help
+        return <<-EOF
+          disable the loadbalancer
+        EOF
+      end
+
+      def command
+        admin.disable_loadbalancer
+      end
+    end
+  end
+end

Added: hbase/branches/0.89-fb/src/main/ruby/shell/commands/enable_loadbalancer.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/ruby/shell/commands/enable_loadbalancer.rb?rev=1378330&view=auto
==============================================================================
--- hbase/branches/0.89-fb/src/main/ruby/shell/commands/enable_loadbalancer.rb (added)
+++ hbase/branches/0.89-fb/src/main/ruby/shell/commands/enable_loadbalancer.rb Tue Aug 28
20:51:57 2012
@@ -0,0 +1,36 @@
+#
+# Copyright 2012 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.
+#
+
+
+module Shell
+  module Commands
+    class EnableLoadbalancer < Command
+      def help
+        return <<-EOF
+          enable the loadbalancer
+        EOF
+      end
+
+      def command
+        admin.enable_loadbalancer
+      end
+    end
+  end
+end

Added: hbase/branches/0.89-fb/src/main/ruby/shell/commands/get_loadbalancer.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/ruby/shell/commands/get_loadbalancer.rb?rev=1378330&view=auto
==============================================================================
--- hbase/branches/0.89-fb/src/main/ruby/shell/commands/get_loadbalancer.rb (added)
+++ hbase/branches/0.89-fb/src/main/ruby/shell/commands/get_loadbalancer.rb Tue Aug 28 20:51:57
2012
@@ -0,0 +1,36 @@
+#
+# Copyright 2012 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.
+#
+
+
+module Shell
+  module Commands
+    class GetLoadbalancer < Command
+      def help
+        return <<-EOF
+          get the loadbalancer sataus
+        EOF
+      end
+
+      def command
+        admin.get_loadbalancer
+      end
+    end
+  end
+end



Mime
View raw message