Search in sources :

Example 6 with ClientCompute

use of org.apache.ignite.client.ClientCompute 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));
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) ClientCompute(org.apache.ignite.client.ClientCompute) Test(org.junit.Test)

Example 7 with ClientCompute

use of org.apache.ignite.client.ClientCompute 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);
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) ClientClusterGroup(org.apache.ignite.client.ClientClusterGroup) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) ClientCompute(org.apache.ignite.client.ClientCompute) Test(org.junit.Test)

Example 8 with ClientCompute

use of org.apache.ignite.client.ClientCompute 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());
    }
}
Also used : IgniteClient(org.apache.ignite.client.IgniteClient) CountDownLatch(java.util.concurrent.CountDownLatch) UUID(java.util.UUID) T2(org.apache.ignite.internal.util.typedef.T2) ClientCompute(org.apache.ignite.client.ClientCompute) Test(org.junit.Test)

Aggregations

ClientCompute (org.apache.ignite.client.ClientCompute)8 IgniteClient (org.apache.ignite.client.IgniteClient)8 Test (org.junit.Test)8 UUID (java.util.UUID)5 T2 (org.apache.ignite.internal.util.typedef.T2)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Random (java.util.Random)1 Set (java.util.Set)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ClientClusterGroup (org.apache.ignite.client.ClientClusterGroup)1 IgniteClientFuture (org.apache.ignite.client.IgniteClientFuture)1 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 ThinClientConfiguration (org.apache.ignite.configuration.ThinClientConfiguration)1