Package org.infinispan.distribution

Examples of org.infinispan.distribution.MagicKey


      cache0.getComponentRegistry().registerComponent(crm, RpcManager.class);
      cache0.getComponentRegistry().rewire();
      crm.blockBefore(PutKeyValueCommand.class);

      // Try to put a key/value from cache0 with cache1 the primary owner
      final MagicKey key = new MagicKey(cache1);
      Future<Object> future = fork(new Callable<Object>() {
         @Override
         public Object call() throws Exception {
            return conditional ? cache0.putIfAbsent(key, "v") : cache0.put(key, "v");
         }
View Full Code Here


      BlockingInterceptor blockingInterceptor2 = new BlockingInterceptor(beforeCache2Barrier,
      op.getCommandClass(), true);
      cache2.addInterceptorBefore(blockingInterceptor2, NonTxConcurrentDistributionInterceptor.class);


      final MagicKey key = getKeyForCache2();

      // Prepare for replace: put a previous value in cache0 and cache1
      if (op.getPreviousValue() != null) {
         cache0.withFlags(Flag.CACHE_MODE_LOCAL).put(key, op.getPreviousValue());
         cache1.withFlags(Flag.CACHE_MODE_LOCAL).put(key, op.getPreviousValue());
View Full Code Here

      assertEquals(op.getValue(), cache2.get(key));

   }

   private MagicKey getKeyForCache2() {
      return new MagicKey(cache(0), cache(1), cache(2));
   }
View Full Code Here

      BlockingInterceptor blockingInterceptor = new BlockingInterceptor(distInterceptorBarrier, PutKeyValueCommand.class, false);
      cache0.addInterceptorBefore(blockingInterceptor, NonTxConcurrentDistributionInterceptor.class);

      for (int i = 0; i < NUM_KEYS; i++) {
         // Try to put a key/value from cache0 with cache1 the primary owner
         final MagicKey key = new MagicKey("key" + i, cache1);
         Future<Object> future = fork(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
               return conditional ? cache0.putIfAbsent(key, "v") : cache0.put(key, "v");
            }
View Full Code Here

      });

      CacheTopology duringJoinTopology = ltm0.getCacheTopology(CACHE_NAME);
      assertEquals(duringJoinTopologyId, duringJoinTopology.getTopologyId());
      assertNotNull(duringJoinTopology.getPendingCH());
      final MagicKey key = getKeyForCache2(duringJoinTopology.getPendingCH());
      log.tracef("Rebalance started. Found key %s with current owners %s and pending owners %s", key,
            duringJoinTopology.getCurrentCH().locateOwners(key), duringJoinTopology.getPendingCH().locateOwners(key));

      // Every PutKeyValueCommand will be blocked before reaching the distribution interceptor on cache1
      CyclicBarrier beforeCache1Barrier = new CyclicBarrier(2);
View Full Code Here

      assertEquals("v", cache2.get(key));
   }

   private MagicKey getKeyForCache2(ConsistentHash pendingCH) {
      int attemptsLeft = 1000;
      MagicKey key;
      do {
         key = new MagicKey("key", cache(0));
         attemptsLeft--;
      } while (!pendingCH.locatePrimaryOwner(key).equals(address(2)) && attemptsLeft > 0);

      if (attemptsLeft <= 0) {
         throw new IllegalStateException("Can't find a key that will map to " + address(2) + " after rebalance!");
View Full Code Here

      DummyInMemoryCacheStore cs = (DummyInMemoryCacheStore) getCacheStore(cache);
      return cs.stats().get(cacheStoreMethod);
   }

   public void testRehashes() throws CacheLoaderException {
      MagicKey k = new MagicKey("k", c1);

      c1.put(k, "v");

      Cache<Object, String>[] owners = getOwners(k);
      log.infof("Initial owners list for key %s: %s", k, Arrays.asList(owners));
View Full Code Here

      createCluster(builder, 4);
      waitForClusterToForm();
   }

   public void testOldStateResponse() throws Throwable {
      MagicKey k1 = new MagicKey("k1", cache(1));
      MagicKey k2 = new MagicKey("k2", cache(2));
      MagicKey k3 = new MagicKey("k3", cache(3));
      cache(1).put(k1, "v1");
      cache(2).put(k2, "v2");
      cache(3).put(k3, "v3");

      final StateTransferManager stm = cache(0).getAdvancedCache().getComponentRegistry().getStateTransferManager();
View Full Code Here

      assertTrue(dataContainer.containsKey(k2));
      assertTrue(dataContainer.containsKey(k3));
   }

   public void testStateResponseWhileRestartingBrokenTransfers() throws Throwable {
      MagicKey k1 = new MagicKey("k1", cache(1), cache(2), cache(3));
      cache(0).put(k1, "v1");

      final StateTransferManager stm = cache(0).getAdvancedCache().getComponentRegistry().getStateTransferManager();
      final int initialTopologyId = stm.getCacheTopology().getTopologyId();
View Full Code Here

*/
@Test(groups = "functional", testName = "atomic.ReplWriteSkewAtomicMapAPITest")
public class ReplWriteSkewAtomicMapAPITest extends RepeatableReadAtomicMapAPITest {

   public void testWriteSkewOnPrimaryOwner() throws Exception {
      doWriteSkewTest(cache(0, "atomic"), new MagicKey(cache(0, "atomic"), cache(1, "atomic")), caches("atomic"));
   }
View Full Code Here

TOP

Related Classes of org.infinispan.distribution.MagicKey

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.