hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [3/3] hbase git commit: HBASE-13222 Add isBalancerEnabled method to Master and Admin.
Date Fri, 27 Mar 2015 21:36:11 GMT
HBASE-13222 Add isBalancerEnabled method to Master and Admin.

Include some basic tests for the method on a testing cluster.
Also update master page to show an alert when balancer is disabled.

Signed-off-by: Enis Soztutar <enis@apache.org>


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

Branch: refs/heads/master
Commit: 98b1e72d1c373cb517dc17b6c93bba3f87bbfbcf
Parents: a4a235b
Author: Josh Elser <elserj@apache.org>
Authored: Tue Mar 24 11:01:16 2015 -0400
Committer: Enis Soztutar <enis@apache.org>
Committed: Fri Mar 27 14:28:03 2015 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Admin.java   |    7 +
 .../hbase/client/ConnectionImplementation.java  |    9 +
 .../apache/hadoop/hbase/client/HBaseAdmin.java  |   17 +
 .../hadoop/hbase/protobuf/RequestConverter.java |   10 +
 .../hbase/protobuf/generated/MasterProtos.java  | 1625 ++++++++++++++----
 hbase-protocol/src/main/protobuf/Master.proto   |   13 +
 .../hbase/tmpl/master/MasterStatusTmpl.jamon    |   12 +
 .../org/apache/hadoop/hbase/master/HMaster.java |   21 +
 .../hadoop/hbase/master/MasterRpcServices.java  |   10 +
 .../master/balancer/LoadBalancerFactory.java    |   11 +-
 .../apache/hadoop/hbase/client/TestAdmin2.java  |   22 +
 hbase-shell/src/main/ruby/hbase/admin.rb        |    7 +
 hbase-shell/src/main/ruby/shell.rb              |    1 +
 .../ruby/shell/commands/balancer_enabled.rb     |   41 +
 14 files changed, 1436 insertions(+), 370 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/98b1e72d/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
index 70ed231..9453924 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
@@ -703,6 +703,13 @@ public interface Admin extends Abortable, Closeable {
   boolean balancer() throws IOException;
 
   /**
+   * Query the current state of the balancer
+   *
+   * @return true if the balancer is enabled, false otherwise.
+   */
+  boolean isBalancerEnabled() throws IOException;
+
+  /**
    * Enable/Disable the catalog janitor
    *
    * @param enable if true enables the catalog janitor

http://git-wip-us.apache.org/repos/asf/hbase/blob/98b1e72d/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
index 93ddea9..426f5fa 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
@@ -22,6 +22,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.protobuf.BlockingRpcChannel;
 import com.google.protobuf.RpcController;
 import com.google.protobuf.ServiceException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -53,6 +54,8 @@ import org.apache.hadoop.hbase.protobuf.RequestConverter;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsBalancerEnabledRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsBalancerEnabledResponse;
 import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -1589,6 +1592,12 @@ class ConnectionImplementation implements ClusterConnection, Closeable
{
           throws ServiceException {
         return stub.getLastMajorCompactionTimestampForRegion(controller, request);
       }
+
+      @Override
+      public IsBalancerEnabledResponse isBalancerEnabled(RpcController controller,
+          IsBalancerEnabledRequest request) throws ServiceException {
+        return stub.isBalancerEnabled(controller, request);
+      }
     };
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/98b1e72d/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 c90ce93..1fe4305 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
@@ -1971,6 +1971,23 @@ public class HBaseAdmin implements Admin {
   }
 
   /**
+   * Query the state of the balancer from the Master. It's not a guarantee that the balancer
is
+   * actually running this very moment, but that it will run.
+   *
+   * @return True if the balancer is enabled, false otherwise.
+   */
+  @Override
+  public boolean isBalancerEnabled() throws IOException {
+    return executeCallable(new MasterCallable<Boolean>(getConnection()) {
+      @Override
+      public Boolean call(int callTimeout) throws ServiceException {
+        return master.isBalancerEnabled(null, RequestConverter.buildIsBalancerEnabledRequest())
+            .getEnabled();
+      }
+    });
+  }
+
+  /**
    * Enable/Disable the catalog janitor
    * @param enable if true enables the catalog janitor
    * @return the previous state

http://git-wip-us.apache.org/repos/asf/hbase/blob/98b1e72d/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
index f92d901..16c3dbf 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
@@ -92,6 +92,7 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterSta
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsBalancerEnabledRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsCatalogJanitorEnabledRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
@@ -1340,6 +1341,15 @@ public final class RequestConverter {
   }
 
   /**
+   * Creates a protocol buffer IsBalancerEnabledRequest
+   *
+   * @return a IsBalancerEnabledRequest
+   */
+  public static IsBalancerEnabledRequest buildIsBalancerEnabledRequest() {
+    return IsBalancerEnabledRequest.newBuilder().build();
+  }
+
+  /**
    * @see {@link #buildGetClusterStatusRequest}
    */
   private static final GetClusterStatusRequest GET_CLUSTER_STATUS_REQUEST =


Mime
View raw message