# ignite-299 : Use ConcurrentMap instead of ClusterNodeLocalMap (delete 2 additional methods from ClusterNodeLocalMap)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/798cce81 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/798cce81 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/798cce81 Branch: refs/heads/ignite-217 Commit: 798cce8161c88a87c2bb60973c2d5ceabf22826b Parents: f1ec719 Author: Artem Shutak <ashu...@gridgain.com> Authored: Fri Feb 20 16:03:29 2015 +0300 Committer: Artem Shutak <ashu...@gridgain.com> Committed: Fri Feb 20 16:03:29 2015 +0300 ---------------------------------------------------------------------- .../ComputeFibonacciContinuationExample.java | 5 ++-- .../examples/ScalarContinuationExample.scala | 11 +++++---- .../ignite/cluster/ClusterNodeLocalMap.java | 24 -------------------- 3 files changed, 9 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/798cce81/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 0e04607..c1792b6 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,6 +21,7 @@ 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.*; @@ -136,14 +137,14 @@ public final class ComputeFibonacciContinuationExample { if (fut1 == null) { compute.apply(new FibonacciClosure(nodeFilter), n - 1); - fut1 = locMap.addIfAbsent(n - 1, compute.<BigInteger>future()); + fut1 = F.addIfAbsent(locMap, n - 1, compute.<BigInteger>future()); } // If future is not cached in node-local-map, cache it. if (fut2 == null) { compute.apply(new FibonacciClosure(nodeFilter), n - 2); - fut2 = locMap.addIfAbsent(n - 2, compute.<BigInteger>future()); + fut2 = F.addIfAbsent(locMap, n - 2, compute.<BigInteger>future()); } // If futures are not done, then wait asynchronously for the result http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/798cce81/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 fc3cb53..ae2bebc 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 @@ -17,16 +17,17 @@ package org.apache.ignite.scalar.examples -import java.math._ -import java.util - 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 import org.apache.ignite.scalar.scalar._ import org.jetbrains.annotations.Nullable +import java.math._ +import java.util + /** * This example recursively calculates `Fibonacci` numbers on the ignite cluster. This is * a powerful design pattern which allows for creation of fully distributively recursive @@ -121,14 +122,14 @@ class FibonacciClosure ( if (fut1 == null) { comp.apply(new FibonacciClosure(excludeNodeId), n - 1) - fut1 = store.addIfAbsent(n - 1, comp.future[BigInteger]()) + fut1 = GridFunc.addIfAbsent(store, n - 1, comp.future[BigInteger]()) } // If future is not cached in node-local store, cache it. if (fut2 == null) { comp.apply(new FibonacciClosure(excludeNodeId), n - 2) - fut2 = store.addIfAbsent(n - 2, comp.future[BigInteger]()) + fut2 = GridFunc.addIfAbsent(store, n - 2, comp.future[BigInteger]()) } // If futures are not done, then wait asynchronously for the result http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/798cce81/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNodeLocalMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNodeLocalMap.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNodeLocalMap.java index b2e69af..e01539a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNodeLocalMap.java +++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNodeLocalMap.java @@ -17,8 +17,6 @@ package org.apache.ignite.cluster; -import org.jetbrains.annotations.*; - import java.util.concurrent.*; /** @@ -35,26 +33,4 @@ import java.util.concurrent.*; * You can get an instance of {@code GridNodeLocalMap} by calling {@link org.apache.ignite.IgniteCluster#nodeLocalMap()} method. */ public interface ClusterNodeLocalMap<K, V> extends ConcurrentMap<K, V> { - /** - * Gets the value with given key. If that value does not exist, calls given closure - * to get the default value, puts it into the map and returns it. If closure is {@code null} - * return {@code null}. - * - * @param key Key to get the value for. - * @param dflt Default value producing closure. - * @return Value for the key or the value produced by the closure if key - * does not exist in the map. Return {@code null} if key is not found and - * closure is {@code null}. - */ - public V addIfAbsent(K key, @Nullable Callable<V> dflt); - - /** - * Unlike its sibling method {@link #putIfAbsent(Object, Object)} this method returns - * current mapping from the map. - * - * @param key Key. - * @param val Value to put if one does not exist. - * @return Current mapping for a given key. - */ - public V addIfAbsent(K key, V val); }