Index: hbase-server/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java
===================================================================
--- hbase-server/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java (revision 1447573)
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java (working copy)
@@ -119,6 +119,16 @@
/**
* INTERNAL Used by HBase Shell interface to access this metadata
+ * attribute which denotes if the table is compaction enabled
+ *
+ * @see #isCompactionEnable()
+ */
+ public static final String COMPACTION_ENABLE = "COMPACTION_ENABLE";
+ private static final ImmutableBytesWritable COMPACTION_ENABLE_KEY =
+ new ImmutableBytesWritable(Bytes.toBytes(COMPACTION_ENABLE));
+
+ /**
+ * INTERNAL 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
*
@@ -176,6 +186,11 @@
public static final boolean DEFAULT_READONLY = false;
/**
+ * Constant that denotes whether the table is compaction enabled by default
+ */
+ public static final boolean DEFAULT_COMPACTION_ENABLE = true;
+
+ /**
* Constant that denotes the maximum default size of the memstore after which
* the contents are flushed to the store files
*/
@@ -579,6 +594,25 @@
}
/**
+ * 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 isCompactionEnable() {
+ return isSomething(COMPACTION_ENABLE_KEY, DEFAULT_COMPACTION_ENABLE);
+ }
+
+ /**
+ * Setting the table compaction enable flag.
+ *
+ * @param isEnable True if enable compaction.
+ */
+ public void setCompactionEnable(final boolean isEnable) {
+ setValue(COMPACTION_ENABLE_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
Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
===================================================================
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java (revision 1447573)
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java (working copy)
@@ -213,6 +213,9 @@
if (this.server.isStopped()) {
return;
}
+ if (!r.getTableDesc().isCompactionEnable()) {
+ return;
+ }
CompactionRequest cr = s.requestCompaction(priority);
if (cr != null) {
cr.setServer(server);
Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java
===================================================================
--- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java (revision 1447573)
+++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java (working copy)
@@ -191,6 +191,9 @@
if (server.isStopped()) {
return;
}
+ if (!r.getTableDesc().isCompactionEnable()) {
+ return;
+ }
try {
long start = EnvironmentEdgeManager.currentTimeMillis();
boolean completed = region.compact(this);
Index: hbase-server/src/main/ruby/hbase/admin.rb
===================================================================
--- hbase-server/src/main/ruby/hbase/admin.rb (revision 1447573)
+++ hbase-server/src/main/ruby/hbase/admin.rb (working copy)
@@ -449,6 +449,7 @@
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.setCompactionEnable(JBoolean.valueOf(arg[COMPACTION_ENABLE])) if arg[COMPACTION_ENABLE]
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]
set_user_metadata(htd, arg.delete(METADATA)) if arg[METADATA]