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();
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations