hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1505060 - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java hbase-server/src/main/ruby/hbase/admin.rb
Date Fri, 19 Jul 2013 22:40:32 GMT
Author: sershe
Date: Fri Jul 19 22:40:31 2013
New Revision: 1505060

URL: http://svn.apache.org/r1505060
Log:
HBASE-7875 introduce a compaction switch in HBase Shell (Liang Xie)

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
    hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=1505060&r1=1505059&r2=1505060&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java Fri
Jul 19 22:40:31 2013
@@ -126,6 +126,16 @@ public class HTableDescriptor implements
 
   /**
    * <em>INTERNAL</em> Used by HBase Shell interface to access this metadata
+   * attribute which denotes if the table is compaction enabled
+   *
+   * @see #isCompactionEnabled()
+   */
+  public static final String COMPACTION_ENABLED = "COMPACTION_ENABLED";
+  private static final ImmutableBytesWritable COMPACTION_ENABLED_KEY =
+    new ImmutableBytesWritable(Bytes.toBytes(COMPACTION_ENABLED));
+
+  /**
+   * <em>INTERNAL</em> Used by HBase Shell interface to access this metadata
    * attribute which represents the maximum size of the memstore after which
    * its contents are flushed onto the disk
    *
@@ -196,6 +206,11 @@ public class HTableDescriptor implements
   public static final boolean DEFAULT_READONLY = false;
 
   /**
+   * Constant that denotes whether the table is compaction enabled by default
+   */
+  public static final boolean DEFAULT_COMPACTION_ENABLED = true;
+
+  /**
    * Constant that denotes the maximum default size of the memstore after which
    * the contents are flushed to the store files
    */
@@ -612,6 +627,25 @@ public class HTableDescriptor implements
   }
 
   /**
+   * Check if the compaction enable flag of the table is true. If flag is
+   * false then no minor/major compactions will be done in real.
+   *
+   * @return true if table compaction enabled
+   */
+  public boolean isCompactionEnabled() {
+    return isSomething(COMPACTION_ENABLED_KEY, DEFAULT_COMPACTION_ENABLED);
+  }
+
+  /**
+   * Setting the table compaction enable flag.
+   *
+   * @param isEnable True if enable compaction.
+   */
+  public void setCompactionEnabled(final boolean isEnable) {
+    setValue(COMPACTION_ENABLED_KEY, isEnable ? TRUE : FALSE);
+  }
+
+  /**
    * Check if deferred log edits are enabled on the table.
    *
    * @return true if that deferred log flush is enabled on the table

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java?rev=1505060&r1=1505059&r2=1505060&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
Fri Jul 19 22:40:31 2013
@@ -297,7 +297,8 @@ public class CompactSplitThread implemen
   private synchronized CompactionRequest requestCompactionInternal(final HRegion r, final
Store s,
       final String why, int priority, CompactionRequest request, boolean selectNow)
           throws IOException {
-    if (this.server.isStopped()) {
+    if (this.server.isStopped()
+        || (r.getTableDesc() != null && !r.getTableDesc().isCompactionEnabled()))
{
       return null;
     }
 
@@ -418,7 +419,8 @@ public class CompactSplitThread implemen
     @Override
     public void run() {
       Preconditions.checkNotNull(server);
-      if (server.isStopped()) {
+      if (server.isStopped()
+          || (region.getTableDesc() != null && !region.getTableDesc().isCompactionEnabled()))
{
         return;
       }
       // Common case - system compaction without a file selection. Select now.

Modified: hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb?rev=1505060&r1=1505059&r2=1505060&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb (original)
+++ hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb Fri Jul 19 22:40:31 2013
@@ -259,6 +259,7 @@ module Hbase
         htd.setOwnerString(arg.delete(OWNER)) if arg[OWNER] 
         htd.setMaxFileSize(JLong.valueOf(arg.delete(MAX_FILESIZE))) if arg[MAX_FILESIZE]
         htd.setReadOnly(JBoolean.valueOf(arg.delete(READONLY))) if arg[READONLY]
+        htd.setCompactionEnabled(JBoolean.valueOf(arg[COMPACTION_ENABLED])) if arg[COMPACTION_ENABLED]
         htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(MEMSTORE_FLUSHSIZE))) if arg[MEMSTORE_FLUSHSIZE]
         htd.setDeferredLogFlush(JBoolean.valueOf(arg.delete(DEFERRED_LOG_FLUSH))) if arg[DEFERRED_LOG_FLUSH]
         htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(DURABILITY)))
if arg[DURABILITY]
@@ -468,6 +469,7 @@ module Hbase
         htd.setOwnerString(arg.delete(OWNER)) if arg[OWNER] 
         htd.setMaxFileSize(JLong.valueOf(arg.delete(MAX_FILESIZE))) if arg[MAX_FILESIZE]
         htd.setReadOnly(JBoolean.valueOf(arg.delete(READONLY))) if arg[READONLY]
+        htd.setCompactionEnabled(JBoolean.valueOf(arg[COMPACTION_ENABLED])) if arg[COMPACTION_ENABLED]
         htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(MEMSTORE_FLUSHSIZE))) if arg[MEMSTORE_FLUSHSIZE]
         htd.setDeferredLogFlush(JBoolean.valueOf(arg.delete(DEFERRED_LOG_FLUSH))) if arg[DEFERRED_LOG_FLUSH]
         htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(DURABILITY)))
if arg[DURABILITY]



Mime
View raw message