use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testTaskCancellation.
/**
*/
@Test(expected = CancellationException.class)
public void testTaskCancellation() throws Exception {
try (IgniteClient client = startClient(0)) {
Future<T2<UUID, List<UUID>>> fut = client.compute().executeAsync(TestTask.class.getName(), TIMEOUT);
assertFalse(fut.isCancelled());
assertFalse(fut.isDone());
assertTrue(fut.cancel(true));
assertTrue(GridTestUtils.waitForCondition(() -> ((ClientComputeImpl) client.compute()).activeTasksCount() == 0, TIMEOUT));
assertTrue(fut.isCancelled());
assertTrue(fut.isDone());
fut.get();
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testExecuteTaskOnEmptyClusterGroup.
/**
*/
@Test(expected = ClientException.class)
public void testExecuteTaskOnEmptyClusterGroup() throws Exception {
try (IgniteClient client = startClient(0)) {
ClientClusterGroup grp = client.cluster().forNodeIds(Collections.emptyList());
client.compute(grp).execute(TestTask.class.getName(), null);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ClusterApiTest method testClusterState.
/**
* Test change cluster state operation by thin client.
*/
@Test
public void testClusterState() throws Exception {
try (IgniteClient client = startClient(0)) {
ClientCluster clientCluster = client.cluster();
IgniteCluster igniteCluster = grid(0).cluster();
changeAndCheckState(clientCluster, igniteCluster, ClusterState.INACTIVE);
changeAndCheckState(clientCluster, igniteCluster, ClusterState.ACTIVE_READ_ONLY);
changeAndCheckState(clientCluster, igniteCluster, ClusterState.ACTIVE);
changeAndCheckState(clientCluster, igniteCluster, ClusterState.INACTIVE);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ServicesTest method testOverloadedMethods.
/**
* Test that overloaded methods resolved correctly.
*/
@Test
public void testOverloadedMethods() throws Exception {
try (IgniteClient client = startClient(0)) {
// Test local service calls (service deployed to each node).
TestServiceInterface svc = client.services().serviceProxy(NODE_SINGLTON_SERVICE_NAME, TestServiceInterface.class);
checkOverloadedMethods(svc);
// Test remote service calls (client connected to grid(0) but service deployed to grid(1)).
svc = client.services().serviceProxy(CLUSTER_SINGLTON_SERVICE_NAME, TestServiceInterface.class);
checkOverloadedMethods(svc);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ServicesTest method testServiceCallContext.
/**
* Test custom caller context.
*/
@Test
public void testServiceCallContext() {
String attrName = "testAttr";
String attrVal = "test";
String binAttrName = "binTestAttr";
byte[] binAttrVal = attrVal.getBytes();
try (IgniteClient client = startClient(0)) {
// Check proxy creation with an invalid implementation.
ServiceCallContext customCls = new ServiceCallContext() {
@Override
public String attribute(String name) {
return null;
}
@Override
public byte[] binaryAttribute(String name) {
return null;
}
};
GridTestUtils.assertThrowsAnyCause(log, () -> client.services().serviceProxy(NODE_SINGLTON_SERVICE_NAME, TestServiceInterface.class, customCls), IllegalArgumentException.class, "\"callCtx\" has an invalid type.");
// Check proxy creation with a valid caller context.
ServiceCallContext callCtx = new ServiceCallContextBuilder().put(attrName, attrVal).put(binAttrName, binAttrVal).build();
TestServiceInterface svc = client.services().serviceProxy(NODE_SINGLTON_SERVICE_NAME, TestServiceInterface.class, callCtx);
assertEquals(attrVal, svc.testContextAttribute(attrName));
assertArrayEquals(binAttrVal, svc.testContextBinaryAttribute(binAttrName));
}
}
Aggregations