Package org.infinispan.topology

Examples of org.infinispan.topology.CacheTopology$Externalizer


      Set<Integer> seg = new HashSet<Integer>(Arrays.asList(0));

      assertFalse(stateConsumer.isStateTransferInProgress());

      stateConsumer.onTopologyUpdate(new CacheTopology(1, ch2, null), false);
      assertTrue(stateConsumer.isStateTransferInProgress());

      stateConsumer.onTopologyUpdate(new CacheTopology(2, ch2, ch3), true);
      assertTrue(stateConsumer.isStateTransferInProgress());

      stateConsumer.stop();
      assertFalse(stateConsumer.isStateTransferInProgress());
   }
View Full Code Here


         StateConsumer stateConsumer = extractComponent(c, StateConsumer.class);
         StateTransferLock stateTransferLock = extractComponent(c, StateTransferLock.class);
         DefaultRebalancePolicy rebalancePolicy = (DefaultRebalancePolicy) TestingUtil.extractGlobalComponent(c.getCacheManager(), RebalancePolicy.class);
         Address cacheAddress = c.getAdvancedCache().getRpcManager().getAddress();
         while (true) {
            CacheTopology cacheTopology = stateTransferManager.getCacheTopology();
            boolean chContainsAllMembers = cacheTopology.getCurrentCH().getMembers().size() == caches.length;
            boolean chIsBalanced = cacheTopology.getPendingCH() == null && rebalancePolicy.isBalanced(cacheTopology.getCurrentCH());
            if (chContainsAllMembers && chIsBalanced) {
               // This is the part where we wait for the old entries to be invalidated
               // because the "transaction data received" flag is only set after the invalidation.
               try {
                  stateTransferLock.waitForTransactionData(cacheTopology.getTopologyId());
               } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
               }
               break;
            }

            if (System.currentTimeMillis() > giveup) {
               String message;
               if (!chContainsAllMembers) {
                  Address[] addresses = new Address[caches.length];
                  for (int i = 0; i < caches.length; i++) {
                     addresses[i] = caches[i].getCacheManager().getAddress();
                  }
                  message = String.format("Timed out waiting for rebalancing to complete on node %s, " +
                        "expected member list is %s, current member list is %s!",
                        cacheAddress, Arrays.toString(addresses), cacheTopology.getCurrentCH().getMembers());
               } else {
                  message = String.format("Timed out waiting for rebalancing to complete on node %s, " +
                        "current topology is %s", c.getCacheManager().getAddress(), cacheTopology);
               }
               log.error(message);
View Full Code Here

   public boolean isStateTransferInProgressForKey(Object key) {
      if (configuration.clustering().cacheMode().isInvalidation()) {
         return false;
      }
      synchronized (this) {
         CacheTopology localCacheTopology = cacheTopology;
         if (localCacheTopology == null || localCacheTopology.getPendingCH() == null)
            return false;
         Address address = rpcManager.getAddress();
         boolean keyWillBeLocal = localCacheTopology.getPendingCH().isKeyLocalToNode(address, key);
         boolean keyIsLocal = localCacheTopology.getCurrentCH().isKeyLocalToNode(address, key);
         return keyWillBeLocal && !keyIsLocal;
      }
   }
View Full Code Here

      return t != null ? t.getAddress() : null;
   }

   @Override
   public int getTopologyId() {
      CacheTopology cacheTopology = stateTransferManager.getCacheTopology();
      return cacheTopology != null ? cacheTopology.getTopologyId() : -1;
   }
View Full Code Here

      currentCH = new GroupingConsistentHash(currentCH, groupManager);
      ConsistentHash pendingCH = cacheTopology.getPendingCH();
      if (pendingCH != null) {
         pendingCH = new GroupingConsistentHash(pendingCH, groupManager);
      }
      return new CacheTopology(cacheTopology.getTopologyId(), currentCH, pendingCH);
   }
View Full Code Here

      }

      // handle grouping
      newCacheTopology = addGrouping(newCacheTopology);

      CacheTopology oldCacheTopology = stateConsumer.getCacheTopology();

      if (oldCacheTopology != null && oldCacheTopology.getTopologyId() > newCacheTopology.getTopologyId()) {
         throw new IllegalStateException("Old topology is higher: old=" + oldCacheTopology + ", new=" + newCacheTopology);
      }

      ConsistentHash oldCH = oldCacheTopology != null ? oldCacheTopology.getWriteConsistentHash() : null;
      ConsistentHash newCH = newCacheTopology.getWriteConsistentHash();

      // TODO Improve notification to contain both CHs
      cacheNotifier.notifyTopologyChanged(oldCH, newCH, newCacheTopology.getTopologyId(), true);
View Full Code Here

      return stateConsumer.getCacheTopology();
   }

   @Override
   public boolean isLocalNodeFirst() {
      CacheTopology cacheTopology = stateConsumer.getCacheTopology();
      if (cacheTopology == null || cacheTopology.getMembers().isEmpty()) {
         throw new IllegalStateException("Can only check if the local node is the first to join after joining");
      }

      return cacheTopology.getMembers().get(0).equals(rpcManager.getAddress());
   }
View Full Code Here

   @Override
   public void forwardCommandIfNeeded(TopologyAffectedCommand command, Set<Object> affectedKeys, Address origin, boolean sync) {
      int cmdTopologyId = command.getTopologyId();
      // forward commands with older topology ids to their new targets
      // but we need to make sure we have the latest topology
      CacheTopology cacheTopology = getCacheTopology();
      int localTopologyId = cacheTopology != null ? cacheTopology.getTopologyId() : -1;
      // if it's a tx/lock/write command, forward it to the new owners
      log.tracef("CommandTopologyId=%s, localTopologyId=%s", cmdTopologyId, localTopologyId);

      if (cmdTopologyId < localTopologyId) {
         ConsistentHash writeCh = cacheTopology.getWriteConsistentHash();
         Set<Address> newTargets = new HashSet<Address>(writeCh.locateAllOwners(affectedKeys));
         newTargets.remove(rpcManager.getAddress());
         // Forwarding to the originator would create a cycle
         // TODO This may not be the "real" originator, but one of the original recipients
         // or even one of the nodes that one of the original recipients forwarded the command to.
View Full Code Here

            configuration.clustering().hash().numOwners(),
            configuration.clustering().stateTransfer().timeout(),
            configuration.transaction().transactionProtocol().isTotalOrder(),
            configuration.clustering().cacheMode().isDistributed());

      CacheTopology initialTopology = localTopologyManager.join(cacheName, joinInfo, new CacheTopologyHandler() {
         @Override
         public void updateConsistentHash(CacheTopology cacheTopology) {
            doTopologyUpdate(cacheTopology, false);
         }
View Full Code Here

      currentCH = new GroupingConsistentHash(currentCH, groupManager);
      ConsistentHash pendingCH = cacheTopology.getPendingCH();
      if (pendingCH != null) {
         pendingCH = new GroupingConsistentHash(pendingCH, groupManager);
      }
      return new CacheTopology(cacheTopology.getTopologyId(), currentCH, pendingCH);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.topology.CacheTopology$Externalizer

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.