Package org.infinispan.distribution

Examples of org.infinispan.distribution.DistributionManager


    * @see org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager#isLocal(java.lang.String)
    */
   @Override
   public boolean isLocal(String sessionId)
   {
      DistributionManager manager = this.sessionCache.getAdvancedCache().getDistributionManager();
     
      return (manager != null) ? manager.isLocal(sessionId) : 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 = getJvmRouteCache(container, this.manager);
        
         for (Address address: manager.locate(sessionId))
         {
            String jvmRoute = jvmRouteCache.get(address);
           
            if (jvmRoute != null)
            {
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>>(input.length * 2);
      boolean usingREPLMode = dm == null;     
      List<Address> members = null;
      if(usingREPLMode){
         members = new ArrayList<Address>(cache.getRpcManager().getTransport().getMembers());
      }
      for (K key : input) {
         Address ownerOfKey = null;
         if(usingREPLMode){
            //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
            ownerOfKey = dm.getPrimaryLocation(key);
         }
         List<K> keysAtNode = addressToKey.get(ownerOfKey);
         if (keysAtNode == null) {
            keysAtNode = new LinkedList<K>();
            addressToKey.put(ownerOfKey, keysAtNode);
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

            MapCombineCommand<KIn, VIn, KOut, VOut> mcc) throws InterruptedException {
      Cache<KIn, VIn> cache = cacheManager.getCache(mcc.getCacheName());
      Set<KIn> keys = mcc.getKeys();
      Set<KIn> inputKeysCopy = null;
      Mapper<KIn, VIn, KOut, VOut> mapper = mcc.getMapper();
      DistributionManager dm = cache.getAdvancedCache().getDistributionManager();
      boolean inputKeysSpecified = keys != null && !keys.isEmpty();
      Set <KIn> inputKeys = keys;
      if (!inputKeysSpecified) {
         inputKeys = filterLocalPrimaryOwner(cache.keySet(), dm);
      } else {
View Full Code Here

      }
      if (tmpCache == null) {
         throw new IllegalStateException("Temporary cache for MapReduceTask " + taskId
                  + " not found on " + cdl.getAddress());
      }
      DistributionManager dm = tmpCache.getAdvancedCache().getDistributionManager();

      if (combiner != null) {
         Cache<?, ?> cache = cacheManager.getCache(mcc.getCacheName());
         log.tracef("For m/r task %s invoking combiner %s at %s",  taskId, mcc, cdl.getAddress());
         MapReduceTaskLifecycleService taskLifecycleService = MapReduceTaskLifecycleService.getInstance();
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

      log.infof("Initialized with keys %s", keys);
     
      EmbeddedCacheManager joinerManager = addClusterEnabledCacheManager();
      joinerManager.defineConfiguration(cacheName, configuration.build());
      Cache joiner = joinerManager.getCache(cacheName);
      DistributionManager dmi = joiner.getAdvancedCache().getDistributionManager();
      assert dmi.isJoinComplete();
   }
View Full Code Here

   }

   private void assertEvenDistribution() {
      for (int i = 0; i < getCacheManagers().size(); i++) {
         Cache<String, String> testCache = manager(i).getCache(testCacheName);
         DistributionManager dm = testCache.getAdvancedCache().getDistributionManager();
         // Note there is stale data in the cache store that this owner no longer owns
         for (Object key : testCache.getAdvancedCache().getDataContainer().keySet()) {
            // each key must only occur once (numOwners is one)
            assertTrue("Key '" + key + "' is not owned by node " + address(i) + " but it still appears there",
                  dm.getLocality(key).isLocal());
         }
      }
   }
View Full Code Here

      if (keyData.getCacheName() != null) {
         cache = (Cache<Object, Object>) session.getCache(keyData.getCacheName());
      } else {
         cache = (Cache<Object, Object>) session.getCache();
      }
      DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
      if(distributionManager!=null) {
         List<Address> addresses = distributionManager.locate(keyData.getKey());
         return new StringResult(addresses.toString());
      } else {
         throw new StatementException("Cache is not distributed");
      }
   }
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.