use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteRejectConnectOnNodeStopTest method testNodeStop.
/**
* @throws Exception If failed.
*/
@Test
public void testNodeStop() throws Exception {
Ignite srv = startGrid(0);
final Ignite c = startClientGrid(1);
ClusterGroup grp = srv.cluster().forClients();
IgniteCompute srvCompute = srv.compute(grp);
srvCompute.call(new DummyClosure());
IgniteInternalFuture fut = GridTestUtils.runAsync(new Runnable() {
@Override
public void run() {
IgniteCache cache = c.cache(DEFAULT_CACHE_NAME);
for (int i = 0; i < 100_000; i++) {
try {
cache.put(1, 1);
} catch (Exception ignore) {
break;
}
}
}
}, "cache-put");
U.sleep(100);
final CountDownLatch stopStartLatch = new CountDownLatch(1);
IgniteInternalFuture<?> fut2 = GridTestUtils.runAsync(new Runnable() {
@Override
public void run() {
stopStartLatch.countDown();
c.close();
}
});
boolean err = false;
try {
stopStartLatch.await();
IgniteCacheMessageRecoveryAbstractTest.closeSessions(srv);
long stopTime = U.currentTimeMillis() + 10_000;
while (U.currentTimeMillis() < stopTime) {
try {
srvCompute.call(new DummyClosure());
} catch (ClusterTopologyException e) {
err = true;
assertFalse(fut2.isDone());
break;
}
}
} finally {
stopLatch.countDown();
}
fut.get();
fut2.get();
assertTrue("Failed to get excpected error", err);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method orderedMessage.
/**
* @throws Exception If fail.
*/
private void orderedMessage() throws Exception {
Ignite ignite = grid(SERVER_NODE_IDX);
ClusterGroup grp = gridCount() > 1 ? ignite.cluster().forRemotes() : ignite.cluster().forLocal();
assert !grp.nodes().isEmpty();
registerListenerAndSendOrderedMessages(ignite, grp);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method localServerInternal.
/**
* Single server test.
*
* @param async Async message send flag.
* @throws Exception If failed.
*/
private void localServerInternal(boolean async) throws Exception {
int messages = MSGS;
Ignite ignite = grid(SERVER_NODE_IDX);
LATCH = new CountDownLatch(messages);
ClusterGroup grp = grid(SERVER_NODE_IDX).cluster().forLocal();
UUID opId = registerListener(grp);
try {
for (int i = 0; i < messages; i++) sendMessage(ignite, grp, value(i), async);
assertTrue(LATCH.await(10, TimeUnit.SECONDS));
} finally {
ignite.message().stopRemoteListen(opId);
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method clientServerMessage.
/**
* Client sends a message and client receives it.
*
* @param async Async message send flag.
* @throws Exception If failed.
*/
private void clientServerMessage(boolean async) throws Exception {
Ignite ignite = grid(CLIENT_NODE_IDX);
ClusterGroup grp = ignite.cluster().forServers();
assert !grp.nodes().isEmpty();
registerListenerAndSendMessages(ignite, grp, async);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteMessagingConfigVariationFullApiTest method clientClientMessage.
/**
* Client sends a message and client receives it.
*
* @param async Async message send flag.
* @throws Exception If failed.
*/
private void clientClientMessage(boolean async) throws Exception {
Ignite ignite = grid(CLIENT_NODE_IDX);
ClusterGroup grp = ignite.cluster().forClients();
assert !grp.nodes().isEmpty();
registerListenerAndSendMessages(ignite, grp, async);
}
Aggregations