use of org.apache.ignite.IgniteAtomicLong in project ignite by apache.
the class IgniteClientReconnectAtomicsTest method testAtomicLongReconnectInProgress.
/**
* @throws Exception If failed.
*/
public void testAtomicLongReconnectInProgress() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = clientRouter(client);
BlockTcpCommunicationSpi commSpi = commSpi(srv);
final IgniteAtomicLong clientAtomicLong = client.atomicLong("atomicLongInProggress", 0, true);
final IgniteAtomicLong srvAtomicLong = srv.atomicLong("atomicLongInProggress", 0, false);
commSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
clientAtomicLong.getAndAdd(1);
} catch (IgniteClientDisconnectedException e) {
checkAndWait(e);
return true;
}
return false;
}
});
// Check that client waiting operation.
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
return fut.get(200);
}
}, IgniteFutureTimeoutCheckedException.class, null);
assertNotDone(fut);
commSpi.unblockMessage();
reconnectClientNode(client, srv, null);
assertTrue((Boolean) fut.get(2, TimeUnit.SECONDS));
// Check that after reconnect working.
assertEquals(2, clientAtomicLong.addAndGet(1));
assertEquals(3, srvAtomicLong.addAndGet(1));
clientAtomicLong.close();
}
Aggregations