Package org.infinispan.distribution

Examples of org.infinispan.distribution.DistributionManager


      }
      return chosen;
   }

   protected <K> Map<Address, List<K>> keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input) {
      DistributionManager dm = cache.getDistributionManager();
      Map<Address, List<K>> addressToKey = new HashMap<Address, List<K>>(input.length * 2);
      boolean usingREPLMode = dm == null;
      for (K key : input) {
         Address ownerOfKey = null;
         if (usingREPLMode) {
            List<Address> members = new ArrayList<Address>(getMembers());
            members =  filterMembers(policy, members);
            // using REPL mode https://issues.jboss.org/browse/ISPN-1886
            // since keys and values are on all nodes, lets just pick randomly
            Collections.shuffle(members);
            ownerOfKey = members.get(0);
         } else {
            // DIST mode
            List<Address> owners = dm.locate(key);
            List<Address> filtered = filterMembers(policy, owners);
            if(!filtered.isEmpty()){
               ownerOfKey = filtered.get(0);
            } else {
               ownerOfKey = owners.get(0);
View Full Code Here


    * @see org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager#isLocal(java.lang.String)
    */
   @Override
   public boolean isLocal(String realId)
   {
      DistributionManager manager = this.sessionCache.getAdvancedCache().getDistributionManager();
     
      return (manager != null) ? manager.isLocal(realId) : true;
   }
View Full Code Here

    */
   @Override
   public String locate(String sessionId)
   {
      AdvancedCache<?, ?> cache = this.sessionCache.getAdvancedCache();
      DistributionManager manager = cache.getDistributionManager();
     
      if ((manager != null) && !manager.isRehashInProgress())
      {
         EmbeddedCacheManager container = (EmbeddedCacheManager) cache.getCacheManager();
         Cache<Address, String> jvmRouteCache = this.getJvmRouteCache(container);
        
         for (Address address: manager.locate(sessionId))
         {
            String jvmRoute = jvmRouteCache.get(address);
           
            if (jvmRoute != null)
            {
View Full Code Here

    */
   private StatefulBeanContext create()
   {
      StatefulBeanContext bean = (StatefulBeanContext) this.container.createBeanContext();
     
      DistributionManager manager = this.cache.getAdvancedCache().getDistributionManager();
     
      if (manager != null)
      {
         // If using distribution mode, ensure that bean will cache locally
         while (!manager.isLocal(bean.getId()))
         {
            bean = new InfinispanStatefulBeanContext(this.container, bean.getInstance());
         }
      }

View Full Code Here

         throw new IllegalStateException("Temporary cache for MapReduceTask " + taskId
                  + " named " + tmpCacheName + " not found on " + cdl.getAddress());
      }

      Set<KOut> mapPhaseKeys = new HashSet<KOut>();
      DistributionManager dm = tmpCache.getAdvancedCache().getDistributionManager();
      boolean emitCompositeIntermediateKeys = mcc.isEmitCompositeIntermediateKeys();
      Map<Address, List<KOut>> keysToNodes = mapKeysToNodes(dm, taskId, collectedValues.keySet(),
            emitCompositeIntermediateKeys);
      long start = log.isTraceEnabled() ? timeService.time() : 0;
      try {
View Full Code Here

      }
      return chosen;
   }

   protected <K> Map<Address, List<K>> keysToExecutionNodes(DistributedTaskExecutionPolicy policy, K... input) {
      DistributionManager dm = cache.getDistributionManager();
      Map<Address, List<K>> addressToKey = new HashMap<Address, List<K>>(input.length * 2);
      boolean usingREPLMode = dm == null;
      for (K key : input) {
         Address ownerOfKey = null;
         if (usingREPLMode) {
            List<Address> members = new ArrayList<Address>(getMembers());
            members =  filterMembers(policy, members);
            // using REPL mode https://issues.jboss.org/browse/ISPN-1886
            // since keys and values are on all nodes, lets just pick randomly
            Collections.shuffle(members);
            ownerOfKey = members.get(0);
         } else {
            // DIST mode
            List<Address> owners = dm.locate(key);
            List<Address> filtered = filterMembers(policy, owners);
            if(!filtered.isEmpty()){
               ownerOfKey = filtered.get(0);
            } else {
               ownerOfKey = owners.get(0);
View Full Code Here

   private List<Address> getExistingNodes() {
      return cache.getAdvancedCache().getRpcManager().getTransport().getMembers();
   }

   private Address getAddressForKey(Object key) {
      DistributionManager distributionManager = getDistributionManager();
      ConsistentHash hash = distributionManager.getConsistentHash();
      List<Address> addressList = hash.locate(key, 1);
      if (addressList.size() == 0) {
         throw new IllegalStateException("Empty address list returned by consistent hash " + hash + " for key " + key);
      }
      return addressList.get(0);
View Full Code Here

      }
      return addressList.get(0);
   }

   private DistributionManager getDistributionManager() {
      DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
      if (distributionManager == null) {
         throw new IllegalStateException("Null distribution manager. Is this an distributed(v.s. replicated) cache?");
      }
      return distributionManager;
   }
View Full Code Here

   public JoinHandle howToHandle(CacheRpcCommand cmd) {
      Configuration localConfig = cmd.getConfiguration();
      ComponentRegistry cr = cmd.getComponentRegistry();

      if (localConfig.getCacheMode().isDistributed()) {
         DistributionManager dm = cr.getComponent(DistributionManager.class);
         if (dm.isJoinComplete())
            return JoinHandle.OK;
         else {
            // no point in enqueueing clustered GET commands - just ignore these and hope someone else in the cluster responds.
            if (!(cmd instanceof ClusteredGetCommand))
               return JoinHandle.QUEUE;
View Full Code Here

         log.localExecutionFailed(e1);
      }
   }

   protected <K> Map<Address, List<K>> mapKeysToNodes(K... input) {
      DistributionManager dm = cache.getDistributionManager();
      Map<Address, List<K>> addressToKey = new HashMap<Address, List<K>>();
      for (K key : input) {
         List<Address> nodesForKey = dm.locate(key);
         Address ownerOfKey = nodesForKey.get(0);
         List<K> keysAtNode = addressToKey.get(ownerOfKey);
         if (keysAtNode == null) {
            keysAtNode = new ArrayList<K>();
            addressToKey.put(ownerOfKey, keysAtNode);
View Full Code Here

TOP

Related Classes of org.infinispan.distribution.DistributionManager

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.