hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-12434 Add a command to compact all the regions in a regionserver (Liu Shaohui)
Date Wed, 12 Nov 2014 01:58:25 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 d01bc2f43 -> f1a8f2fca


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

Conflicts:
	hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Amending-Author: Andrew Purtell <apurtell@apache.org>


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

Branch: refs/heads/0.98
Commit: f1a8f2fcaef46dc48dd764651aa9214cad07ec1f
Parents: d01bc2f
Author: stack <stack@apache.org>
Authored: Tue Nov 11 09:32:55 2014 -0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Tue Nov 11 17:56:55 2014 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/client/HBaseAdmin.java  | 14 +++++++
 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 ++++++++++++++++++++
 4 files changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f1a8f2fc/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 583920c..4d5007c 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
@@ -1684,6 +1684,20 @@ public class HBaseAdmin implements Abortable, Closeable {
   }
 
   /**
+   * 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 {
+    for (HRegionInfo region : getOnlineRegions(sn)) {
+      compact(sn, region, major, null);
+    }
+  }
+
+  /**
    * 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 suffix: e.g. if regionname is

http://git-wip-us.apache.org/repos/asf/hbase/blob/f1a8f2fc/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 baf11fb..b513412 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -64,6 +64,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/f1a8f2fc/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 e67bdf0..11968c0 100644
--- a/hbase-shell/src/main/ruby/shell.rb
+++ b/hbase-shell/src/main/ruby/shell.rb
@@ -318,6 +318,7 @@ Shell.load_command_group(
     catalogjanitor_run
     catalogjanitor_switch
     catalogjanitor_enabled
+    compact_rs
     trace
   ]
 )

http://git-wip-us.apache.org/repos/asf/hbase/blob/f1a8f2fc/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


Mime
View raw message