You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2014/05/02 20:18:23 UTC
svn commit: r1591994 -
/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java
Author: liyin
Date: Fri May 2 18:18:23 2014
New Revision: 1591994
URL: http://svn.apache.org/r1591994
Log:
[master] Make TestHTableMultiPutThreadPool more stable
Author: daviddeng
Summary:
Since `ThreadPoolExecutor.getCompletedTaskCount()` is not very accurate, sometimes the task may be finished but the count is not increased because the thread has been switched.
Add a sleep before read the number.
Use `AssignmentLoadBalancer` to make the creating of table more stable.
Test Plan: `TestHTable`
Reviewers: manukranthk, gauravm, liyintang, rshroff, adela, elliot
Reviewed By: adela
CC: hbase-eng@
Differential Revision: https://phabricator.fb.com/D1305847
Task ID: 3296253
Modified:
hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java
Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java?rev=1591994&r1=1591993&r2=1591994&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java Fri May 2 18:18:23 2014
@@ -20,6 +20,7 @@ import org.apache.hadoop.hbase.regionser
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.StringBytes;
+import org.apache.hadoop.hbase.util.Threads;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -40,6 +41,7 @@ public class TestHTable {
public void setUp() throws Exception {
TEST_UTIL.getConfiguration().set(HBaseTestingUtility.FS_TYPE_KEY,
HBaseTestingUtility.FS_TYPE_LFS);
+ TEST_UTIL.useAssignmentLoadBalancer();
TEST_UTIL.startMiniCluster(SLAVES);
}
@@ -137,11 +139,17 @@ public class TestHTable {
@Test
public void testHTableMultiPutThreadPool() throws Exception {
+ final int MS_SLEEP = 500;
+
byte [] TABLE = Bytes.toBytes("testHTableMultiputThreadPool");
final int NUM_REGIONS = 10;
HTable ht = TEST_UTIL.createTable(TABLE, new byte[][]{FAMILY},
3, Bytes.toBytes("aaaaa"), Bytes.toBytes("zzzzz"), NUM_REGIONS);
byte [][] ROWS = ht.getStartKeys();
+
+ // Sleep for a while to make getCompletedTaskCount more accurate
+ Threads.sleepRetainInterrupt(MS_SLEEP);
+
ThreadPoolExecutor pool = (ThreadPoolExecutor)HTable.multiActionThreadPool;
int previousPoolSize = pool.getPoolSize();
int previousLargestPoolSize = pool.getLargestPoolSize();
@@ -154,6 +162,9 @@ public class TestHTable {
ht.flushCommits();
}
+ // Sleep for a while to make getCompletedTaskCount more accurate
+ Threads.sleepRetainInterrupt(MS_SLEEP);
+
// verify that HTable does NOT use thread pool for single put requests
assertEquals(1, pool.getCorePoolSize());
assertEquals(previousPoolSize, pool.getPoolSize());
@@ -169,11 +180,15 @@ public class TestHTable {
ht.put(multiput);
ht.flushCommits();
+ // Sleep for a while to make getCompletedTaskCount more accurate
+ Threads.sleepRetainInterrupt(MS_SLEEP);
+
// verify that HTable does use thread pool for multi put requests.
assertTrue((SLAVES >= pool.getLargestPoolSize())
&& (pool.getLargestPoolSize() >= previousLargestPoolSize));
- assertEquals(SLAVES,
- (pool.getCompletedTaskCount() - previousCompletedTaskCount));
+ assertTrue(String.format("Tasks completed(%d -> %d)",
+ previousCompletedTaskCount, pool.getCompletedTaskCount()),
+ (pool.getCompletedTaskCount() - previousCompletedTaskCount) >= SLAVES);
}
/**