use of org.apache.ignite.IgniteServices in project ignite by apache.
the class IgniteClientReconnectServicesTest method testReconnectInDeploying.
/**
* @throws Exception If failed.
*/
public void testReconnectInDeploying() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
final IgniteServices services = client.services();
Ignite srv = clientRouter(client);
BlockTcpCommunicationSpi commSpi = commSpi(srv);
commSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
services.deployClusterSingleton("testReconnectInDeploying", new TestServiceImpl());
} 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.IgniteServices in project ignite by apache.
the class IgniteClientReconnectServicesTest method testReconnect.
/**
* @throws Exception If failed.
*/
@Test
public void testReconnect() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
IgniteServices services = client.services();
services.deployClusterSingleton("testReconnect", new TestServiceImpl());
TestService srvc = services.serviceProxy("testReconnect", TestService.class, false);
assertNotNull(srvc);
long topVer = grid(0).cluster().topologyVersion();
assertEquals((Object) topVer, srvc.test());
Ignite srv = ignite(0);
reconnectClientNode(client, srv, null);
CountDownLatch latch = new CountDownLatch(1);
DummyService.exeLatch("testReconnect2", latch);
services.deployClusterSingleton("testReconnect2", new DummyService());
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
assertEquals((Object) (topVer + 2), srvc.test());
}
use of org.apache.ignite.IgniteServices 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.IgniteServices in project ignite by apache.
the class IgniteClientReconnectServicesTest method testServiceRemove.
/**
* @throws Exception If failed.
*/
@Test
public void testServiceRemove() throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = ignite(0);
IgniteServices clnServices = client.services();
final IgniteServices srvServices = srv.services();
srvServices.deployClusterSingleton("testServiceRemove", new TestServiceImpl());
final TestService srvc = clnServices.serviceProxy("testServiceRemove", TestService.class, false);
assertNotNull(srvc);
assertNotNull(srvc.test());
reconnectClientNode(client, srv, new Runnable() {
@Override
public void run() {
srvServices.cancel("testServiceRemove");
}
});
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
return srvc.test();
}
}, IgniteException.class, null);
clnServices.deployClusterSingleton("testServiceRemove", new TestServiceImpl());
TestService newSrvc = clnServices.serviceProxy("testServiceRemove", TestService.class, false);
assertNotNull(newSrvc);
assertNotNull(newSrvc.test());
}
use of org.apache.ignite.IgniteServices in project ignite by apache.
the class SystemCacheNotConfiguredTest method test.
/**
* @throws Exception If failed.
*/
@Test
public void test() throws Exception {
captureErr();
new Thread(this::startServer).start();
Ignite client = startClientGrid(getConfiguration("client"));
IgniteServices services = client.services();
SimpleService srvc = services.serviceProxy("service", SimpleService.class, false);
Thread.sleep(1000);
srvc.isWorking();
assertFalse(getErr().contains("Cache is not configured:"));
}
Aggregations