diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactingMemStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactingMemStore.java index 5e286de..6419369 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactingMemStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactingMemStore.java @@ -67,7 +67,6 @@ public class CompactingMemStore extends AbstractMemStore { // the threshold on active size for in-memory flush private long inmemoryFlushSize; private final AtomicBoolean inMemoryFlushInProgress = new AtomicBoolean(false); - @VisibleForTesting private final AtomicBoolean allowCompaction = new AtomicBoolean(true); public CompactingMemStore(Configuration conf, CellComparator c, @@ -289,13 +288,11 @@ public class CompactingMemStore extends AbstractMemStore { } // Phase II: Compact the pipeline try { - if (allowCompaction.get() && inMemoryFlushInProgress.compareAndSet(false, true)) { - // setting the inMemoryFlushInProgress flag again for the case this method is invoked - // directly (only in tests) in the common path setting from true to true is idempotent - // Speculative compaction execution, may be interrupted if flush is forced while - // compaction is in progress - compactor.startCompaction(); - } + // setting the inMemoryFlushInProgress flag again for the case this method is invoked + // directly (only in tests) in the common path setting from true to true is idempotent + // Speculative compaction execution, may be interrupted if flush is forced while + // compaction is in progress + compactor.startCompaction(); } catch (IOException e) { LOG.warn("Unable to run memstore compaction. region " + getRegionServices().getRegionInfo().getRegionNameAsString() @@ -312,9 +309,9 @@ public class CompactingMemStore extends AbstractMemStore { } private boolean shouldFlushInMemory() { - if(getActive().getSize() > inmemoryFlushSize) { + if (getActive().getSize() > inmemoryFlushSize && allowCompaction.get()) { // size above flush threshold - return (allowCompaction.get() && !inMemoryFlushInProgress.get()); + return inMemoryFlushInProgress.compareAndSet(false, true); } return false; } @@ -360,8 +357,8 @@ public class CompactingMemStore extends AbstractMemStore { * and compacts the pipeline. */ private class InMemoryFlushRunnable implements Runnable { - - @Override public void run() { + @Override + public void run() { try { flushInMemory(); } catch (IOException e) { @@ -375,14 +372,17 @@ public class CompactingMemStore extends AbstractMemStore { //---------------------------------------------------------------------- //methods for tests //---------------------------------------------------------------------- + @VisibleForTesting boolean isMemStoreFlushingInMemory() { return inMemoryFlushInProgress.get(); } + @VisibleForTesting void disableCompaction() { allowCompaction.set(false); } + @VisibleForTesting void enableCompaction() { allowCompaction.set(true); }