当前位置: 首页>>代码示例>>Java>>正文


Java DefaultExecutorService类代码示例

本文整理汇总了Java中org.infinispan.distexec.DefaultExecutorService的典型用法代码示例。如果您正苦于以下问题:Java DefaultExecutorService类的具体用法?Java DefaultExecutorService怎么用?Java DefaultExecutorService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultExecutorService类属于org.infinispan.distexec包,在下文中一共展示了DefaultExecutorService类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.infinispan.distexec.DefaultExecutorService; //导入依赖的package包/类
public static void main(String[] args) {
   // Setup up a clustered cache manager
   GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
   // Make the default cache a distributed one
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.clustering().cacheMode(CacheMode.DIST_SYNC);
   // Initialize the cache manager
   DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
   // Obtain the default cache
   Cache<String, String> cache = cacheManager.getCache();
   // Create a distributed executor service using the distributed cache to determine the nodes on which to run
   DefaultExecutorService executorService = new DefaultExecutorService(cache);
   // Submit a job to all nodes
   List<Future<Integer>> results = executorService.submitEverywhere((Callable & Serializable) () -> new Random().nextInt());
   // Print out the results
   results.forEach(s -> {
      try {
         System.out.printf("%s\n", s.get(100, TimeUnit.MILLISECONDS));
      } catch (Exception e) {
      }
   });
   // Shuts down the cache manager and all associated resources
   cacheManager.stop();
   System.exit(0);
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:26,代码来源:InfinispanDistExec.java

示例2: submitDistributable

import org.infinispan.distexec.DefaultExecutorService; //导入依赖的package包/类
@Override
public List<Future<Long>> submitDistributable(String cacheName,
                                              Callable<Long> callable,
                                              String... keys)
{
    Cache c = getCache(cacheName);

    DistributedExecutorService des  = new DefaultExecutorService(c);

    return des.submitEverywhere(callable, keys);

    // TODO executors will probably leak, find a better solution where I shut down an
    // executor that is not in use anymore.
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:15,代码来源:ProcessingNode.java

示例3: execute

import org.infinispan.distexec.DefaultExecutorService; //导入依赖的package包/类
@Override
public void execute() throws Exception
{
    Cache c = ca.getCache("SOURCE-CACHE");

    DistributedExecutorService des = new DefaultExecutorService(c);

    Callable callable = new ExampleDistributedCallable();
    //Callable<String> callable = new ExampleCallable<String>();

    List<Future<DistributedCallableResponse>> results = null;

    if (submitEverywhere)
    {
        if (keys.isEmpty())
        {
            System.out.println("> submitting everywhere, no input keys");
            results = des.submitEverywhere(callable);
            System.out.println("> submission everywhere, no input keys, ok");
        }
        else
        {
            results = des.submitEverywhere(callable, keys);
            System.out.println("> submission to all nodes ok, key set " + keys);
        }
    }
    else
    {
        Future<DistributedCallableResponse> result = des.submit(callable, keys);
        System.out.println("> submission to one node ok, key set " + keys);
        results = Arrays.asList(result);
    }

    for (Future<DistributedCallableResponse> f : results)
    {
        System.out.println("> got response from " + f.get().getNodeName());
    }

    System.out.println("> execution ok");
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:41,代码来源:LaunchDistributedCallable.java

示例4: rot

import org.infinispan.distexec.DefaultExecutorService; //导入依赖的package包/类
public List<Future> rot(int offset) {
    DistributedExecutorService des = new DefaultExecutorService(cache);
    return des.submitEverywhere(new Rotate(offset));
}
 
开发者ID:ugol,项目名称:jdg-playground,代码行数:5,代码来源:JDG.java


注:本文中的org.infinispan.distexec.DefaultExecutorService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。