Index: hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java (revision 1535810) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java (working copy) @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.List; import java.util.NavigableSet; +import java.util.concurrent.CountDownLatch; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; @@ -240,6 +241,8 @@ HRegion region = regions.get(0); admin.flush(region.getRegionName()); + CountDownLatch latch = region.getCompactionStateChangeLatch(); + // put another row and flush that too put = new Put(Bytes.toBytes("anotherrow")); put.add(A, A, A); @@ -249,7 +252,7 @@ // run a compaction, which normally would should get rid of the data // wait for the compaction checker to complete - Thread.sleep(1000); + latch.await(); // check both rows to ensure that they aren't there Get get = new Get(ROW); Result r = table.get(get); Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 1535810) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -232,6 +232,8 @@ protected final Map stores = new ConcurrentSkipListMap( Bytes.BYTES_RAWCOMPARATOR); + + private static volatile CountDownLatch compactionStateChangeLatch = null; // TODO: account for each registered handler in HeapSize computation private Map coprocessorServiceHandlers = Maps.newHashMap(); @@ -1236,6 +1238,14 @@ } } } + + /* + * This method is for testing purpose + */ + public CountDownLatch getCompactionStateChangeLatch() { + if (compactionStateChangeLatch == null) compactionStateChangeLatch = new CountDownLatch(1); + return compactionStateChangeLatch; + } /* * Called by compaction thread and after region is opened to compact the @@ -1309,6 +1319,7 @@ } } status.markComplete("Compaction complete"); + if (compactionStateChangeLatch != null) compactionStateChangeLatch.countDown(); return true; } finally { try {