diff --git src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 79b0d34..4ba3a1e 100644 --- src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -44,6 +44,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -74,8 +75,8 @@ import org.apache.hadoop.hbase.io.hfile.CacheConfig; import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.Store; -import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.Threads; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -3928,7 +3929,7 @@ public class TestFromClientSide { assertTrue(scan.getFamilyMap().containsKey(FAMILY)); } - + @Test public void testIncrement() throws Exception { LOG.info("Starting testIncrement"); @@ -4047,6 +4048,10 @@ public class TestFromClientSide { threads.get(1).join(); assertEquals(2, pool.getPoolSize()); + //ensure that ThreadPoolExecutor knows that threads are finished. + while (pool.getCompletedTaskCount() < 2) { + Threads.sleep(1); + } // Now let's simulate adding a RS meaning that we'll go up to three // concurrent threads. The pool should not grow larger than three. pool.submit(threads.get(2)); @@ -4092,6 +4097,9 @@ public class TestFromClientSide { + " did not match what was put", Bytes.equals(VALUE, entry.getValue())); } + + //ensure that server milis timestamp has incremented for put + Threads.sleep(1); } } @@ -4129,6 +4137,8 @@ public class TestFromClientSide { + " did not match what was put", Bytes.equals(VALUE, entry.getValue())); } + //ensure that server milis timestamp has incremented for put + Threads.sleep(1); } final Object waitLock = new Object(); @@ -4163,19 +4173,21 @@ public class TestFromClientSide { return null; } }); + //ensure that server milis timestamp has incremented for put + Threads.sleep(1); } synchronized (waitLock) { waitLock.notifyAll(); } executorService.shutdownNow(); } - - + + @Test public void testCheckAndPut() throws IOException { final byte [] anotherrow = Bytes.toBytes("anotherrow"); final byte [] value2 = Bytes.toBytes("abcd"); - + HTable table = TEST_UTIL.createTable(Bytes.toBytes("testCheckAndPut"), new byte [][] {FAMILY}); Put put1 = new Put(ROW); @@ -4184,7 +4196,7 @@ public class TestFromClientSide { // row doesn't exist, so using non-null value should be considered "not match". boolean ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, VALUE, put1); assertEquals(ok, false); - + // row doesn't exist, so using "null" to check for existence should be considered "match". ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, null, put1); assertEquals(ok, true); @@ -4192,24 +4204,24 @@ public class TestFromClientSide { // row now exists, so using "null" to check for existence should be considered "not match". ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, null, put1); assertEquals(ok, false); - + Put put2 = new Put(ROW); put2.add(FAMILY, QUALIFIER, value2); - + // row now exists, use the matching value to check ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, VALUE, put2); assertEquals(ok, true); Put put3 = new Put(anotherrow); put3.add(FAMILY, QUALIFIER, VALUE); - - // try to do CheckAndPut on different rows + + // try to do CheckAndPut on different rows try { ok = table.checkAndPut(ROW, FAMILY, QUALIFIER, value2, put3); fail("trying to check and modify different rows should have failed."); - } catch(Exception e) {} - - } + } catch(Exception e) {} + + } /** * Tests that cache on write works all the way up from the client-side. @@ -4364,7 +4376,7 @@ public class TestFromClientSide { assertNotNull(addrAfter); assertTrue(addrAfter.getPort() != addrCache.getPort()); assertEquals(addrAfter.getPort(), addrNoCache.getPort()); - } + } @Test /**