Package org.infinispan.distexec

Examples of org.infinispan.distexec.DefaultExecutorService


            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;
   }

   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

   }

   @Override
   public void start() {
      super.start();
      this.distExecutorService = new DefaultExecutorService(cache, new WithinThreadExecutor());
   }
View Full Code Here

            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

                                       Location location,
                                       DistributedCallable<K, V, T> callable,
                                       Combiner<T> combiner ) throws InterruptedException, ExecutionException {
        if (location == null) location = Location.LOCALLY;

        DistributedExecutorService distributedExecutor = new DefaultExecutorService(cache);
        List<StoreConfiguration> stores = cache.getCacheConfiguration().persistence().stores();
        boolean shared = (stores != null) && !stores.isEmpty() && stores.get(0).shared();
        T result = null;
        if (!shared) {
            // store is not shared so every node must return key list of the store
            List<Future<T>> futures = null;
            switch (location) {
                case EVERYWHERE:
                    futures = distributedExecutor.submitEverywhere(callable);
                    break;
                case LOCALLY:
                    futures = Collections.singletonList(distributedExecutor.submit(callable));
                    break;
            }

            while (futures != null && !futures.isEmpty()) {
                // Get the next future that is ready ...
                Iterator<Future<T>> futureIter = futures.iterator();
                while (futureIter.hasNext()) {
                    Future<T> future = futureIter.next();
                    try {
                        // But done't wait too long for this future ...
                        T value = future.get(100, TimeUnit.MILLISECONDS);
                        // We got some keys, so this future is done and should be removed from our list ...
                        futureIter.remove();
                        result = combiner.combine(result, value);
                    } catch (TimeoutException e) {
                        // continue;
                    }
                }
                if (futures.isEmpty()) break;
            }
        } else {
            // store is shared, so we can short-circuit the logic and just run locally; otherwise, if distributed
            // each process will see the all of the keys ...
            result = distributedExecutor.submit(callable).get();
        }
        return result;
    }
View Full Code Here

   static DefaultExecutorService getDefaultExecutorService(final Cache<?, ?> cache) {
      if (System.getSecurityManager() != null) {
         return AccessController.doPrivileged(new PrivilegedAction<DefaultExecutorService>() {
            @Override
            public DefaultExecutorService run() {
               return new DefaultExecutorService(cache, new WithinThreadExecutor());
            }
         });
      } else {
         return new DefaultExecutorService(cache, new WithinThreadExecutor());
      }
   }
View Full Code Here

            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

      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

TOP

Related Classes of org.infinispan.distexec.DefaultExecutorService

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.