You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/12/06 15:08:36 UTC

[GitHub] keith-turner closed pull request #801: fixes #791 fixed bug in ConcurrentKeyExtentCacheTest

keith-turner closed pull request #801: fixes #791 fixed bug in ConcurrentKeyExtentCacheTest
URL: https://github.com/apache/accumulo/pull/801
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/ConcurrentKeyExtentCacheTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/ConcurrentKeyExtentCacheTest.java
index ec4ad19559..a7a967aaba 100644
--- a/core/src/test/java/org/apache/accumulo/core/clientImpl/ConcurrentKeyExtentCacheTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/ConcurrentKeyExtentCacheTest.java
@@ -26,8 +26,8 @@
 import java.util.List;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Stream;
 
 import org.apache.accumulo.core.client.AccumuloException;
@@ -48,7 +48,7 @@
   @BeforeClass
   public static void setupSplits() {
     Text prev = null;
-    for (int i = 1; i < 256; i++) {
+    for (int i = 1; i < 255; i++) {
       Text endRow = new Text(String.format("%02x", i));
       extents.add(new KeyExtent(Table.ID.of("1"), endRow, prev));
       prev = endRow;
@@ -61,7 +61,7 @@ public static void setupSplits() {
 
   private static class TestCache extends ConcurrentKeyExtentCache {
 
-    AtomicInteger updates = new AtomicInteger(0);
+    ConcurrentSkipListSet<KeyExtent> seen = new ConcurrentSkipListSet<>();
 
     TestCache() {
       super(null, null);
@@ -70,7 +70,7 @@ public static void setupSplits() {
     @Override
     protected void updateCache(KeyExtent e) {
       super.updateCache(e);
-      updates.incrementAndGet();
+      assertTrue(seen.add(e));
     }
 
     @Override
@@ -103,16 +103,18 @@ private void testLookup(TestCache tc, Text lookupRow) {
   @Test
   public void testExactEndRows() {
     Random rand = new SecureRandom();
+
     TestCache tc = new TestCache();
-    rand.ints(10000, 0, 256).mapToObj(i -> new Text(String.format("%02x", i))).sequential()
+
+    rand.ints(20000, 0, 256).mapToObj(i -> new Text(String.format("%02x", i))).sequential()
         .forEach(lookupRow -> testLookup(tc, lookupRow));
-    assertEquals(256, tc.updates.get());
+    assertEquals(extentsSet, tc.seen);
 
     // try parallel
     TestCache tc2 = new TestCache();
-    rand.ints(10000, 0, 256).mapToObj(i -> new Text(String.format("%02x", i))).parallel()
+    rand.ints(20000, 0, 256).mapToObj(i -> new Text(String.format("%02x", i))).parallel()
         .forEach(lookupRow -> testLookup(tc2, lookupRow));
-    assertEquals(256, tc2.updates.get());
+    assertEquals(extentsSet, tc.seen);
   }
 
   @Test
@@ -120,14 +122,14 @@ public void testRandom() throws Exception {
     TestCache tc = new TestCache();
 
     Random rand = new SecureRandom();
-    rand.ints(10000).mapToObj(i -> new Text(String.format("%08x", i))).sequential()
+    rand.ints(20000).mapToObj(i -> new Text(String.format("%08x", i))).sequential()
         .forEach(lookupRow -> testLookup(tc, lookupRow));
-    assertEquals(256, tc.updates.get());
+    assertEquals(extentsSet, tc.seen);
 
     // try parallel
     TestCache tc2 = new TestCache();
-    rand.ints(10000).mapToObj(i -> new Text(String.format("%08x", i))).parallel()
+    rand.ints(20000).mapToObj(i -> new Text(String.format("%08x", i))).parallel()
         .forEach(lookupRow -> testLookup(tc2, lookupRow));
-    assertEquals(256, tc2.updates.get());
+    assertEquals(extentsSet, tc2.seen);
   }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services