hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject [3/3] hbase git commit: Add mechanism to control hbase cleaner behavior
Date Thu, 02 Feb 2017 03:33:17 GMT
Add mechanism to control hbase cleaner behavior

Signed-off-by: tedyu <yuzhihong@gmail.com>


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

Branch: refs/heads/master
Commit: ef052521cd3b1ae086770aabfad14804ee8d4ac6
Parents: c6250ec
Author: Ajay Jadhav <jadhavab@amazon.com>
Authored: Wed Feb 1 11:33:01 2017 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Feb 1 19:33:06 2017 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Admin.java   |   24 +
 .../hbase/client/ConnectionImplementation.java  |   25 +-
 .../apache/hadoop/hbase/client/HBaseAdmin.java  |   36 +-
 .../hbase/shaded/protobuf/RequestConverter.java |   39 +
 .../shaded/protobuf/ResponseConverter.java      |    9 +
 .../shaded/protobuf/generated/MasterProtos.java | 4912 ++++++++++++++----
 .../src/main/protobuf/Master.proto              |   38 +
 .../org/apache/hadoop/hbase/master/HMaster.java |   22 +-
 .../hadoop/hbase/master/MasterRpcServices.java  |   36 +
 .../hbase/master/cleaner/CleanerChore.java      |   23 +
 .../hbase/master/cleaner/TestCleanerChore.java  |   66 +
 hbase-shell/src/main/ruby/hbase/admin.rb        |   20 +
 hbase-shell/src/main/ruby/shell.rb              |    3 +
 .../shell/commands/cleaner_chore_enabled.rb     |   36 +
 .../ruby/shell/commands/cleaner_chore_run.rb    |   35 +
 .../ruby/shell/commands/cleaner_chore_switch.rb |   37 +
 16 files changed, 4378 insertions(+), 983 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ef052521/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 583ee52..232dbf4 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
@@ -897,6 +897,30 @@ public interface Admin extends Abortable, Closeable {
   boolean isCatalogJanitorEnabled() throws IOException;
 
   /**
+   * Enable/Disable the cleaner chore
+   *
+   * @param on if true enables the cleaner chore
+   * @return the previous state
+   * @throws IOException
+   */
+  public boolean setCleanerChoreRunning(final boolean on) throws IOException;
+
+  /**
+   * Ask for cleaner chore to run
+   *
+   * @return True if cleaner chore ran, false otherwise
+   * @throws IOException
+   */
+  public boolean runCleanerChore() throws IOException;
+
+  /**
+   * Query on the cleaner chore state (Enabled/Disabled?)
+   *
+   * @throws IOException
+   */
+  public boolean isCleanerChoreEnabled() throws IOException;
+
+  /**
    * Merge two regions. Asynchronous operation.
    *
    * @param nameOfRegionA encoded or full name of region a

http://git-wip-us.apache.org/repos/asf/hbase/blob/ef052521/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 ca21365..9142ec9 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
@@ -80,12 +80,12 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientServ
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DrainRegionServersResponse;
-import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersRequest;
-import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDrainingRegionServersResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RemoveDrainFromRegionServersRequest;
@@ -1444,6 +1444,27 @@ class ConnectionImplementation implements ClusterConnection, Closeable
{
       }
 
       @Override
+      public MasterProtos.RunCleanerChoreResponse runCleanerChore(RpcController controller,
+          MasterProtos.RunCleanerChoreRequest request)
+          throws ServiceException {
+        return stub.runCleanerChore(controller, request);
+      }
+
+      @Override
+      public MasterProtos.SetCleanerChoreRunningResponse setCleanerChoreRunning(
+          RpcController controller, MasterProtos.SetCleanerChoreRunningRequest request)
+          throws ServiceException {
+        return stub.setCleanerChoreRunning(controller, request);
+      }
+
+      @Override
+      public MasterProtos.IsCleanerChoreEnabledResponse isCleanerChoreEnabled(
+          RpcController controller, MasterProtos.IsCleanerChoreEnabledRequest request)
+          throws ServiceException {
+        return stub.isCleanerChoreEnabled(controller, request);
+      }
+
+      @Override
       public ClientProtos.CoprocessorServiceResponse execMasterService(
           RpcController controller, ClientProtos.CoprocessorServiceRequest request)
           throws ServiceException {

http://git-wip-us.apache.org/repos/asf/hbase/blob/ef052521/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 6e1f254..4e0a6c7 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
@@ -58,8 +58,8 @@ import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.NamespaceNotFoundException;
 import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.ProcedureInfo;
-import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.RegionLoad;
+import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableName;
@@ -1459,6 +1459,40 @@ public class HBaseAdmin implements Admin {
     });
   }
 
+  @Override
+  public boolean setCleanerChoreRunning(final boolean on) throws IOException {
+    return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory())
{
+      @Override public Boolean rpcCall() throws Exception {
+        return master.setCleanerChoreRunning(getRpcController(), RequestConverter
+                                                                   .buildSetCleanerChoreRunningRequest(
+                                                                     on)).getPrevValue();
+      }
+    });
+  }
+
+  @Override
+  public boolean runCleanerChore() throws IOException {
+    return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory())
{
+      @Override public Boolean rpcCall() throws Exception {
+        return master
+                 .runCleanerChore(getRpcController(), RequestConverter
+                                                        .buildRunCleanerChoreRequest())
+                 .getCleanerChoreRan();
+      }
+    });
+  }
+
+  @Override
+  public boolean isCleanerChoreEnabled() throws IOException {
+    return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory())
{
+      @Override public Boolean rpcCall() throws Exception {
+        return master.isCleanerChoreEnabled(getRpcController(),
+                                            RequestConverter.buildIsCleanerChoreEnabledRequest())
+                     .getValue();
+      }
+    });
+  }
+
   private boolean isEncodedRegionName(byte[] regionName) throws IOException {
     try {
       HRegionInfo.parseRegionName(regionName);

http://git-wip-us.apache.org/repos/asf/hbase/blob/ef052521/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
index 8de9ad8..d3ef7b8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
@@ -85,6 +85,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteColu
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTableRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableCatalogJanitorRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetCleanerChoreRunningRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetClusterStatusRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
@@ -93,6 +94,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableNa
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableStateRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsCatalogJanitorEnabledRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsCleanerChoreEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsMasterRunningRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledRequest;
@@ -103,6 +105,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegion
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.OfflineRegionRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCatalogScanRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCleanerChoreRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningRequest;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledRequest;
@@ -1452,6 +1455,42 @@ public final class RequestConverter {
   }
 
   /**
+   * @see {@link #buildCleanerChoreRequest}
+   */
+  private static final RunCleanerChoreRequest CLEANER_CHORE_REQUEST =
+    RunCleanerChoreRequest.newBuilder().build();
+
+  /**
+   * Creates a request for running cleaner chore
+   * @return A {@link RunCleanerChoreRequest}
+   */
+  public static RunCleanerChoreRequest buildRunCleanerChoreRequest() {
+    return CLEANER_CHORE_REQUEST;
+  }
+
+  /**
+   * Creates a request for enabling/disabling the cleaner chore
+   * @return A {@link SetCleanerChoreRunningRequest}
+   */
+  public static SetCleanerChoreRunningRequest buildSetCleanerChoreRunningRequest(boolean
on) {
+    return SetCleanerChoreRunningRequest.newBuilder().setOn(on).build();
+  }
+
+  /**
+   * @see {@link #buildIsCleanerChoreEnabledRequest()}
+   */
+  private static final IsCleanerChoreEnabledRequest IS_CLEANER_CHORE_ENABLED_REQUEST =
+    IsCleanerChoreEnabledRequest.newBuilder().build();
+
+  /**
+   * Creates a request for querying the master whether the cleaner chore is enabled
+   * @return A {@link IsCleanerChoreEnabledRequest}
+   */
+  public static IsCleanerChoreEnabledRequest buildIsCleanerChoreEnabledRequest() {
+    return IS_CLEANER_CHORE_ENABLED_REQUEST;
+  }
+
+  /**
    * Creates a request for querying the master the last flushed sequence Id for a region
    * @param regionName
    * @return A {@link GetLastFlushedSequenceIdRequest}

http://git-wip-us.apache.org/repos/asf/hbase/blob/ef052521/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ResponseConverter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ResponseConverter.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ResponseConverter.java
index a83667d..cbcad80 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ResponseConverter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ResponseConverter.java
@@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameInt64Pa
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MapReduceProtos.ScanMetrics;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableCatalogJanitorResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCatalogScanResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCleanerChoreResponse;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.GetLastFlushedSequenceIdResponse;
 import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
 import org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString;
@@ -314,6 +315,14 @@ public final class ResponseConverter {
     return EnableCatalogJanitorResponse.newBuilder().setPrevValue(prevValue).build();
   }
 
+  /**
+   * Creates a response for the cleaner chore request
+   * @return A RunCleanerChoreResponse
+   */
+  public static RunCleanerChoreResponse buildRunCleanerChoreResponse(boolean ran) {
+    return RunCleanerChoreResponse.newBuilder().setCleanerChoreRan(ran).build();
+  }
+
 // End utilities for Admin
 
   /**


Mime
View raw message