本文整理了Java中org.apache.ignite.Ignition.allGrids()
方法的一些代码示例,展示了Ignition.allGrids()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignition.allGrids()
方法的具体详情如下:
包路径:org.apache.ignite.Ignition
类名称:Ignition
方法名:allGrids
[英]Gets a list of all grids started so far.
[中]获取到目前为止已启动的所有网格的列表。
代码示例来源:origin: apache/ignite
/**
* Creates instance of the HadoopIgfsInProcWithIgniteRefsCount by IGFS name.
*
* @param igfsName Target IGFS name.
* @param log Log.
* @param userName User name.
* @return HadoopIgfsInProcWithIgniteRefsCount instance. {@code null} if the IGFS not fount in the current VM.
*/
public static HadoopIgfsInProc create(String igfsName, Log log, String userName) {
synchronized (REF_CTR_MUX) {
for (Ignite ignite : Ignition.allGrids()) {
HadoopIgfsInProc delegate = create0(ignite, igfsName, log, userName);
if (delegate != null)
return delegate;
}
}
return null;
}
代码示例来源:origin: apache/ignite
/**
* Ensure index is used in plan.
*
* @param idxName Index name.
* @param sql SQL.
* @param args Arguments.
*/
protected static void assertIndexUsed(String idxName, String sql, Object... args) {
for (Ignite node : Ignition.allGrids())
assertIndexUsed((IgniteEx)node, idxName, sql, args);
}
代码示例来源:origin: apache/ignite
/**
* Ensure index is not used in plan.
*
* @param idxName Index name.
* @param sql SQL.
* @param args Arguments.
*/
protected static void assertIndexNotUsed(String idxName, String sql, Object... args) {
for (Ignite node : Ignition.allGrids())
assertIndexNotUsed((IgniteEx)node, idxName, sql, args);
}
代码示例来源:origin: apache/ignite
@Override public boolean apply() {
for (Ignite node0 : Ignition.allGrids()) {
if (!node0.cacheNames().isEmpty())
return false;
}
return true;
}
}, 2000));
代码示例来源:origin: apache/ignite
/**
* Assert SQL simple data state.
*
* @param sql SQL query.
* @param expSize Expected size.
*/
protected static void assertSqlSimpleData(String sql, int expSize) {
for (Ignite node : Ignition.allGrids())
assertSqlSimpleData(node, sql, expSize);
}
代码示例来源:origin: apache/ignite
/**
* Assert index doesn't exist on all nodes.
*
* @param cacheName Cache name.
* @param tblName Table name.
* @param idxName Index name.
*/
static void assertNoIndex(String cacheName, String tblName, String idxName) {
for (Ignite node : Ignition.allGrids())
assertNoIndex(node, cacheName, tblName, idxName);
}
代码示例来源:origin: apache/ignite
/**
* Assert index state on all <b>affinity</b> nodes.
*
* @param cacheName Cache name.
* @param tblName Table name.
* @param idxName Index name.
* @param inlineSize Inline size.
* @param fields Fields.
*/
static void assertIndex(String cacheName, String tblName, String idxName,
int inlineSize, IgniteBiTuple<String, Boolean>... fields) {
for (Ignite node : Ignition.allGrids())
assertIndex(node, cacheName, tblName, idxName, inlineSize, fields);
}
代码示例来源:origin: apache/ignite
/**
* Applies specified closure to each cluster node.
*/
protected void testAllNodes(Consumer<Ignite> consumer) {
for (Ignite node : Ignition.allGrids()) {
log.info("Testing on node " + node.name() + '.');
consumer.accept(node);
log.info("Testing on node " + node.name() + " is done.");
}
}
代码示例来源:origin: apache/ignite
/**
* @param ignite Ignite.
*/
private void checkBaselineInFromMBean(IgniteEx ignite) {
Set<Object> cIds = ignite.cluster().currentBaselineTopology().stream()
.map(BaselineNode::consistentId)
.collect(Collectors.toSet());
for (Ignite ign : Ignition.allGrids()) {
IgniteMXBean igniteMXBean = (IgniteMXBean)ign;
assertEquals(cIds.contains(ign.cluster().localNode().consistentId()),
igniteMXBean.isNodeInBaseline());
}
}
代码示例来源:origin: apache/ignite
/**
* @param key Key.
* @param cacheName Cache name.
* @return Ignite instance which has backup cache for given key.
*/
protected Ignite backupNode(Object key, String cacheName) {
List<Ignite> allGrids = Ignition.allGrids();
assertFalse("There are no alive nodes.", F.isEmpty(allGrids));
Ignite ignite = allGrids.get(0);
Affinity<Object> aff = ignite.affinity(cacheName);
Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(key);
assertTrue("Expected more than one node for key [key=" + key + ", nodes=" + nodes + ']', nodes.size() > 1);
Iterator<ClusterNode> it = nodes.iterator();
it.next(); // Skip primary.
return grid(it.next());
}
代码示例来源:origin: apache/ignite
/**
* Assert FIELD_1 index usage.
*
* @param sql Simple SQL.
*/
private void assertSimpleIndexOperations(String sql) {
for (Ignite node : Ignition.allGrids())
assertSqlSimpleData(node, sql, KEY_BEFORE - SQL_ARG_1);
put(node(), KEY_BEFORE, KEY_AFTER);
for (Ignite node : Ignition.allGrids())
assertSqlSimpleData(node, sql, KEY_AFTER - SQL_ARG_1);
remove(node(), 0, KEY_BEFORE);
for (Ignite node : Ignition.allGrids())
assertSqlSimpleData(node, sql, KEY_AFTER - KEY_BEFORE);
remove(node(), KEY_BEFORE, KEY_AFTER);
for (Ignite node : Ignition.allGrids())
assertSqlSimpleData(node, sql, 0);
}
代码示例来源:origin: apache/ignite
/**
* Assert WAL state on all nodes.
*
* @param cacheName Cache name.
* @param expState Expected state.
* @throws IgniteCheckedException If failed.
*/
protected void assertForAllNodes(String cacheName, boolean expState) throws IgniteCheckedException {
for (final Ignite node : Ignition.allGrids()) {
info(">>> Checking WAL state on node: " + node.name());
assert GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
return node.cluster().isWalEnabled(cacheName) == expState;
}
}, 1000L);
}
}
代码示例来源:origin: apache/ignite
/**
* @param key Key.
* @param cacheName Cache name.
* @return Ignite instance which has primary cache for given key.
*/
protected Ignite primaryNode(Object key, String cacheName) {
List<Ignite> allGrids = Ignition.allGrids();
assertFalse("There are no alive nodes.", F.isEmpty(allGrids));
Ignite ignite = allGrids.get(0);
Affinity<Object> aff = ignite.affinity(cacheName);
ClusterNode node = aff.mapKeyToNode(key);
assertNotNull("There are no cache affinity nodes", node);
return grid(node);
}
代码示例来源:origin: apache/ignite
/**
*
*/
private void checkOpenedClosedCount() {
assertEquals(GRID_CNT, Ignition.allGrids().size());
for (Ignite ignite : Ignition.allGrids()) {
GridCacheContext cctx = ((IgniteKernal)ignite).internalCache(DEFAULT_CACHE_NAME).context();
CacheStore store = cctx.store().configuredStore();
long opened = ((LongAdder)U.field(store, "opened")).sum();
long closed = ((LongAdder)U.field(store, "closed")).sum();
assert opened > 0;
assert closed > 0;
assertEquals(opened, closed);
}
}
}
代码示例来源:origin: apache/ignite
/**
* @param key Key.
* @return Near cache for key.
*/
protected IgniteCache<Integer, Integer> nearCache(Integer key) {
List<Ignite> allGrids = Ignition.allGrids();
assertFalse("There are no alive nodes.", F.isEmpty(allGrids));
Affinity<Integer> aff = allGrids.get(0).affinity(DEFAULT_CACHE_NAME);
Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(key);
for (Ignite ignite : allGrids) {
if (!nodes.contains(ignite.cluster().localNode()))
return ignite.cache(DEFAULT_CACHE_NAME);
}
fail();
return null;
}
代码示例来源:origin: apache/ignite
@Override public boolean apply() {
for (Ignite node : Ignition.allGrids()) {
IgniteH2Indexing idx = (IgniteH2Indexing) ((IgniteKernal)node).context().query().getIndexing();
if (idx.mapQueryExecutor().registeredLazyWorkers() != 0)
return false;
}
return MapQueryLazyWorker.activeCount() == 0;
}
}, 1000L);
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
for (Ignite node0 : Ignition.allGrids()) {
Collection<String> cacheNames = node0.cacheNames();
for (String cacheName : cacheNames)
destroyCache(node0, cacheName);
}
awaitPartitionMapExchange();
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
for (Ignite node0 : Ignition.allGrids()) {
if (!node0.cacheNames().isEmpty())
return false;
}
return true;
}
}, 2000));
}
代码示例来源:origin: apache/ignite
/**
* @param topVer Topology version.
* @throws Exception If failed.
*/
private void awaitTopology(final long topVer) throws Exception {
for (Ignite grid : Ignition.allGrids()) {
final GridCacheAdapter cache = ((IgniteKernal)grid).internalCache(DEFAULT_CACHE_NAME);
if (cache == null)
continue;
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
return cache.context().affinity().affinityTopologyVersion().topologyVersion() == topVer;
}
}, 5000);
assertEquals(topVer, cache.context().affinity().affinityTopologyVersion().topologyVersion());
}
}
}
代码示例来源:origin: apache/ignite
/**
* Waits for the topology version to be not less than one registered on source node.
*
* @param src Source node.
* @throws IgniteCheckedException If failed to wait on affinity ready future.
*/
protected void alignCacheTopologyVersion(Ignite src) throws IgniteCheckedException {
AffinityTopologyVersion topVer = ((IgniteEx)src).context().cache().context().exchange().readyAffinityVersion();
info("Will wait for topology version on all nodes: " + topVer);
for (Ignite ignite : Ignition.allGrids()) {
IgniteInternalFuture<?> ready = ((IgniteEx)ignite).context().cache().context().exchange()
.affinityReadyFuture(topVer);
if (ready != null)
ready.get();
}
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
assert testsCfg != null;
if (Ignition.allGrids().size() != testsCfg.gridCount()) {
info("All nodes will be stopped, new " + testsCfg.gridCount() + " nodes will be started.");
Ignition.stopAll(true);
FileUtils.deleteDirectory(workDir);
info("Ignite's 'work' directory has been cleaned.");
startGrids(testsCfg.gridCount());
for (int i = 0; i < testsCfg.gridCount(); i++)
info("Grid " + i + ": " + grid(i).localNode().id());
}
assert testsCfg.testedNodeIndex() >= 0 : "testedNodeIdx: " + testedNodeIdx;
testedNodeIdx = testsCfg.testedNodeIndex();
if (testsCfg.withClients()) {
for (int i = 0; i < gridCount(); i++)
assertEquals("i: " + i, expectedClient(getTestIgniteInstanceName(i)),
(boolean)grid(i).configuration().isClientMode());
}
}
内容来源于网络,如有侵权,请联系作者删除!