Package org.infinispan.distribution.ch

Examples of org.infinispan.distribution.ch.ConsistentHash.locateOwners()


         @Override
         public boolean isSatisfied() throws Exception {
            log.trace("Testing condition");
            ConsistentHash ch = cache(a0).getAdvancedCache().getDistributionManager().getReadConsistentHash();
            for (Object k : allKeys) {
               Collection<Address> owners = ch.locateOwners(k);
               try {
                  cache(a0).get(k);
                  if (owners.contains(address(c0)) || owners.contains(address(c1)))
                     return false;
               } catch (AvailabilityException e) {
View Full Code Here


      }
   }

   protected void assertMapsToAddress(Object o, Address addr) {
      ConsistentHash hash = caches.get(0).getAdvancedCache().getDistributionManager().getConsistentHash();
      List<Address> addresses = hash.locateOwners(o);
      assertEquals("Expected key " + o + " to map to address " + addr + ". List of addresses is" + addresses, true, addresses.contains(addr));
   }

   protected List<Address> topology() {
      return topology(caches.get(0).getCacheManager());
View Full Code Here

               owners++;
            }
            if (dc2.get(i) != null) {
               owners++;
            }
            assertEquals("Wrong number of owners", ch.locateOwners(i).size(), owners);

            // check values were not overwritten with old values carried by state transfer
            String expected = "after_st_" + i;
            assertEquals(expected, cache(0).get(i));
            assertEquals("after_st_" + i, cache(2).get(i));
View Full Code Here

               owners++;
            }
            if (dc2.get(i) != null) {
               owners++;
            }
            assertEquals("Wrong number of owners", ch.locateOwners(i).size(), owners);

            String expected = "before_st_" + i;
            assertEquals(expected, cache(0).get(i));
            assertEquals(expected, cache(2).get(i));
         }
View Full Code Here

         @Override
         public boolean isSatisfied() throws Exception {
            log.trace("Testing condition");
            ConsistentHash ch = cache(a0).getAdvancedCache().getDistributionManager().getReadConsistentHash();
            for (Object k : allKeys) {
               Collection<Address> owners = ch.locateOwners(k);
               try {
                  cache(a0).get(k);
                  if (owners.contains(address(c0)) || owners.contains(address(c1)))
                     return false;
               } catch (AvailabilityException e) {
View Full Code Here

      ConsistentHash ch = createNewConsistentHash(createAddresses(numNodes));
      int dummy = 0;
      long start = System.nanoTime();
      for (int i = 0; i < iterations; i++) {
         Object key = i;
         dummy += ch.locateOwners(key).size();
      }
      long duration = System.nanoTime() - start;
      assert dummy == iterations * min(numOwners, numNodes);
      return duration;
   }
View Full Code Here

      ConsistentHash ch = createNewConsistentHash(createAddresses(numNodes));

      Map<Address, Integer> distribution = new HashMap<Address, Integer>();

      for (Object key : keys) {
         Address a = ch.locateOwners(key).get(0);
         if (distribution.containsKey(a)) {
            int i = distribution.get(a);
            distribution.put(a, i + 1);
         } else {
            distribution.put(a, 1);
View Full Code Here

            for (int k = 0; k < NUM_ITERATIONS; k++) {
               String key = keyFor(i, j, k);
               if (keysToIgnore.contains(key)) {
                  log.infof("Skipping test on failing key %s", key);
               } else {
                  List<Address> owners = hash.locateOwners(key);
                  for (Map.Entry<Address, Cache<Object, Object>> e : cacheMap.entrySet()) {
                     try {
                        if (owners.contains(e.getKey())) DistributionTestHelper.assertIsInContainerImmortal(e.getValue(), key);
                        // Don't bother testing non-owners since invalidations caused by rehashing are async!
                     } catch (Throwable th) {
View Full Code Here

   @Test (dependsOnMethods = "testServersDropped")
   public void testCollocatedKey() {
      ConsistentHash hash = manager(0).getCache(cacheName).getAdvancedCache().getDistributionManager().getConsistentHash();
      for (int i = 0; i < 1000; i++) {
         List<Address> addresses = hash.locateOwners(i);
         Object collocatedKey = keyAffinityService.getCollocatedKey(i);
         List<Address> addressList = hash.locateOwners(collocatedKey);
         assertEquals(addresses, addressList);
      }
   }
View Full Code Here

   public void testCollocatedKey() {
      ConsistentHash hash = manager(0).getCache(cacheName).getAdvancedCache().getDistributionManager().getConsistentHash();
      for (int i = 0; i < 1000; i++) {
         List<Address> addresses = hash.locateOwners(i);
         Object collocatedKey = keyAffinityService.getCollocatedKey(i);
         List<Address> addressList = hash.locateOwners(collocatedKey);
         assertEquals(addresses, addressList);
      }
   }

   public class KeyConsumer extends Thread {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.