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

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

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

Ignite.createCache介绍

[英]Dynamically starts new cache using template configuration.

If local node is an affinity node, this method will return the instance of started cache. Otherwise, it will create a client cache on local node.

If a cache with the same name already exists in the grid, an exception will be thrown.
[中]使用模板配置动态启动新缓存。
如果本地节点是关联节点,则此方法将返回已启动缓存的实例。否则,它将在本地节点上创建客户端缓存。
如果网格中已存在同名缓存,则会引发异常。

代码示例

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

@Override public Void call() throws Exception {
    ignite.createCache(cacheName);
    return null;
  }
}, CacheExistsException.class, null);

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

/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) {
  checkIgnite();
  return g.createCache(cacheCfg);
}

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

/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(String cacheName) {
  checkIgnite();
  return g.createCache(cacheName);
}

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

@Override public Object call() throws Exception {
    ignite.createCache("NEW_CACHE");
    return null;
  }
}, IgniteException.class, EXPECTED_MSG);

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

@Override public Object call() throws Exception {
    ignite.createCache("NEW_CACHE");
    return null;
  }
}, IgniteException.class, EXPECTED_MSG);

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

@Override public Object call() throws Exception {
    ignite.createCache(cacheConfiguration("NEW_CACHE"));
    return null;
  }
}, IgniteException.class, EXPECTED_MSG);

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

@Override public Object call() throws Exception {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setName(CACHE_NAMES[idx.getAndIncrement()]);
    ignite.createCache(ccfg);
    return null;
  }
}, CACHE_COUNT, "cache-starter");

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

@Override public Void call() throws Exception {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setName(CACHE_NAME);
    Ignite ignite = cacheStartFrom1 ? ignite1 : ignite0;
    ignite.createCache(ccfg);
    return null;
  }
});

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

@Override public Object call() throws Exception {
    ignite.createCache(cacheConfiguration("NEW_CACHE"), new NearCacheConfiguration());
    return null;
  }
}, IgniteException.class, EXPECTED_MSG);

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

@Override public Void call() {
    node.createCache(
      new CacheConfiguration("cache2").setGroupName("grp1").setAtomicityMode(TRANSACTIONAL_SNAPSHOT));
    return null;
  }
}, CacheException.class, null);

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

/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
  super.beforeTestsStarted();
  ignite(0).createCache(createAllTypesCacheConfig());
}

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

/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
  startGridsMultiThreaded(3, true);
  ignite(0).createCache(cacheConfig("S2P", true, false).setIndexedTypes(String.class, Person.class));
  if (isBinaryMarshaller())
    ignite(0).createCache(createBinCacheConfig());
}

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

/**
 * @throws Exception If fail.
 */
@Test
public void testAtomicUpdateNear() throws Exception {
  cache = client.createCache(cacheConfiguration(), new NearCacheConfiguration<String, String>());
  checkNear(null, null);
}

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

/**
 * @throws Exception If failed.
 */
@Test
public void testSegmentedIndex() throws Exception {
  ignite(0).createCache(cacheConfig(PERSON_CAHE_NAME, true, Integer.class, Person.class));
  ignite(0).createCache(cacheConfig(ORG_CACHE_NAME, true, Integer.class, Organization.class));
  fillCache();
  checkDistributedQueryWithSegmentedIndex();
  checkLocalQueryWithSegmentedIndex();
  checkLocalSizeQueryWithSegmentedIndex();
}

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

/**
 * @throws Exception If fail.
 */
@Test
public void testPessimisticRepeatableReadUpdateNear() throws Exception {
  cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL),
    new NearCacheConfiguration<String, String>());
  checkNear(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}

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

/**
 * @throws Exception If fail.
 */
@Test
public void testPessimisticReadCommittedUpdateNear() throws Exception {
  cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL),
    new NearCacheConfiguration<String, String>());
  checkNear(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
}

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

/**
 * @throws Exception If fail.
 */
@Test
public void testOptimisticSerializableUpdateNear() throws Exception {
  cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL),
    new NearCacheConfiguration<String, String>());
  checkNear(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}

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

/**
 * @param ignite Node.
 * @param ccfg Cache configuration.
 * @return Created cache.
 */
private <K, V> IgniteCache<K, V> createCache(Ignite ignite, CacheConfiguration<K, V> ccfg) {
  IgniteCache<K, V> cache = ignite.createCache(ccfg);
  if (!MvccFeatureChecker.forcedMvcc() || MvccFeatureChecker.isSupported(Feature.NEAR_CACHE))
    ignite(NODES - 1).createNearCache(ccfg.getName(), new NearCacheConfiguration<>());
  return cache;
}

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

/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
  CacheConfiguration<Integer, Person> ccfg = new CacheConfiguration<>(CACHE_NAME);
  ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT);
  ccfg.setIndexedTypes(Integer.class, Person.class);
  node.createCache(ccfg);
  for (int i = 0; i < 100; i++)
    cache().put(i, new Person("Name" + i, "LastName" + i));
}

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

/**
 * @throws Exception If failed.
 */
@Test
public void testJoin() throws Exception {
  Ignite client = grid(SRVS);
  client.createCache(personCache());
  checkJoin(0);
  h2DataInserted = true;
  checkJoin(1);
  checkJoin(2);
}

相关文章