• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TaskContextImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: process

import org.infinispan.persistence.TaskContextImpl; //导入依赖的package包/类
@Override
public void process(final KeyFilter<? super K> filter, final CacheLoaderTask<K, V> task, Executor executor, boolean fetchValue, boolean fetchMetadata) {
   ExecutorAllCompletionService eacs = new ExecutorAllCompletionService(executor);
   final TaskContextImpl taskContext = new TaskContextImpl();

   //A while loop since we have to hit the db again for paging.
   boolean shouldContinue = true;
   byte[] id = null;
   while (shouldContinue) {
      final List<MongoDBEntry<K, V>> entries = cache.getPagedEntries(id);
      shouldContinue = !entries.isEmpty();
      if (taskContext.isStopped()) {
         break;
      }
      if (shouldContinue) {
         eacs.submit(() -> {
            for (final MongoDBEntry<K, V> entry : entries) {
               if (taskContext.isStopped()) {
                  break;
               }
               final K marshalledKey = (K) toObject(entry.getKeyBytes());
               if (filter == null || filter.accept(marshalledKey)) {
                  final MarshalledEntry<K, V> marshalledEntry = getMarshalledEntry(entry);
                  if (marshalledEntry != null) {
                     task.processEntry(marshalledEntry, taskContext);
                  }
               }
            }
            return null;
         });
         //get last key so we can get more entries.
         id = entries.get(entries.size() - 1).getKeyBytes();
      }
   }
   eacs.waitUntilAllCompleted();
   if (eacs.isExceptionThrown()) {
      throw new PersistenceException("Execution exception!", eacs.getFirstException());
   }

}
 
开发者ID:infinispan,项目名称:infinispan-cachestore-mongodb,代码行数:41,代码来源:MongoDBStore.java


示例2: process

import org.infinispan.persistence.TaskContextImpl; //导入依赖的package包/类
@Override
public void process(KeyFilter filter, CacheLoaderTask task, Executor executor, boolean fetchValue,
      boolean fetchMetadata) {
   int batchSize = 100;
   ExecutorCompletionService ecs = new ExecutorCompletionService(executor);
   int tasks = 0;
   final TaskContext taskContext = new TaskContextImpl();

   List<Map.Entry<Object, byte[]>> entries = new ArrayList<Map.Entry<Object, byte[]>>(batchSize);
   
   try {
      for (Map.Entry<Object, byte[]> entry : store.entrySet()) {
         entries.add(entry);
         if (entries.size() == batchSize) {
            final List<Map.Entry<Object, byte[]>> batch = entries;
            entries = new ArrayList<Map.Entry<Object, byte[]>>(batchSize);
            submitProcessTask(task, filter, ecs, taskContext, batch);
            tasks++;
         }
      }
      if (!entries.isEmpty()) {
         submitProcessTask(task, filter,ecs, taskContext, entries);
         tasks++;
      }

      PersistenceUtil.waitForAllTasksToComplete(ecs, tasks);
   } catch (Exception e) {
      throw new CacheLoaderException(e);
   }
}
 
开发者ID:saturnism,项目名称:infinispan-cachestore-mapdb,代码行数:31,代码来源:MapDBStore.java


示例3: process

import org.infinispan.persistence.TaskContextImpl; //导入依赖的package包/类
@Override
public void process(KeyFilter<? super K> keyFilter, final CacheLoaderTask<K, V> cacheLoaderTask, Executor executor,
      boolean loadValue, boolean loadMetadata) {
   String nextMarker = null;
   PageSet<? extends StorageMetadata> pageSet;

   do {
      ListContainerOptions listOptions = nextMarker == null ? ListContainerOptions.NONE
            : ListContainerOptions.Builder.afterMarker(nextMarker);

      pageSet = blobStore.list(containerName, listOptions);

      ExecutorAllCompletionService eacs = new ExecutorAllCompletionService(executor);
      final TaskContext taskContext = new TaskContextImpl();

      Set<Object> entries = new HashSet<Object>(BATCH_SIZE);

      Iterator<? extends StorageMetadata> storageMetadataIterator = pageSet.iterator();
      while (storageMetadataIterator.hasNext()) {
         StorageMetadata blobMetadata = storageMetadataIterator.next();
         K key = (K) key2StringMapper.getKeyMapping(blobMetadata.getName());
         if (keyFilter == null || keyFilter.accept(key)) {
            entries.add(key);
         }
         if (entries.size() == BATCH_SIZE) {
            final Set<Object> batch = entries;
            entries = new HashSet<Object>(BATCH_SIZE);
            submitProcessTask(cacheLoaderTask, eacs, taskContext, batch, loadValue, loadMetadata);
         }
      }

      if (!entries.isEmpty()) {
         submitProcessTask(cacheLoaderTask, eacs, taskContext, entries, loadValue, loadMetadata);
      }
      eacs.waitUntilAllCompleted();
      if (eacs.isExceptionThrown()) {
         throw new PersistenceException("Process execution exception!", eacs.getFirstException());
      }

      nextMarker = pageSet.getNextMarker();
   } while (nextMarker != null);
}
 
开发者ID:infinispan,项目名称:infinispan-cachestore-cloud,代码行数:43,代码来源:CloudStore.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Tree类代码示例发布时间:2022-05-22
下一篇:
Java Input类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap