org.apache.ignite.Ignite.getOrCreateCaches()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.apache.ignite.Ignite.getOrCreateCaches()方法的一些代码示例,展示了Ignite.getOrCreateCaches()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.getOrCreateCaches()方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:getOrCreateCaches

Ignite.getOrCreateCaches介绍

[英]Gets existing caches with the given name or created one with the given configuration.

If a cache with the same name already exist, this method will not check that the given configuration matches the configuration of existing cache and will return an instance of the existing cache.
[中]获取具有给定名称的现有缓存或使用给定配置创建的缓存。
如果已经存在同名缓存,此方法将不会检查给定配置是否与现有缓存的配置匹配,并将返回现有缓存的实例。

代码示例

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs) {
  checkIgnite();
  return g.getOrCreateCaches(cacheCfgs);
}

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    Ignite node = ignite(idx.incrementAndGet() % NODES);
    b.await();
    boolean sleep = iter % 2 == 0;
    if (sleep)
      Thread.sleep(ThreadLocalRandom.current().nextLong(100) + 1);
    switch (op) {
      case GET_OR_CREATE_CACHE:
        node.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
        break;
      case GET_OR_CREATE_CACHES:
        node.getOrCreateCaches(cacheConfigurations());
        break;
    }
    return null;
  }
}, THREADS, "start-cache");

代码示例来源:origin: apache/ignite

@Override public void apply(Integer idx) {
    try {
      b.await();
      Ignite node = startGrid(idx + SRVS);
      if (createCache) {
        for (int c = 0; c < 5; c++) {
          for (IgniteCache cache : node.getOrCreateCaches(cacheConfigurations())) {
            boolean updated = false;
            while (!updated) {
              try {
                cache.put(c, c);
                updated = true;
              }
              catch (Exception e) {
                assertMvccWriteConflict(e);
              }
            }
            assertEquals(c, cache.get(c));
          }
        }
      }
    }
    catch (Exception e) {
      throw new IgniteException(e);
    }
  }
}, CLIENTS, "start-client");

代码示例来源:origin: apache/ignite

Collection<IgniteCache> caches = client.getOrCreateCaches(cfgs);

代码示例来源:origin: apache/ignite

/**
 * @param ig Ig.
 */
private void loadData(Ignite ig) {
  List<CacheConfiguration> configs = Stream.of(
    F.t(CACHE_1, GROUP_1),
    F.t(CACHE_2, GROUP_1),
    F.t(CACHE_3, GROUP_2),
    F.t(CACHE_4, GROUP_2)
  ).map(names -> new CacheConfiguration<>(names.get1())
    .setGroupName(names.get2())
    .setRebalanceBatchSize(REBALANCE_BATCH_SIZE)
    .setCacheMode(CacheMode.REPLICATED)
    .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
  ).collect(Collectors.toList());
  ig.getOrCreateCaches(configs);
  configs.forEach(cfg -> {
    try (IgniteDataStreamer<Object, Object> streamer = ig.dataStreamer(cfg.getName())) {
      for (int i = 0; i < KEYS_SIZE; i++)
        streamer.addData(i, new byte[1024]);
      streamer.flush();
    }
  });
}

代码示例来源:origin: apache/ignite

caches = client.getOrCreateCaches(cacheConfigurations(grp, atomicityMode));
else {
  caches = new ArrayList<>();

代码示例来源:origin: apache/ignite

srv.getOrCreateCaches(cacheConfigurations());
    for (IgniteCache cache : node.getOrCreateCaches(cacheConfigurations())) {
      cache.put(c, c);

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testStartClientCachesOnCoordinatorWithGroup() throws Exception {
  startGrids(3);
  List<CacheConfiguration> ccfgs = cacheConfigurations("testGrp", ATOMIC);
  for (CacheConfiguration ccfg : ccfgs)
    ccfg.setNodeFilter(new CachePredicate(F.asList(getTestIgniteInstanceName(0))));
  ignite(1).createCaches(ccfgs);
  ccfgs = cacheConfigurations("testGrp", ATOMIC);
  for (CacheConfiguration ccfg : ccfgs)
    ccfg.setNodeFilter(new CachePredicate(F.asList(getTestIgniteInstanceName(0))));
  for (IgniteCache<Object, Object> cache : ignite(0).getOrCreateCaches(ccfgs)) {
    cache.put(1, 1);
    assertEquals(1, cache.get(1));
    cache.close();
  }
  startGrid(4);
}

代码示例来源:origin: apache/ignite

ignite(0).getOrCreateCaches(Arrays.asList(configurations2()));

代码示例来源:origin: org.apache.ignite/ignite-spring

/** {@inheritDoc} */
@Override public Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs) {
  checkIgnite();
  return g.getOrCreateCaches(cacheCfgs);
}

相关文章