Package org.infinispan.util.concurrent

Examples of org.infinispan.util.concurrent.ConcurrentHashSet


      assertEquals(map.remove(obj1.getKey()), obj1.getValue());
      assertEquals(map.remove(obj2.getKey()), obj2.getValue());
      assertEquals(map.remove(obj3.getKey()), obj3.getValue());
    assertTrue(map.isEmpty());

      final ConcurrentHashSet set = new ConcurrentHashSet();
      AdvancedCacheLoader.CacheLoaderTask taskWithoutValues = new AdvancedCacheLoader.CacheLoaderTask() {
         @Override
         public void processEntry(MarshalledEntry marshalledEntry, AdvancedCacheLoader.TaskContext taskContext) throws InterruptedException {
            if (marshalledEntry.getKey() != null) {
               set.add(marshalledEntry.getKey());
            }
         }
      };
      cs.process(null, taskWithoutValues, new ThreadPoolExecutor(1, 2, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(10)), false, false);
      assertEquals(set.size(), 3);
      assertTrue(set.remove(obj1.getKey()));
      assertTrue(set.remove(obj2.getKey()));
      assertTrue(set.remove(obj3.getKey()));
      assertTrue(map.isEmpty());
  }
View Full Code Here


      assertEquals(map.remove(obj1.getKey()), obj1.getValue());
      assertEquals(map.remove(obj2.getKey()), obj2.getValue());
      assertEquals(map.remove(obj3.getKey()), obj3.getValue());
    assertTrue(map.isEmpty());

      final ConcurrentHashSet set = new ConcurrentHashSet();
      AdvancedCacheLoader.CacheLoaderTask taskWithoutValues = new AdvancedCacheLoader.CacheLoaderTask() {
         @Override
         public void processEntry(MarshalledEntry marshalledEntry, AdvancedCacheLoader.TaskContext taskContext) throws InterruptedException {
            if (marshalledEntry.getKey() != null) {
               set.add(marshalledEntry.getKey());
            }
         }
      };
      cs.process(null, taskWithoutValues, new ThreadPoolExecutor(1, 2, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(10)), false, false);
      assertEquals(set.size(), 3);
      assertTrue(set.remove(obj1.getKey()));
      assertTrue(set.remove(obj2.getKey()));
      assertTrue(set.remove(obj3.getKey()));
      assertTrue(map.isEmpty());
  }
View Full Code Here

   }

   private void runIterationTest(int numThreads, Executor persistenceExecutor1) {
      int numEntries = insertData();
      final ConcurrentMap entries = new ConcurrentHashMap();
      final ConcurrentHashSet threads = new ConcurrentHashSet();
      final AtomicBoolean sameKeyMultipleTimes = new AtomicBoolean();

      store.process(null, new AdvancedCacheLoader.CacheLoaderTask() {
         @Override
         public void processEntry(MarshalledEntry marshalledEntry, AdvancedCacheLoader.TaskContext taskContext) throws InterruptedException {
            Object existing = entries.put(marshalledEntry.getKey(), marshalledEntry.getValue());
            threads.add(Thread.currentThread());
            if (existing != null) {
               log.warnf("Already a value present for key %s: %s", marshalledEntry.getKey(), existing);
               sameKeyMultipleTimes.set(true);
            }
         }
      }, persistenceExecutor1, true, true);

      assertFalse(sameKeyMultipleTimes.get());
      for (int i = 0; i < numEntries; i++) {
         assertEquals(entries.get(i), i, "For key" + i);
      }

      if (multipleThreads) {
         assertEquals(threads.size(), numThreads);
      }
   }
View Full Code Here

      assertEquals(map.remove(obj1.getKey()), obj1.getValue());
      assertEquals(map.remove(obj2.getKey()), obj2.getValue());
      assertEquals(map.remove(obj3.getKey()), obj3.getValue());
    assertTrue(map.isEmpty());

      final ConcurrentHashSet set = new ConcurrentHashSet();
      AdvancedCacheLoader.CacheLoaderTask taskWithoutValues = new AdvancedCacheLoader.CacheLoaderTask() {
         @Override
         public void processEntry(MarshalledEntry marshalledEntry, AdvancedCacheLoader.TaskContext taskContext) throws InterruptedException {
            if (marshalledEntry.getKey() != null) {
               set.add(marshalledEntry.getKey());
            }
         }
      };
      cs.process(null, taskWithoutValues, new ThreadPoolExecutor(1, 2, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(10)), false, false);
      assertEquals(set.size(), 3);
      assertTrue(set.remove(obj1.getKey()));
      assertTrue(set.remove(obj2.getKey()));
      assertTrue(set.remove(obj3.getKey()));
      assertTrue(map.isEmpty());
  }
View Full Code Here

TOP

Related Classes of org.infinispan.util.concurrent.ConcurrentHashSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.