# ignite-299: fix review comments (remove internal utils from examples)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7b79009e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7b79009e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7b79009e Branch: refs/heads/ignite-264 Commit: 7b79009e2d01f937038e28d233ca38d0e9fdae71 Parents: e09b037 Author: Artem Shutak <ashu...@gridgain.com> Authored: Thu Feb 26 11:35:19 2015 +0300 Committer: Artem Shutak <ashu...@gridgain.com> Committed: Thu Feb 26 11:35:19 2015 +0300 ---------------------------------------------------------------------- .../ComputeFibonacciContinuationExample.java | 15 ++++++++++++--- .../scalar/examples/ScalarContinuationExample.scala | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b79009e/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..5665b9e 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,24 @@ public final class ComputeFibonacciContinuationExample { if (fut1 == null) { compute.apply(new FibonacciClosure(nodeFilter), n - 1); - fut1 = F.addIfAbsent(locMap, n - 1, compute.<BigInteger>future()); + ComputeTaskFuture<BigInteger> futVal = compute.future(); + + fut1 = locMap.putIfAbsent(n - 1, futVal); + + if (fut1 == null) + fut1 = futVal; } // 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()); + ComputeTaskFuture<BigInteger> futVal = compute.<BigInteger>future(); + + fut2 = locMap.putIfAbsent(n - 2, futVal); + + if (fut2 == null) + fut2 = futVal; } // If futures are not done, then wait asynchronously for the result http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b79009e/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..9067918 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,24 @@ class FibonacciClosure ( if (fut1 == null) { comp.apply(new FibonacciClosure(excludeNodeId), n - 1) - fut1 = GridFunc.addIfAbsent(store, n - 1, comp.future[BigInteger]()) + val futVal = comp.future[BigInteger]() + + fut1 = store.putIfAbsent(n - 1, futVal) + + if (fut1 == null) + fut1 = futVal } // If future is not cached in node-local store, cache it. if (fut2 == null) { comp.apply(new FibonacciClosure(excludeNodeId), n - 2) - fut2 = GridFunc.addIfAbsent(store, n - 2, comp.future[BigInteger]()) + val futVal = comp.future[BigInteger]() + + fut2 = store.putIfAbsent(n - 2, futVal) + + if (fut2 == null) + fut2 = futVal } // If futures are not done, then wait asynchronously for the result