Search in sources :

Example 61 with IgniteCompute

use of org.apache.ignite.IgniteCompute in project ignite by apache.

the class IgniteComputeResultExceptionTest method checkExecuteAsyncException.

/**
 */
private void checkExecuteAsyncException(IgniteException resE) throws Exception {
    try (Ignite ignite = startGrid()) {
        IgniteCompute compute = ignite.compute();
        ComputeTaskFuture<Object> fut = compute.executeAsync(new ResultExceptionTask(resE), null);
        try {
            fut.get();
        } catch (IgniteException e) {
            assertSame(resE, e);
        }
    }
}
Also used : IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite) IgniteCompute(org.apache.ignite.IgniteCompute)

Example 62 with IgniteCompute

use of org.apache.ignite.IgniteCompute in project ignite by apache.

the class GridTaskExecutionSelfTest method testJobIdCollision.

/**
 * Test for https://issues.apache.org/jira/browse/IGNITE-1384
 *
 * @throws Exception If failed.
 */
@Test
public void testJobIdCollision() throws Exception {
    fail("Test refactoring is needed: https://issues.apache.org/jira/browse/IGNITE-4706");
    long locId = IgniteUuid.lastLocalId();
    ArrayList<IgniteFuture<Object>> futs = new ArrayList<>(2016);
    IgniteCompute compute = grid(1).compute(grid(1).cluster().forNodeId(grid(3).localNode().id()));
    for (int i = 0; i < 1000; i++) {
        futs.add(compute.callAsync(new IgniteCallable<Object>() {

            @JobContextResource
            ComputeJobContext ctx;

            boolean held;

            @Override
            public Object call() throws Exception {
                if (!held) {
                    ctx.holdcc(1000);
                    held = true;
                }
                return null;
            }
        }));
    }
    info("Finished first loop.");
    AtomicLong idx = U.field(IgniteUuid.class, "cntGen");
    idx.set(locId);
    IgniteCompute compute1 = grid(2).compute(grid(2).cluster().forNodeId(grid(3).localNode().id()));
    for (int i = 0; i < 100; i++) {
        futs.add(compute1.callAsync(new IgniteCallable<Object>() {

            @JobContextResource
            ComputeJobContext ctx;

            boolean held;

            @Override
            public Object call() throws Exception {
                if (!held) {
                    ctx.holdcc(1000);
                    held = true;
                }
                return null;
            }
        }));
    }
    for (IgniteFuture<Object> fut : futs) fut.get();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ComputeJobContext(org.apache.ignite.compute.ComputeJobContext) IgniteCallable(org.apache.ignite.lang.IgniteCallable) ArrayList(java.util.ArrayList) IgniteFuture(org.apache.ignite.lang.IgniteFuture) IgniteCompute(org.apache.ignite.IgniteCompute) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest)

Example 63 with IgniteCompute

use of org.apache.ignite.IgniteCompute in project ignite by apache.

the class IgniteCacheRandomOperationBenchmark method doScanQuery.

/**
 * @param cache Ignite cache.
 * @throws Exception If failed.
 */
private void doScanQuery(IgniteCache<Object, Object> cache) throws Exception {
    if (!affCaches.contains(cache))
        return;
    Map<UUID, List<Integer>> partitionsMap = personCachePartitions(cache.getName());
    ScanQueryBroadcastClosure c = new ScanQueryBroadcastClosure(cache.getName(), partitionsMap);
    ClusterGroup clusterGrp = ignite().cluster().forNodeIds(partitionsMap.keySet());
    IgniteCompute compute = ignite().compute(clusterGrp);
    compute.broadcast(c);
}
Also used : ClusterGroup(org.apache.ignite.cluster.ClusterGroup) List(java.util.List) ArrayList(java.util.ArrayList) UUID(java.util.UUID) IgniteCompute(org.apache.ignite.IgniteCompute)

Aggregations

IgniteCompute (org.apache.ignite.IgniteCompute)63 Ignite (org.apache.ignite.Ignite)30 Test (org.junit.Test)20 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)18 IgniteException (org.apache.ignite.IgniteException)15 ArrayList (java.util.ArrayList)12 IgniteFuture (org.apache.ignite.lang.IgniteFuture)10 UUID (java.util.UUID)9 ClusterGroup (org.apache.ignite.cluster.ClusterGroup)8 CountDownLatch (java.util.concurrent.CountDownLatch)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 IgniteEx (org.apache.ignite.internal.IgniteEx)5 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)4 IgniteCallable (org.apache.ignite.lang.IgniteCallable)4 Nullable (org.jetbrains.annotations.Nullable)4 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3