Search in sources :

Example 51 with IgniteCompute

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

the class GridMarshallerAbstractTest method testCompute.

/**
 * @throws Exception If failed.
 */
@Test
public void testCompute() throws Exception {
    IgniteConfiguration cfg = optimize(getConfiguration("g1"));
    try (Ignite g1 = G.start(cfg)) {
        IgniteCompute compute = compute(grid().cluster().forNode(g1.cluster().localNode()));
        compute.run(new IgniteRunnable() {

            @Override
            public void run() {
            // No-op.
            }
        });
        GridMarshallerTestBean inBean = newTestBean(compute);
        byte[] buf = marshal(inBean);
        GridMarshallerTestBean outBean = unmarshal(buf);
        assert inBean.getObjectField() != null;
        assert outBean.getObjectField() != null;
        assert inBean.getObjectField().getClass().equals(IgniteComputeImpl.class);
        assert outBean.getObjectField().getClass().equals(IgniteComputeImpl.class);
        assert inBean != outBean;
        assert inBean.equals(outBean);
        ClusterGroup inPrj = compute.clusterGroup();
        ClusterGroup outPrj = ((IgniteCompute) outBean.getObjectField()).clusterGroup();
        assert inPrj.getClass().equals(outPrj.getClass());
        assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes());
        outBean.checkNullResources();
    }
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) Ignite(org.apache.ignite.Ignite) IgniteCompute(org.apache.ignite.IgniteCompute) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 52 with IgniteCompute

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

the class GridClosureProcessorSelfTest method runAsync.

/**
 * @param idx Node index.
 * @param jobs Runnable jobs.
 * @param p Optional node predicate.
 * @return Future object.
 */
private IgniteFuture<?> runAsync(int idx, Collection<ClosureTestRunnable> jobs, @Nullable IgnitePredicate<ClusterNode> p) {
    assert idx >= 0 && idx < NODES_CNT;
    assert !F.isEmpty(jobs);
    execCntr.set(0);
    IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
    return comp.runAsync(jobs);
}
Also used : IgniteCompute(org.apache.ignite.IgniteCompute)

Example 53 with IgniteCompute

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

the class GridClosureProcessorSelfTest method callAsync.

/**
 * @param idx Node index.
 * @param jobs Callable job.
 * @param p Optional node predicate.
 * @return Future object.
 */
private IgniteFuture<Collection<Integer>> callAsync(int idx, Collection<ClosureTestCallable> jobs, @Nullable IgnitePredicate<ClusterNode> p) {
    assert idx >= 0 && idx < NODES_CNT;
    assert !F.isEmpty(jobs);
    execCntr.set(0);
    IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
    return comp.callAsync(jobs);
}
Also used : IgniteCompute(org.apache.ignite.IgniteCompute)

Example 54 with IgniteCompute

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

the class GridClosureProcessorSelfTest method runAsync.

/**
 * @param idx Node index.
 * @param job Runnable job.
 * @param p Optional node predicate.
 * @return Future object.
 */
private IgniteFuture<?> runAsync(int idx, IgniteRunnable job, @Nullable IgnitePredicate<ClusterNode> p) {
    assert idx >= 0 && idx < NODES_CNT;
    assert job != null;
    execCntr.set(0);
    IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
    return comp.runAsync(job);
}
Also used : IgniteCompute(org.apache.ignite.IgniteCompute)

Example 55 with IgniteCompute

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

the class GridClosureProcessorSelfTest method broadcast.

/**
 * @param idx Node index.
 * @param job Callable job.
 * @param p Optional node predicate.
 * @return Future object.
 */
private IgniteFuture<Collection<Integer>> broadcast(int idx, IgniteCallable<Integer> job, @Nullable IgnitePredicate<ClusterNode> p) {
    assert idx >= 0 && idx < NODES_CNT;
    assert job != null;
    execCntr.set(0);
    IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
    return comp.broadcastAsync(job);
}
Also used : 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