use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class IgniteClientReconnectServicesTest method testReconnectInProgress.
/**
* @throws Exception If failed.
*/
@Test
public void testReconnectInProgress() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
final IgniteServices services = client.services();
final Ignite srv = ignite(0);
services.deployClusterSingleton("testReconnectInProgress", new TestServiceImpl());
final TestService srvc = services.serviceProxy("testReconnectInProgress", TestService.class, false);
assertNotNull(srvc);
BlockTcpCommunicationSpi commSpi = commSpi(srv);
commSpi.blockMessage(GridJobExecuteResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
srvc.test();
} 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));
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class IgniteClientReconnectAbstractTest method check.
/**
* @param e Client disconnected exception.
* @return Reconnect future.
*/
protected IgniteFuture<?> check(CacheException e) {
log.info("Expected exception: " + e);
if (!(e.getCause() instanceof IgniteClientDisconnectedException))
log.error("Unexpected cause: " + e.getCause(), e);
assertTrue("Unexpected cause: " + e.getCause(), e.getCause() instanceof IgniteClientDisconnectedException);
IgniteClientDisconnectedException e0 = (IgniteClientDisconnectedException) e.getCause();
assertNotNull(e0.reconnectFuture());
return e0.reconnectFuture();
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class IgniteClientReconnectAtomicsTest method testAtomicStampedReconnectInProgress.
/**
* @throws Exception If failed.
*/
@Test
public void testAtomicStampedReconnectInProgress() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = ignite(0);
final IgniteAtomicStamped clientAtomicStamped = client.atomicStamped("atomicStampedInProgress", 0, 0, true);
assertEquals(true, clientAtomicStamped.compareAndSet(0, 1, 0, 1));
assertEquals(1, clientAtomicStamped.value());
assertEquals(1, clientAtomicStamped.stamp());
IgniteAtomicStamped srvAtomicStamped = srv.atomicStamped("atomicStampedInProgress", 0, 0, false);
assertEquals(true, srvAtomicStamped.compareAndSet(1, 2, 1, 2));
assertEquals(2, srvAtomicStamped.value());
assertEquals(2, srvAtomicStamped.stamp());
BlockTcpCommunicationSpi servCommSpi = commSpi(srv);
servCommSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
clientAtomicStamped.compareAndSet(2, 3, 2, 3);
} 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);
servCommSpi.unblockMessage();
reconnectClientNode(client, srv, null);
assertTrue((Boolean) fut.get(2, TimeUnit.SECONDS));
// Check that after reconnect working.
assertEquals(false, clientAtomicStamped.compareAndSet(2, 3, 2, 3));
assertEquals(3, clientAtomicStamped.value());
assertEquals(3, clientAtomicStamped.stamp());
assertEquals(true, srvAtomicStamped.compareAndSet(3, 4, 3, 4));
assertEquals(4, srvAtomicStamped.value());
assertEquals(4, srvAtomicStamped.stamp());
srvAtomicStamped.close();
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class IgniteClientReconnectAtomicsTest method testAtomicReferenceReconnectInProgress.
/**
* @throws Exception If failed.
*/
@Test
public void testAtomicReferenceReconnectInProgress() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = ignite(0);
final IgniteAtomicReference<String> clientAtomicRef = client.atomicReference("atomicRefInProg", "1st value", true);
assertEquals("1st value", clientAtomicRef.get());
assertTrue(clientAtomicRef.compareAndSet("1st value", "2st value"));
assertEquals("2st value", clientAtomicRef.get());
IgniteAtomicReference<String> srvAtomicRef = srv.atomicReference("atomicRefInProg", "1st value", false);
assertEquals("2st value", srvAtomicRef.get());
assertTrue(srvAtomicRef.compareAndSet("2st value", "3st value"));
assertEquals("3st value", srvAtomicRef.get());
BlockTcpCommunicationSpi servCommSpi = commSpi(srv);
servCommSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
clientAtomicRef.compareAndSet("3st value", "4st value");
} 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);
servCommSpi.unblockMessage();
reconnectClientNode(client, srv, null);
assertTrue((Boolean) fut.get(2, TimeUnit.SECONDS));
// Check that after reconnect working.
assertEquals("4st value", clientAtomicRef.get());
assertEquals("4st value", srvAtomicRef.get());
assertTrue(srvAtomicRef.compareAndSet("4st value", "5st value"));
assertEquals("5st value", srvAtomicRef.get());
srvAtomicRef.close();
}
use of org.apache.ignite.IgniteClientDisconnectedException in project ignite by apache.
the class IgniteClientReconnectCollectionsTest method queueReconnectInProgress.
/**
* @param colCfg Collection configuration.
* @throws Exception If failed.
*/
private void queueReconnectInProgress(final CollectionConfiguration colCfg) throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = ignite(0);
final String setName = "queue-rmv" + colCfg.getAtomicityMode();
final IgniteQueue<String> clientQueue = client.queue(setName, 10, colCfg);
final IgniteQueue<String> srvQueue = srv.queue(setName, 10, null);
assertTrue(clientQueue.offer("1"));
assertTrue(srvQueue.contains("1"));
BlockTcpCommunicationSpi commSpi = commSpi(srv);
if (colCfg.getAtomicityMode() == ATOMIC)
commSpi.blockMessage(GridNearAtomicUpdateResponse.class);
else
commSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
clientQueue.add("2");
} 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("Future was not failed. Atomic mode: " + colCfg.getAtomicityMode() + ".", (Boolean) fut.get());
assertTrue(clientQueue.add("3"));
assertEquals("1", clientQueue.poll());
}
Aggregations