Package org.infinispan.distexec

Examples of org.infinispan.distexec.DefaultExecutorService$RemoteDistributedTaskPart


            TestKey key = new TestKey(random.nextInt(KEY_RANGE));
            try {

                log.info("Submitting a task " + key);
                EmbeddedCacheManager cacheManager = cacheManagers.get(random.nextInt(cacheManagers.size()));
                DistributedExecutorService ispnExecutor = new DefaultExecutorService(cacheManager.getCache("serviceGroup"));

                Future<String> z = ispnExecutor.submit(new TransactionTask(), key);
                log.info("Task result=" + z.get());
            } catch (Exception ex) {
                log.warn("error during executing task " + key, ex);
            }
        }
View Full Code Here


   public void setEnvironment(Cache<K, V> cache, Set<K> inputKeys) {
      cacheManager = cache.getCacheManager();
      cacheNotifier = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheNotifier.class);
      cacheManagerNotifier = cache.getCacheManager().getGlobalComponentRegistry().getComponent(
            CacheManagerNotifier.class);
      distExecutor = new DefaultExecutorService(cache, new WithinThreadExecutor());
      ourAddress = cache.getCacheManager().getAddress();
   }
View Full Code Here

      this.cache = cache;
   }

   @Override
   public DefaultExecutorService run() {
      return new DefaultExecutorService(cache, new WithinThreadExecutor());
   }
View Full Code Here

      });
   }

   private void distExecTest() throws Exception {
      DefaultExecutorService des = new DefaultExecutorService(cache(0, EXECUTION_CACHE));
      NotifyingFuture<Integer> future = des.submit(new SimpleCallable());
      assertEquals(Integer.valueOf(1), future.get());
   }
View Full Code Here

      this.cache = cache;
   }

   public static <K, V> Set<K> getGlobalKeySet(Cache<K, V> cache) throws InterruptedException, ExecutionException {
      if (cache.getCacheConfiguration().clustering().cacheMode().isDistributed()) {
         DefaultExecutorService des = new DefaultExecutorService(cache);
         List<Future<Set<K>>> fk = des.submitEverywhere(new GlobalKeySetTask<K, V>());
         Set<K> allKeys = new HashSet<K>();
         for(Future<Set<K>> f : fk) {
            allKeys.addAll(f.get());
         }
         return allKeys;
View Full Code Here

      try {
         if (isMaster) {
            int numServers = cache.getCacheManager().getMembers().size();
            int numberPerWorker = numPoints / numServers;

            DistributedExecutorService des = new DefaultExecutorService(cache);

            long start = System.currentTimeMillis();
            List<Future<Integer>> results = des.submitEverywhere(new CircleTest(numberPerWorker));

            int insideCircleCount = 0;

            for (Future<Integer> f : results) insideCircleCount += f.get();
View Full Code Here

      });
   }

   private void distExecTest() throws Exception {
      DefaultExecutorService des = new DefaultExecutorService(cache(0, EXECUTION_CACHE));
      NotifyingFuture<Integer> future = des.submit(new SimpleCallable());
      assertEquals(Integer.valueOf(1), future.get());
   }
View Full Code Here

            // If cache mode is LOCAL or REPL, dump local keyset.
            // Defensive copy to serialize and transmit across a network
            keys = new HashSet<Object>(cache.keySet());
         } else {
            // If cache mode is DIST, use a map/reduce task
            DistributedExecutorService des = new DefaultExecutorService(cache);
            List<Future<Set<Object>>> keysets = des.submitEverywhere(new GlobalKeysetTask(cache));
            Set<Object> combinedKeyset = new HashSet<Object>();

            for (Future<Set<Object>> keyset : keysets)
               combinedKeyset.addAll(keyset.get());
View Full Code Here

   @Override
   public List<Future<T>> executeDistributedTask(String distributedCallableFqn,
                                                 String executionPolicyName, String failoverPolicyFqn, String nodeAddress, Map<String, String> params) {

      Cache<K, V> cache = (Cache<K, V>) service.getCache(null);
      DistributedExecutorService des = new DefaultExecutorService(cache);
      Callable<T> callable = null;
      DistributedTaskBuilder<T> taskBuilder = null;
      List<Future<T>> result = null;
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

      if (distributedCallableFqn == null) {
         log.fatal("The distributedCallableFqn parameter must be specified.");
      } else {
         try {
            callable = Utils.instantiate(classLoader, distributedCallableFqn);
            taskBuilder = des.createDistributedTaskBuilder(callable);
            callable = (Callable<T>) Utils.invokeMethodWithString(callable, params);
         } catch (Exception e1) {
            throw (new IllegalArgumentException("Could not instantiate '" + distributedCallableFqn + "' as a Callable",
                  e1));
         }
      }

      if (callable != null) {
         if (executionPolicyName != null) {
            DistributedTaskExecutionPolicy executionPolicy = Enum.valueOf(DistributedTaskExecutionPolicy.class,
                  executionPolicyName);
            if (executionPolicy == null) {
               log.error("No DistributedTaskExecutionPolicy found with name: " + executionPolicyName);
            } else {
               taskBuilder = taskBuilder.executionPolicy(executionPolicy);
            }
         }

         if (failoverPolicyFqn != null) {
            try {
               DistributedTaskFailoverPolicy failoverPolicy = Utils.instantiate(classLoader, failoverPolicyFqn);
               taskBuilder = taskBuilder.failoverPolicy(failoverPolicy);
            } catch (Exception e) {
               log.error("Could not instantiate DistributedTaskFailoverPolicy class: " + failoverPolicyFqn, e);
            }
         }

         if (nodeAddress != null) {
            Address target = findHostPhysicalAddress(nodeAddress);
            if (target == null) {
               log.error("No host found with address: " + nodeAddress);
            } else {
               result = new ArrayList<Future<T>>();
               result.add(des.submit(target, taskBuilder.build()));
            }
         } else {
            result = des.submitEverywhere(taskBuilder.build());
         }
      }

      return result;
   }
View Full Code Here

      }

      @Override
      public long getTotalSize() {
         long totalSize = 0;
         DistributedExecutorService des = new DefaultExecutorService(cache);
         CacheSizer<?, ?, Integer> cacheSizer = new CacheSizer<Object, Object, Integer>();
         DistributedTaskBuilder<Integer> taskBuilder = des.createDistributedTaskBuilder(cacheSizer);
         List<Future<Integer>> futureList = des.submitEverywhere(taskBuilder.build());
        
         for (Future<Integer> future : futureList) {
            try {
               totalSize += future.get().intValue();
            } catch (InterruptedException e) {
View Full Code Here

TOP

Related Classes of org.infinispan.distexec.DefaultExecutorService$RemoteDistributedTaskPart

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.