use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method localListenerInternal.
/**
* Single server test with local listener.
* @throws Exception If failed.
*/
private void localListenerInternal() throws Exception {
int messages = MSGS;
Ignite ignite = grid(SERVER_NODE_IDX);
LATCH = new CountDownLatch(messages);
ClusterGroup grp = grid(SERVER_NODE_IDX).cluster().forLocal();
MessageListener c = new MessageListener();
try {
ignite.message(grp).localListen("localListenerTopic", c);
for (int i = 0; i < messages; i++) ignite.message(grp).send("localListenerTopic", value(i));
assertTrue(LATCH.await(10, TimeUnit.SECONDS));
} finally {
ignite.message().stopLocalListen("localListenerTopic", c);
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method serverClientMessage.
/**
* Server sends a message and client receives it.
*
* @param async Async message send flag.
* @throws Exception If failed.
*/
private void serverClientMessage(boolean async) throws Exception {
Ignite ignite = grid(SERVER_NODE_IDX);
ClusterGroup grp = ignite.cluster().forClients();
assert grp.nodes().size() > 0;
registerListenerAndSendMessages(ignite, grp, async);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method serverClientOrderedMessage.
/**
* @throws Exception If fail.
*/
private void serverClientOrderedMessage() throws Exception {
Ignite ignite = grid(SERVER_NODE_IDX);
ClusterGroup grp = ignite.cluster().forClients();
assert grp.nodes().size() > 0;
registerListenerAndSendOrderedMessages(ignite, grp);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridProjectionForCachesOnDaemonNodeSelfTest method testForCacheNodes.
/**
* @throws Exception If failed.
*/
public void testForCacheNodes() throws Exception {
ClusterGroup grp = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME);
assertFalse(grp.nodes().isEmpty());
try {
daemon.cluster().forCacheNodes(DEFAULT_CACHE_NAME);
} catch (IllegalStateException ignored) {
return;
}
fail();
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class TcpCommunicationSpiHalfOpenedConnectionTest method checkReconnect.
/**
* @throws Exception If failed.
*/
private void checkReconnect() throws Exception {
Ignite srv = startGrid("server");
Ignite client = startGrid("client");
UUID nodeId = srv.cluster().localNode().id();
System.out.println(">> Server ID: " + nodeId);
ClusterGroup srvGrp = client.cluster().forNodeId(nodeId);
System.out.println(">> Send job");
// Establish connection
client.compute(srvGrp).run(F.noop());
ConcurrentMap<UUID, GridCommunicationClient[]> clients = U.field(clientSpi, "clients");
ConcurrentMap<?, GridNioRecoveryDescriptor> recoveryDescs = U.field(clientSpi, "recoveryDescs");
ConcurrentMap<?, GridNioRecoveryDescriptor> outRecDescs = U.field(clientSpi, "outRecDescs");
ConcurrentMap<?, GridNioRecoveryDescriptor> inRecDescs = U.field(clientSpi, "inRecDescs");
GridNioServerListener<Message> lsnr = U.field(clientSpi, "srvLsnr");
Iterator<GridNioRecoveryDescriptor> it = F.concat(recoveryDescs.values().iterator(), outRecDescs.values().iterator(), inRecDescs.values().iterator());
while (it.hasNext()) {
GridNioRecoveryDescriptor desc = it.next();
// Need to simulate connection close in GridNioServer as it
// releases descriptors on disconnect.
desc.release();
}
// Remove client to avoid calling close(), in that case server
// will close connection too, but we want to keep the server
// uninformed and force ping old connection.
GridCommunicationClient[] clients0 = clients.remove(nodeId);
for (GridCommunicationClient commClient : clients0) lsnr.onDisconnected(((GridTcpNioCommunicationClient) commClient).session(), new IOException("Test exception"));
info(">> Removed client");
// Reestablish connection
client.compute(srvGrp).run(F.noop());
info(">> Sent second job");
}
Aggregations