use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testTaskWithNoResultCache.
/**
*/
@Test
public void testTaskWithNoResultCache() throws Exception {
try (IgniteClient client = startClient(0)) {
ClientCompute computeWithCache = client.compute();
ClientCompute computeWithNoCache = client.compute().withNoResultCache();
assertTrue(computeWithCache.execute(TestResultCacheTask.class.getName(), null));
assertFalse(computeWithNoCache.execute(TestResultCacheTask.class.getName(), null));
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testComputeWithMixedModificators.
/**
*/
@Test
public void testComputeWithMixedModificators() throws Exception {
try (IgniteClient client = startClient(0)) {
ClientClusterGroup grp = client.cluster().forNodeId(nodeId(1), nodeId(2));
ClientCompute compute = client.compute(grp).withNoFailover().withNoResultCache().withTimeout(TIMEOUT / 5);
T2<UUID, List<UUID>> val = client.compute(grp).execute(TestTask.class.getName(), null);
assertEquals(nodeIds(1, 2), val.get2());
assertFalse(compute.execute(TestFailoverTask.class.getName(), null));
assertFalse(compute.execute(TestResultCacheTask.class.getName(), null));
GridTestUtils.assertThrowsAnyCause(null, () -> compute.execute(TestTask.class.getName(), TIMEOUT), ClientException.class, null);
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testExecuteTwoTasksMisorderedResults.
/**
*/
@Test
public void testExecuteTwoTasksMisorderedResults() throws Exception {
try (IgniteClient client = startClient(0)) {
ClientCompute compute1 = client.compute(client.cluster().forNodeId(nodeId(1)));
ClientCompute compute2 = client.compute(client.cluster().forNodeId(nodeId(2)));
CountDownLatch latch1 = TestLatchTask.latch = new CountDownLatch(2);
TestLatchTask.startLatch = new CountDownLatch(1);
Future<T2<UUID, Set<UUID>>> fut1 = compute1.executeAsync(TestLatchTask.class.getName(), null);
TestLatchTask.startLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
CountDownLatch latch2 = TestLatchTask.latch = new CountDownLatch(1);
TestLatchTask.startLatch = new CountDownLatch(1);
Future<T2<UUID, Set<UUID>>> fut2 = compute2.executeAsync(TestLatchTask.class.getName(), null);
TestLatchTask.startLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
latch2.countDown();
assertEquals(nodeIds(2), fut2.get().get2());
assertFalse(fut1.isDone());
latch1.countDown();
assertEquals(nodeIds(1), fut1.get().get2());
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testExecuteTaskOnClusterGroup.
/**
*/
@Test
public void testExecuteTaskOnClusterGroup() throws Exception {
try (IgniteClient client = startClient(0)) {
ClientClusterGroup grp = client.cluster().forNodeIds(nodeIds(1, 2));
T2<UUID, List<UUID>> val = client.compute(grp).execute(TestTask.class.getName(), null);
assertEquals(nodeId(0), val.get1());
assertEquals(nodeIds(1, 2), val.get2());
// Compute on client node defined explicitly.
grp = client.cluster().forNodeIds(nodeIds(3));
val = client.compute(grp).execute(TestTask.class.getName(), null);
assertEquals(nodeId(0), val.get1());
assertEquals(nodeIds(3), val.get2());
// Compute on all nodes (clients + servers).
grp = client.cluster();
val = client.compute(grp).execute(TestTask.class.getName(), null);
assertEquals(nodeId(0), val.get1());
assertEquals(new HashSet<>(F.nodeIds(grid(0).cluster().nodes())), val.get2());
}
}
use of org.apache.ignite.client.IgniteClient in project ignite by apache.
the class ComputeTaskTest method testExecuteTaskByName.
/**
*/
@Test
public void testExecuteTaskByName() throws Exception {
try (IgniteClient client = startClient(0)) {
// We should deploy class manually to make it visible to server node by task name.
grid(0).compute().localDeployTask(TestTask.class, TestTask.class.getClassLoader());
T2<UUID, Set<UUID>> val = client.compute().execute(TEST_TASK_NAME, null);
assertEquals(nodeId(0), val.get1());
assertEquals(new HashSet<>(F.nodeIds(grid(0).cluster().forServers().nodes())), val.get2());
}
}
Aggregations