git commit: HBASE-12055 TestBucketWriterThread hangs flakily based on timing (Nick Dimiduk)
Repository: hbase Updated Branches: refs/heads/master bcbacefdd - 7b7648322 HBASE-12055 TestBucketWriterThread hangs flakily based on timing (Nick Dimiduk) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7b764832 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7b764832 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7b764832 Branch: refs/heads/master Commit: 7b7648322b069864151cc1af6b17c3759f4de26c Parents: bcbacef Author: Enis Soztutar e...@apache.org Authored: Mon Sep 22 14:41:12 2014 -0700 Committer: Enis Soztutar e...@apache.org Committed: Mon Sep 22 14:41:12 2014 -0700 -- .../hbase/io/hfile/bucket/BucketCache.java | 14 ++- .../io/hfile/bucket/TestBucketWriterThread.java | 41 +--- 2 files changed, 32 insertions(+), 23 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/7b764832/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java index 2bb0b8c..9737e72 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java @@ -256,8 +256,9 @@ public class BucketCache implements BlockCache, HeapSize { writerThreads[i] = new WriterThread(writerQueues.get(i), i); writerThreads[i].setName(threadName + -BucketCacheWriter- + i); writerThreads[i].setDaemon(true); - writerThreads[i].start(); } +startWriterThreads(); + // Run the statistics thread periodically to print the cache statistics log // TODO: Add means of turning this off. Bit obnoxious running thread just to make a log // every five minutes. @@ -270,6 +271,17 @@ public class BucketCache implements BlockCache, HeapSize { persistencePath + , bucketAllocator= + this.bucketAllocator); } + /** + * Called by the constructor to start the writer threads. Used by tests that need to override + * starting the threads. + */ + @VisibleForTesting + protected void startWriterThreads() { +for (WriterThread thread : writerThreads) { + thread.start(); +} + } + @VisibleForTesting boolean isCacheEnabled() { return this.cacheEnabled; http://git-wip-us.apache.org/repos/asf/hbase/blob/7b764832/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java index 32227a1..4d3f550 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java @@ -37,22 +37,35 @@ import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicLong; -import static java.lang.Thread.State; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @Category({IOTests.class, SmallTests.class}) public class TestBucketWriterThread { - public static final int MAX_NUMBER_OF_TRIES_BEFORE_TEST_FAILURE = 100; private BucketCache bc; private BucketCache.WriterThread wt; private BlockingQueueRAMQueueEntry q; private Cacheable plainCacheable; private BlockCacheKey plainKey; + /** A BucketCache that does not start its writer threads. */ + private static class MockBucketCache extends BucketCache { + +public MockBucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes, + int writerThreadNum, int writerQLen, String persistencePath, int ioErrorsTolerationDuration) + throws FileNotFoundException, IOException { + super(ioEngineName, capacity, blockSize, bucketSizes, writerThreadNum, writerQLen, +persistencePath, ioErrorsTolerationDuration); +} + +@Override +protected void startWriterThreads() { + // intentional noop +} + } + /** * Set up variables and get BucketCache and WriterThread into state where tests can manually * control the running of WriterThread and BucketCache is empty. @@ -65,36 +78,20 @@ public class TestBucketWriterThread { // Run with one writer thread
[2/2] git commit: HBASE-12055 TestBucketWriterThread hangs flakily based on timing (Nick Dimiduk)
HBASE-12055 TestBucketWriterThread hangs flakily based on timing (Nick Dimiduk) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6ee04626 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6ee04626 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6ee04626 Branch: refs/heads/branch-1 Commit: 6ee0462642e1311dbbf838cb29051e77fc80fa80 Parents: e92413d Author: Enis Soztutar e...@apache.org Authored: Mon Sep 22 14:41:12 2014 -0700 Committer: Enis Soztutar e...@apache.org Committed: Mon Sep 22 14:42:58 2014 -0700 -- .../hbase/io/hfile/bucket/BucketCache.java | 14 ++- .../io/hfile/bucket/TestBucketWriterThread.java | 41 +--- 2 files changed, 32 insertions(+), 23 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/6ee04626/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java index e634712..75d0630 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java @@ -256,8 +256,9 @@ public class BucketCache implements BlockCache, HeapSize { writerThreads[i] = new WriterThread(writerQueues.get(i), i); writerThreads[i].setName(threadName + -BucketCacheWriter- + i); writerThreads[i].setDaemon(true); - writerThreads[i].start(); } +startWriterThreads(); + // Run the statistics thread periodically to print the cache statistics log // TODO: Add means of turning this off. Bit obnoxious running thread just to make a log // every five minutes. @@ -270,6 +271,17 @@ public class BucketCache implements BlockCache, HeapSize { persistencePath + , bucketAllocator= + this.bucketAllocator); } + /** + * Called by the constructor to start the writer threads. Used by tests that need to override + * starting the threads. + */ + @VisibleForTesting + protected void startWriterThreads() { +for (WriterThread thread : writerThreads) { + thread.start(); +} + } + @VisibleForTesting boolean isCacheEnabled() { return this.cacheEnabled; http://git-wip-us.apache.org/repos/asf/hbase/blob/6ee04626/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java index 8a6296a..91f453f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketWriterThread.java @@ -36,22 +36,35 @@ import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicLong; -import static java.lang.Thread.State; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @Category(SmallTests.class) public class TestBucketWriterThread { - public static final int MAX_NUMBER_OF_TRIES_BEFORE_TEST_FAILURE = 100; private BucketCache bc; private BucketCache.WriterThread wt; private BlockingQueueRAMQueueEntry q; private Cacheable plainCacheable; private BlockCacheKey plainKey; + /** A BucketCache that does not start its writer threads. */ + private static class MockBucketCache extends BucketCache { + +public MockBucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes, + int writerThreadNum, int writerQLen, String persistencePath, int ioErrorsTolerationDuration) + throws FileNotFoundException, IOException { + super(ioEngineName, capacity, blockSize, bucketSizes, writerThreadNum, writerQLen, +persistencePath, ioErrorsTolerationDuration); +} + +@Override +protected void startWriterThreads() { + // intentional noop +} + } + /** * Set up variables and get BucketCache and WriterThread into state where tests can manually * control the running of WriterThread and BucketCache is empty. @@ -64,36 +77,20 @@ public class TestBucketWriterThread { // Run with one writer thread only. Means there will be one writer queue only too. We depend // on this in below.