ignite-299 review
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/fb0eb28b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/fb0eb28b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/fb0eb28b Branch: refs/heads/ignite-299 Commit: fb0eb28b6f44e75e565c78e82eeb0f74c0aef7cb Parents: 157b6ce Author: Yakov Zhdanov <yzhda...@gridgain.com> Authored: Wed Feb 25 21:02:29 2015 +0300 Committer: Yakov Zhdanov <yzhda...@gridgain.com> Committed: Wed Feb 25 21:02:29 2015 +0300 ---------------------------------------------------------------------- .../computegrid/ComputeFibonacciContinuationExample.java | 11 ++++++++--- .../scalar/examples/ScalarContinuationExample.scala | 11 +++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb0eb28b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java index ea96b43..ae36fb2 100644 --- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java @@ -21,7 +21,6 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; import org.apache.ignite.examples.*; -import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; @@ -138,14 +137,20 @@ public final class ComputeFibonacciContinuationExample { if (fut1 == null) { compute.apply(new FibonacciClosure(nodeFilter), n - 1); - fut1 = F.addIfAbsent(locMap, n - 1, compute.<BigInteger>future()); + IgniteFuture<BigInteger> old = locMap.putIfAbsent(n - 1, fut1 = compute.future()); + + if (old != null) + fut1 = old; } // If future is not cached in node-local-map, cache it. if (fut2 == null) { compute.apply(new FibonacciClosure(nodeFilter), n - 2); - fut2 = F.addIfAbsent(locMap, n - 2, compute.<BigInteger>future()); + IgniteFuture<BigInteger> old = locMap.putIfAbsent(n - 2, fut2 = compute.future()); + + if (old != null) + fut2 = old; } // If futures are not done, then wait asynchronously for the result http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fb0eb28b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala ---------------------------------------------------------------------- diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala index ae2bebc..843f394 100644 --- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala +++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala @@ -18,7 +18,6 @@ package org.apache.ignite.scalar.examples import org.apache.ignite.compute.ComputeJobContext -import org.apache.ignite.internal.util.lang.GridFunc import org.apache.ignite.lang.{IgniteClosure, IgniteFuture} import org.apache.ignite.resources.JobContextResource import org.apache.ignite.scalar.scalar @@ -122,14 +121,18 @@ class FibonacciClosure ( if (fut1 == null) { comp.apply(new FibonacciClosure(excludeNodeId), n - 1) - fut1 = GridFunc.addIfAbsent(store, n - 1, comp.future[BigInteger]()) + val old: IgniteFuture[BigInteger] = store.putIfAbsent(n - 1, fut1 = comp.future[BigInteger]()) + + if (old != null) fut1 = old } - // If future is not cached in node-local store, cache it. + // If future is not cached in node-local-map, cache it. if (fut2 == null) { comp.apply(new FibonacciClosure(excludeNodeId), n - 2) - fut2 = GridFunc.addIfAbsent(store, n - 2, comp.future[BigInteger]()) + val old: IgniteFuture[BigInteger] = store.putIfAbsent(n - 2, fut2 = comp.future[BigInteger]()) + + if (old != null) fut2 = old } // If futures are not done, then wait asynchronously for the result