Package org.infinispan.distribution.ch

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


      cache(0).put(key, value);

      ConsistentHash ch = cache(0).getAdvancedCache().getComponentRegistry()
            .getStateTransferManager().getCacheTopology().getCurrentCH();
      List<Address> members = new ArrayList<Address>(ch.getMembers());
      List<Address> owners = ch.locateOwners(key);
      members.removeAll(owners);
      int nonOwner = ch.getMembers().indexOf(members.get(0));
      final Cache<Object, Object> c = cache(nonOwner);

      List<Cache<Object, Object>> partition1 = caches();
View Full Code Here


      if (entry == null || entry.isNull()) {
         Object key = command.getKey();
         ConsistentHash ch = stateTransferManager.getCacheTopology().getReadConsistentHash();
         shouldFetchFromRemote = ctx.isOriginLocal() && !ch.isKeyLocalToNode(rpcManager.getAddress(), key) && !dataContainer.containsKey(key);
         if (!shouldFetchFromRemote && getLog().isTraceEnabled()) {
            getLog().tracef("Not doing a remote get for key %s since entry is mapped to current node (%s) or is in L1. Owners are %s", toStr(key), rpcManager.getAddress(), ch.locateOwners(key));
         }
      }
      return shouldFetchFromRemote;
   }
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

            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

      }
   }

   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

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.