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() && !isValueAvailableLocally(ch, 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

   @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

            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

      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

   @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

      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

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.