use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class ClusterGroupSelfTest method testEmptyGroup.
/**
* @throws Exception If failed.
*/
public void testEmptyGroup() throws Exception {
ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
assertEquals(0, emptyGrp.forOldest().nodes().size());
assertEquals(0, emptyGrp.forYoungest().nodes().size());
assertEquals(0, emptyGrp.forAttribute("nonExistent2", "val").nodes().size());
assertEquals(0, emptyGrp.forCacheNodes("cacheName").nodes().size());
assertEquals(0, emptyGrp.forClientNodes("cacheName").nodes().size());
assertEquals(0, emptyGrp.forClients().nodes().size());
assertEquals(0, emptyGrp.forDaemons().nodes().size());
assertEquals(0, emptyGrp.forDataNodes("cacheName").nodes().size());
assertEquals(0, emptyGrp.forRandom().nodes().size());
assertEquals(0, emptyGrp.forRemotes().nodes().size());
assertEquals(0, emptyGrp.forServers().nodes().size());
assertEquals(0, emptyGrp.forHost(ignite.cluster().localNode()).nodes().size());
assertEquals(0, emptyGrp.forHost("127.0.0.1").nodes().size());
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class ClusterGroupSelfTest method testOldest.
/**
* @throws Exception If failed.
*/
public void testOldest() throws Exception {
ClusterGroup oldest = ignite.cluster().forOldest();
ClusterNode node = null;
long minOrder = Long.MAX_VALUE;
for (ClusterNode n : ignite.cluster().nodes()) {
if (n.order() < minOrder) {
node = n;
minOrder = n.order();
}
}
assertEquals(oldest.node(), ignite.cluster().forNode(node).node());
ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val");
assertEquals(0, emptyGrp.forOldest().nodes().size());
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class ClusterGroupSelfTest method testClientServer.
/**
* @throws Exception If failed.
*/
public void testClientServer() throws Exception {
ClusterGroup srv = ignite.cluster().forServers();
assertEquals(2, srv.nodes().size());
assertTrue(srv.nodes().contains(ignite(0).cluster().localNode()));
assertTrue(srv.nodes().contains(ignite(1).cluster().localNode()));
ClusterGroup cli = ignite.cluster().forClients();
assertEquals(2, srv.nodes().size());
assertTrue(cli.nodes().contains(ignite(2).cluster().localNode()));
assertTrue(cli.nodes().contains(ignite(3).cluster().localNode()));
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class ClusterGroupSelfTest method testNewNodes.
/**
* @throws Exception If failed.
*/
public void testNewNodes() throws Exception {
ClusterGroup youngest = ignite.cluster().forYoungest();
ClusterGroup oldest = ignite.cluster().forOldest();
ClusterNode old = oldest.node();
ClusterNode last = youngest.node();
assertNotNull(last);
try (Ignite g = startGrid(NODES_CNT)) {
ClusterNode n = g.cluster().localNode();
ClusterNode latest = youngest.node();
assertNotNull(latest);
assertEquals(latest.id(), n.id());
assertEquals(oldest.node(), old);
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteComputeEmptyClusterGroupTest method testSync.
/**
* @throws Exception If failed.
*/
public void testSync() throws Exception {
ClusterGroup empty = ignite(0).cluster().forNodeId(UUID.randomUUID());
assertEquals(0, empty.nodes().size());
final IgniteCompute comp = ignite(0).compute(empty);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
comp.affinityRun(DEFAULT_CACHE_NAME, 1, new FailRunnable());
return null;
}
}, ClusterGroupEmptyException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
comp.apply(new FailClosure(), new Object());
return null;
}
}, ClusterGroupEmptyException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
comp.affinityCall(DEFAULT_CACHE_NAME, 1, new FailCallable());
return null;
}
}, ClusterGroupEmptyException.class, null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
comp.broadcast(new FailCallable());
return null;
}
}, ClusterGroupEmptyException.class, null);
}
Aggregations