You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/11/11 18:33:03 UTC

hbase git commit: HBASE-12434 Add a command to compact all the regions in a regionserver (Liu Shaohui)

Repository: hbase
Updated Branches:
  refs/heads/master df8859d5a -> e28774138


HBASE-12434 Add a command to compact all the regions in a regionserver (Liu Shaohui)


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

Branch: refs/heads/master
Commit: e28774138812411e144de457403678b0efc55496
Parents: df8859d
Author: stack <st...@apache.org>
Authored: Tue Nov 11 09:32:55 2014 -0800
Committer: stack <st...@apache.org>
Committed: Tue Nov 11 09:32:55 2014 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/Admin.java   | 10 +++++
 .../apache/hadoop/hbase/client/HBaseAdmin.java  | 12 ++++++
 hbase-shell/src/main/ruby/hbase/admin.rb        |  5 +++
 hbase-shell/src/main/ruby/shell.rb              |  1 +
 .../src/main/ruby/shell/commands/compact_rs.rb  | 43 ++++++++++++++++++++
 5 files changed, 71 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e2877413/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 a08cf79..9ed4594 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
@@ -594,6 +594,16 @@ public interface Admin extends Abortable, Closeable {
     throws IOException, InterruptedException;
 
   /**
+   * Compact all regions on the region server
+   * @param regionserver the region server name
+   * @param major if it's major compaction
+   * @throws IOException
+   * @throws InterruptedException
+   */
+  public void compactRegionServer(final ServerName sn, boolean major)
+    throws IOException, InterruptedException;
+
+  /**
    * Move the region <code>r</code> to <code>dest</code>.
    *
    * @param encodedRegionName The encoded region name; i.e. the hash that makes up the region name

http://git-wip-us.apache.org/repos/asf/hbase/blob/e2877413/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 75dd72c..2bc8c2d 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
@@ -83,6 +83,7 @@ import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.RollWALWriterReque
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.RollWALWriterResponse;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.StopServerRequest;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateConfigurationRequest;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ProcedureDescription;
@@ -1609,6 +1610,17 @@ public class HBaseAdmin implements Admin {
    * {@inheritDoc}
    */
   @Override
+  public void compactRegionServer(final ServerName sn, boolean major)
+  throws IOException, InterruptedException {
+    for (HRegionInfo region : getOnlineRegions(sn)) {
+      compact(sn, region, major, null);
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
   public void majorCompact(final TableName tableName)
   throws IOException, InterruptedException {
     compact(tableName, null, true);

http://git-wip-us.apache.org/repos/asf/hbase/blob/e2877413/hbase-shell/src/main/ruby/hbase/admin.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index 52d9df7..971df06 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -65,6 +65,11 @@ module Hbase
       end
     end
 
+    # Requests to compact all regions on the regionserver
+    def compact_regionserver(servername, major = false)
+      @admin.compactRegionServer(ServerName.valueOf(servername), major)
+    end
+
     #----------------------------------------------------------------------------------------------
     # Requests a table or region or column family major compaction
     def major_compact(table_or_region_name, family = nil)

http://git-wip-us.apache.org/repos/asf/hbase/blob/e2877413/hbase-shell/src/main/ruby/shell.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb
index 1c10bc1..a06371a 100644
--- a/hbase-shell/src/main/ruby/shell.rb
+++ b/hbase-shell/src/main/ruby/shell.rb
@@ -325,6 +325,7 @@ Shell.load_command_group(
     catalogjanitor_run
     catalogjanitor_switch
     catalogjanitor_enabled
+    compact_rs
     trace
   ]
 )

http://git-wip-us.apache.org/repos/asf/hbase/blob/e2877413/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb b/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb
new file mode 100644
index 0000000..0ecdd21
--- /dev/null
+++ b/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb
@@ -0,0 +1,43 @@
+#
+#
+# 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 CompactRs < Command
+      def help
+        return <<-EOF
+          Compact all regions on passed regionserver.
+          Examples:
+          Compact all regions on a regionserver:
+          hbase> compact_rs 'host187.example.com,60020'
+          or
+          hbase> compact_rs 'host187.example.com,60020,1289493121758'
+          Major compact all regions on a regionserver:
+          hbase> compact_rs 'host187.example.com,60020,1289493121758', true
+        EOF
+      end
+
+      def command(regionserver, major = false)
+        format_simple_command do
+          admin.compact_regionserver(regionserver, major)
+        end
+      end
+    end
+  end
+end