You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/02/02 11:52:40 UTC

[1/2] incubator-ignite git commit: # ignite-158 rename ClusterGroup#forCache() to ClusterGroup#forCacheNodes().

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-158 [created] 1b9629d07


# ignite-158 rename ClusterGroup#forCache() to ClusterGroup#forCacheNodes().


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f04e0ec4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f04e0ec4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f04e0ec4

Branch: refs/heads/ignite-158
Commit: f04e0ec46f2b54aedb56f232e1f98da7ddacb2b8
Parents: 06d9b7d
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Feb 2 12:29:38 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Feb 2 12:29:38 2015 +0300

----------------------------------------------------------------------
 .../ignite/examples/datagrid/CacheEventsExample.java  |  2 +-
 .../examples/datagrid/CachePopularNumbersExample.java |  2 +-
 .../datastructures/CacheAtomicLongExample.java        |  2 +-
 .../datagrid/store/CacheStoreLoadDataExample.java     |  2 +-
 .../scalar/examples/ScalarCacheAffinityExample1.scala |  2 +-
 .../scalar/examples/ScalarCacheAffinityExample2.scala |  2 +-
 .../examples/ScalarCachePopularNumbersExample.scala   |  4 ++--
 .../java/org/apache/ignite/cluster/ClusterGroup.java  |  4 ++--
 .../apache/ignite/internal/ClusterGroupAdapter.java   |  2 +-
 .../ignite/internal/IgniteClusterAsyncImpl.java       |  4 ++--
 .../internal/processors/cache/GridCacheAdapter.java   | 14 +++++++-------
 .../continuous/GridCacheContinuousQueryAdapter.java   |  2 +-
 .../processors/dataload/IgniteDataLoaderImpl.java     |  4 ++--
 .../handlers/cache/GridCacheQueryCommandHandler.java  |  2 +-
 .../internal/GridProjectionForCachesSelfTest.java     | 10 +++++-----
 .../GridHadoopDefaultMapReducePlannerSelfTest.java    |  2 +-
 .../visor/commands/cache/VisorCacheClearCommand.scala |  2 +-
 .../commands/cache/VisorCacheCompactCommand.scala     |  2 +-
 .../visor/commands/cache/VisorCacheScanCommand.scala  |  4 ++--
 .../visor/commands/cache/VisorCacheSwapCommand.scala  |  2 +-
 20 files changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
index 80b4217..0cc05f2 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java
@@ -81,7 +81,7 @@ public class CacheEventsExample {
 
             // Subscribe to specified cache events on all nodes that have cache running.
             // Cache events are explicitly enabled in examples/config/example-cache.xml file.
-            g.events(g.cluster().forCache(CACHE_NAME)).remoteListen(locLsnr, rmtLsnr,
+            g.events(g.cluster().forCacheNodes(CACHE_NAME)).remoteListen(locLsnr, rmtLsnr,
                 EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_READ, EVT_CACHE_OBJECT_REMOVED);
 
             // Generate cache events.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
index 1617662..ab97cc8 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java
@@ -67,7 +67,7 @@ public class CachePopularNumbersExample {
             // Clean up caches on all nodes before run.
             g.cache(CACHE_NAME).globalClearAll(0);
 
-            ClusterGroup prj = g.cluster().forCache(CACHE_NAME);
+            ClusterGroup prj = g.cluster().forCacheNodes(CACHE_NAME);
 
             if (prj.nodes().isEmpty()) {
                 System.out.println("Grid does not have cache configured: " + CACHE_NAME);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java
index 51359fd..cdac189 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java
@@ -62,7 +62,7 @@ public final class CacheAtomicLongExample {
 
             // Try increment atomic long from all grid nodes.
             // Note that this node is also part of the grid.
-            g.compute(g.cluster().forCache(CACHE_NAME)).call(new IgniteCallable<Object>() {
+            g.compute(g.cluster().forCacheNodes(CACHE_NAME)).call(new IgniteCallable<Object>() {
                 @Override public Object call() throws  Exception {
                     for (int i = 0; i < RETRIES; i++)
                         System.out.println("AtomicLong value has been incremented: " + atomicLong.incrementAndGet());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java
index 7fded3c..6355945 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java
@@ -59,7 +59,7 @@ public class CacheStoreLoadDataExample {
             long start = System.currentTimeMillis();
 
             // Start loading cache on all caching nodes.
-            g.compute(g.cluster().forCache(null)).broadcast(new IgniteCallable<Object>() {
+            g.compute(g.cluster().forCacheNodes(null)).broadcast(new IgniteCallable<Object>() {
                 @Override public Object call() throws Exception {
                     // Load cache from persistent store.
                     cache.loadCache(null, 0, ENTRY_COUNT);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
index b0ca960..55714fe 100644
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
+++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample1.scala
@@ -106,7 +106,7 @@ object ScalarCacheAffinityExample1 {
      * @param keys Keys to populate.
      */
     private def populateCache(g: Ignite, keys: Seq[String]) {
-        var prj = g.cluster().forCache(NAME)
+        var prj = g.cluster().forCacheNodes(NAME)
 
         // Give preference to local node.
         if (prj.nodes().contains(g.cluster().localNode))

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample2.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample2.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample2.scala
index e12f3bf..74fefe2 100644
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample2.scala
+++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheAffinityExample2.scala
@@ -94,7 +94,7 @@ object ScalarCacheAffinityExample2 {
      * @param keys Keys to populate.
      */
     private def populateCache(g: Ignite, keys: Seq[String]) {
-        var prj = g.cluster().forCache(NAME)
+        var prj = g.cluster().forCacheNodes(NAME)
 
         // Give preference to local node.
         if (prj.nodes().contains(g.cluster().localNode))

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCachePopularNumbersExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCachePopularNumbersExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCachePopularNumbersExample.scala
index e52f431..3629b26 100644
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCachePopularNumbersExample.scala
+++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCachePopularNumbersExample.scala
@@ -58,7 +58,7 @@ object ScalarCachePopularNumbersExample extends App {
         println()
         println(">>> Cache popular numbers example started.")
 
-        val prj = grid$.cluster().forCache(CACHE_NAME)
+        val prj = grid$.cluster().forCacheNodes(CACHE_NAME)
 
         if (prj.nodes().isEmpty)
             println("Grid does not have cache configured: " + CACHE_NAME);
@@ -75,7 +75,7 @@ object ScalarCachePopularNumbersExample extends App {
                 query(POPULAR_NUMBERS_CNT)
 
                 // Clean up caches on all nodes after run.
-                grid$.cluster().forCache(CACHE_NAME).bcastRun(() => grid$.cache(CACHE_NAME).clearAll(), null)
+                grid$.cluster().forCacheNodes(CACHE_NAME).bcastRun(() => grid$.cache(CACHE_NAME).clearAll(), null)
             }
             finally {
                 popularNumbersQryTimer.cancel()

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
index 2237d9d..9f2f435 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
@@ -43,7 +43,7 @@ import java.util.*;
  * GridProjection randomNode = remoteNodes.forRandom();
  *
  * // Projection over all nodes with cache named "myCache" enabled.
- * GridProjection cacheNodes = g.forCache("myCache");
+ * GridProjection cacheNodes = g.forCacheNodes("myCache");
  *
  * // Projection over all nodes that have user attribute "group" set to value "worker".
  * GridProjection workerNodes = g.forAttribute("group", "worker");
@@ -145,7 +145,7 @@ public interface ClusterGroup {
      * @param cacheNames Optional additional cache names to include into projection.
      * @return Projection over nodes that have specified cache running.
      */
-    public ClusterGroup forCache(String cacheName, @Nullable String... cacheNames);
+    public ClusterGroup forCacheNodes(String cacheName, @Nullable String... cacheNames);
 
     /**
      * Creates projection for all nodes that have streamer with specified name running.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
index 820735e..7dff797 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
@@ -524,7 +524,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
     }
 
     /** {@inheritDoc} */
-    @Override public final ClusterGroup forCache(@Nullable String cacheName, @Nullable String... cacheNames) {
+    @Override public final ClusterGroup forCacheNodes(@Nullable String cacheName, @Nullable String... cacheNames) {
         return forPredicate(new CachesFilter(cacheName, cacheNames));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
index ae4b541..ea148ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
@@ -167,8 +167,8 @@ public class IgniteClusterAsyncImpl extends IgniteAsyncSupportAdapter<IgniteClus
     }
 
     /** {@inheritDoc} */
-    @Override public ClusterGroup forCache(String cacheName, @Nullable String... cacheNames) {
-        return grid.forCache(cacheName, cacheNames);
+    @Override public ClusterGroup forCacheNodes(String cacheName, @Nullable String... cacheNames) {
+        return grid.forCacheNodes(cacheName, cacheNames);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 3ed56c5..c68fa6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -192,7 +192,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
 
     /** {@inheritDoc} */
     @Override public ClusterGroup gridProjection() {
-        return ctx.grid().forCache(name());
+        return ctx.grid().forCacheNodes(name());
     }
 
     /**
@@ -1293,7 +1293,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
     @Override public void globalClearAll(long timeout) throws IgniteCheckedException {
         try {
             // Send job to remote nodes only.
-            Collection<ClusterNode> nodes = ctx.grid().forCache(name()).forRemotes().nodes();
+            Collection<ClusterNode> nodes = ctx.grid().forCacheNodes(name()).forRemotes().nodes();
 
             IgniteInternalFuture<Object> fut = null;
 
@@ -3717,7 +3717,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
 
         if (replaceExisting) {
             if (ctx.store().isLocalStore()) {
-                Collection<ClusterNode> nodes = ctx.grid().forCache(name()).nodes();
+                Collection<ClusterNode> nodes = ctx.grid().forCacheNodes(name()).nodes();
 
                 if (nodes.isEmpty())
                     return new GridFinishedFuture<>(ctx.kernalContext());
@@ -3738,7 +3738,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
             }
         }
         else {
-            Collection<ClusterNode> nodes = ctx.grid().forCache(name()).nodes();
+            Collection<ClusterNode> nodes = ctx.grid().forCacheNodes(name()).nodes();
 
             if (nodes.isEmpty())
                 return new GridFinishedFuture<>(ctx.kernalContext());
@@ -3819,7 +3819,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
      * @throws IgniteCheckedException If failed.
      */
     void globalLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws IgniteCheckedException {
-        ClusterGroup nodes = ctx.kernalContext().grid().cluster().forCache(ctx.name());
+        ClusterGroup nodes = ctx.kernalContext().grid().cluster().forCacheNodes(ctx.name());
 
         IgniteCompute comp = ctx.kernalContext().grid().compute(nodes).withNoFailover();
 
@@ -3833,7 +3833,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
      */
     IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
         throws IgniteCheckedException {
-        ClusterGroup nodes = ctx.kernalContext().grid().cluster().forCache(ctx.name());
+        ClusterGroup nodes = ctx.kernalContext().grid().cluster().forCacheNodes(ctx.name());
 
         IgniteCompute comp = ctx.kernalContext().grid().compute(nodes).withNoFailover();
 
@@ -4133,7 +4133,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
     private int globalSize(boolean primaryOnly) throws IgniteCheckedException {
         try {
             // Send job to remote nodes only.
-            Collection<ClusterNode> nodes = ctx.grid().forCache(name()).forRemotes().nodes();
+            Collection<ClusterNode> nodes = ctx.grid().forCacheNodes(name()).forRemotes().nodes();
 
             IgniteInternalFuture<Collection<Integer>> fut = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAdapter.java
index 13ab56f..e3636d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAdapter.java
@@ -256,7 +256,7 @@ public class GridCacheContinuousQueryAdapter<K, V> implements CacheContinuousQue
         if (prj == null)
             prj = ctx.grid();
 
-        prj = prj.forCache(ctx.name());
+        prj = prj.forCacheNodes(ctx.name());
 
         if (prj.nodes().isEmpty())
             throw new ClusterTopologyException("Failed to execute query (projection is empty): " + this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
index 3e8abd8..4e9222e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
@@ -172,7 +172,7 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay
 
         log = U.logger(ctx, logRef, IgniteDataLoaderImpl.class);
 
-        ClusterNode node = F.first(ctx.grid().forCache(cacheName).nodes());
+        ClusterNode node = F.first(ctx.grid().forCacheNodes(cacheName).nodes());
 
         if (node == null)
             throw new IllegalStateException("Cache doesn't exist: " + cacheName);
@@ -283,7 +283,7 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay
         if (isolated())
             return;
 
-        ClusterNode node = F.first(ctx.grid().forCache(cacheName).nodes());
+        ClusterNode node = F.first(ctx.grid().forCacheNodes(cacheName).nodes());
 
         if (node == null)
             throw new IgniteCheckedException("Failed to get node for cache: " + cacheName);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
index 2ebea11..aca05b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheQueryCommandHandler.java
@@ -144,7 +144,7 @@ public class GridCacheQueryCommandHandler extends GridRestCommandHandlerAdapter
      * @return Execution future.
      */
     private IgniteInternalFuture<GridRestResponse> broadcast(String cacheName, Callable<Object> c) {
-        IgniteCompute comp = ctx.grid().compute(ctx.grid().forCache(cacheName)).withNoFailover().withAsync();
+        IgniteCompute comp = ctx.grid().compute(ctx.grid().forCacheNodes(cacheName)).withNoFailover().withAsync();
 
         try {
             comp.broadcast(c);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
index 6e903d7..35c8afb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
@@ -34,7 +34,7 @@ import java.util.*;
 import static org.apache.ignite.cache.CacheMode.*;
 
 /**
- * Tests for {@link org.apache.ignite.cluster.ClusterGroup#forCache(String, String...)} method.
+ * Tests for {@link org.apache.ignite.cluster.ClusterGroup#forCacheNodes(String, String...)} method.
  */
 public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
     /** */
@@ -109,7 +109,7 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testProjectionForDefaultCache() throws Exception {
-        ClusterGroup prj = ignite.cluster().forCache(null);
+        ClusterGroup prj = ignite.cluster().forCacheNodes(null);
 
         assert prj != null;
         assert prj.nodes().size() == 3;
@@ -124,7 +124,7 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testProjectionForNamedCache() throws Exception {
-        ClusterGroup prj = ignite.cluster().forCache(CACHE_NAME);
+        ClusterGroup prj = ignite.cluster().forCacheNodes(CACHE_NAME);
 
         assert prj != null;
         assert prj.nodes().size() == 3;
@@ -139,7 +139,7 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testProjectionForBothCaches() throws Exception {
-        ClusterGroup prj = ignite.cluster().forCache(null, CACHE_NAME);
+        ClusterGroup prj = ignite.cluster().forCacheNodes(null, CACHE_NAME);
 
         assert prj != null;
         assert prj.nodes().size() == 2;
@@ -154,7 +154,7 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testProjectionForWrongCacheName() throws Exception {
-        ClusterGroup prj = ignite.cluster().forCache("wrong");
+        ClusterGroup prj = ignite.cluster().forCacheNodes("wrong");
 
         assert prj != null;
         assert prj.nodes().isEmpty();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
index 65b8ba2..014f7c5 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
@@ -1140,7 +1140,7 @@ public class GridHadoopDefaultMapReducePlannerSelfTest extends GridHadoopAbstrac
         }
 
         /** {@inheritDoc} */
-        @Override public ClusterGroup forCache(String cacheName, @Nullable String... cacheNames) {
+        @Override public ClusterGroup forCacheNodes(String cacheName, @Nullable String... cacheNames) {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommand.scala
index d78ee0e..5566336 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheClearCommand.scala
@@ -103,7 +103,7 @@ class VisorCacheClearCommand {
             case Some(name) => name
         }
 
-        val prj = if (node.isDefined) grid.forNode(node.get) else grid.forCache(cacheName)
+        val prj = if (node.isDefined) grid.forNode(node.get) else grid.forCacheNodes(cacheName)
 
         if (prj.nodes().isEmpty) {
             val msg =

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala
index f93c998..0afef57 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCompactCommand.scala
@@ -103,7 +103,7 @@ class VisorCacheCompactCommand {
             case Some(name) => name
         }
 
-        val prj = if (node.isDefined) grid.forNode(node.get) else grid.forCache(cacheName)
+        val prj = if (node.isDefined) grid.forNode(node.get) else grid.forCacheNodes(cacheName)
 
         if (prj.nodes().isEmpty) {
             val msg =

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala
index 4008cb6..c36e37c 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheScanCommand.scala
@@ -139,8 +139,8 @@ class VisorCacheScanCommand {
         }
 
         val cachePrj = node match {
-            case Some(n) => grid.forNode(n).forCache(cacheName)
-            case _ => grid.forCache(cacheName)
+            case Some(n) => grid.forNode(n).forCacheNodes(cacheName)
+            case _ => grid.forCacheNodes(cacheName)
         }
 
         if (cachePrj.nodes().isEmpty) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f04e0ec4/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheSwapCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheSwapCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheSwapCommand.scala
index dc2c878..79088d0 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheSwapCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheSwapCommand.scala
@@ -103,7 +103,7 @@ class VisorCacheSwapCommand {
             case Some(name) => name
         }
 
-        val prj = if (node.isDefined) grid.forNode(node.get) else grid.forCache(cacheName)
+        val prj = if (node.isDefined) grid.forNode(node.get) else grid.forCacheNodes(cacheName)
 
         if (prj.nodes().isEmpty) {
             val msg =


[2/2] incubator-ignite git commit: IGNITE-158 implement ClusterGroup#forClientNodes() and ClusterGroup#forClientNodes().

Posted by se...@apache.org.
IGNITE-158 implement ClusterGroup#forClientNodes() and ClusterGroup#forClientNodes().


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1b9629d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1b9629d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1b9629d0

Branch: refs/heads/ignite-158
Commit: 1b9629d07ef7f2a7dd7a43ae41296e79a9a9612b
Parents: f04e0ec
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Feb 2 13:51:34 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Feb 2 13:51:34 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cluster/ClusterGroup.java | 23 ++++++++
 .../ignite/internal/ClusterGroupAdapter.java    | 55 ++++++++++++++++++--
 .../ignite/internal/IgniteClusterAsyncImpl.java | 10 ++++
 .../GridProjectionForCachesSelfTest.java        | 44 ++++++++++++++--
 ...idHadoopDefaultMapReducePlannerSelfTest.java | 10 ++++
 5 files changed, 134 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9629d0/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
index 9f2f435..6267dbe 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cluster;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
@@ -148,6 +149,28 @@ public interface ClusterGroup {
     public ClusterGroup forCacheNodes(String cacheName, @Nullable String... cacheNames);
 
     /**
+     * Creates projection for all nodes that have cache with specified name running and cache distribution mode is
+     * {@link CacheDistributionMode#PARTITIONED_ONLY} or {@link CacheDistributionMode#NEAR_PARTITIONED}.
+     *
+     * @param cacheName Cache name.
+     * @param cacheNames Optional additional cache names to include into projection.
+     * @return Projection over nodes that have specified cache running.
+     * @see CacheConfiguration#getDistributionMode()
+     */
+    public ClusterGroup forDataNodes(String cacheName, @Nullable String... cacheNames);
+
+    /**
+     * Creates projection for all nodes that have cache with specified name running and cache distribution mode is
+     * {@link CacheDistributionMode#CLIENT_ONLY} or {@link CacheDistributionMode#NEAR_ONLY}.
+     *
+     * @param cacheName Cache name.
+     * @param cacheNames Optional additional cache names to include into projection.
+     * @return Projection over nodes that have specified cache running.
+     * @see CacheConfiguration#getDistributionMode()
+     */
+    public ClusterGroup forClientNodes(String cacheName, @Nullable String... cacheNames);
+
+    /**
      * Creates projection for all nodes that have streamer with specified name running.
      *
      * @param streamerName Streamer name.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9629d0/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
index 7dff797..fafb23c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
@@ -18,7 +18,9 @@
 package org.apache.ignite.internal;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.internal.executor.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -525,7 +527,17 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
 
     /** {@inheritDoc} */
     @Override public final ClusterGroup forCacheNodes(@Nullable String cacheName, @Nullable String... cacheNames) {
-        return forPredicate(new CachesFilter(cacheName, cacheNames));
+        return forPredicate(new CachesFilter(cacheName, cacheNames, null));
+    }
+
+    /** {@inheritDoc} */
+    @Override public final ClusterGroup forDataNodes(@Nullable String cacheName, @Nullable String... cacheNames) {
+        return forPredicate(new CachesFilter(cacheName, cacheNames, CachesFilter.DATA_MODES));
+    }
+
+    /** {@inheritDoc} */
+    @Override public final ClusterGroup forClientNodes(@Nullable String cacheName, @Nullable String... cacheNames) {
+        return forPredicate(new CachesFilter(cacheName, cacheNames, CachesFilter.CLIENT_MODES));
     }
 
     /** {@inheritDoc} */
@@ -652,6 +664,14 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
      */
     private static class CachesFilter implements IgnitePredicate<ClusterNode> {
         /** */
+        private static final Set<CacheDistributionMode> DATA_MODES = EnumSet.of(CacheDistributionMode.NEAR_PARTITIONED,
+            CacheDistributionMode.PARTITIONED_ONLY);
+
+        /** */
+        private static final Set<CacheDistributionMode> CLIENT_MODES = EnumSet.of(CacheDistributionMode.CLIENT_ONLY,
+            CacheDistributionMode.NEAR_ONLY);
+
+        /** */
         private static final long serialVersionUID = 0L;
 
         /** Cache name. */
@@ -660,27 +680,54 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
         /** Cache names. */
         private final String[] cacheNames;
 
+        /** */
+        private final Set<CacheDistributionMode> distributionMode;
+
         /**
          * @param cacheName Cache name.
          * @param cacheNames Cache names.
+         * @param distributionMode Filter by {@link CacheConfiguration#getDistributionMode()}.
          */
-        private CachesFilter(@Nullable String cacheName, @Nullable String[] cacheNames) {
+        private CachesFilter(@Nullable String cacheName, @Nullable String[] cacheNames,
+            @Nullable Set<CacheDistributionMode> distributionMode) {
             this.cacheName = cacheName;
             this.cacheNames = cacheNames;
+            this.distributionMode = distributionMode;
         }
 
         /** {@inheritDoc} */
         @Override public boolean apply(ClusterNode n) {
-            if (!U.hasCache(n, cacheName))
+            GridCacheAttributes[] caches = n.attribute(ATTR_CACHE);
+
+            if (caches == null)
+                return false;
+
+            if (!hasCache(caches, cacheName, distributionMode))
                 return false;
 
             if (!F.isEmpty(cacheNames))
                 for (String cn : cacheNames)
-                    if (!U.hasCache(n, cn))
+                    if (!hasCache(caches, cn, distributionMode))
                         return false;
 
             return true;
         }
+
+        /**
+         * @param cacheName Cache name to check.
+         * @param distributionMode Filter by {@link CacheConfiguration#getDistributionMode()}.
+         * @return {@code true} if given node has specified cache started.
+         */
+        public static boolean hasCache(GridCacheAttributes[] caches, @Nullable String cacheName,
+            @Nullable Collection<CacheDistributionMode> distributionMode) {
+            for (GridCacheAttributes attrs : caches) {
+                if (Objects.equals(cacheName, attrs.cacheName())
+                    && (distributionMode == null || distributionMode.contains(attrs.partitionedTaxonomy())))
+                    return true;
+            }
+
+            return false;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9629d0/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
index ea148ff..7e2eaf1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteClusterAsyncImpl.java
@@ -172,6 +172,16 @@ public class IgniteClusterAsyncImpl extends IgniteAsyncSupportAdapter<IgniteClus
     }
 
     /** {@inheritDoc} */
+    @Override public ClusterGroup forDataNodes(String cacheName, @Nullable String... cacheNames) {
+        return grid.forDataNodes(cacheName, cacheNames);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ClusterGroup forClientNodes(String cacheName, @Nullable String... cacheNames) {
+        return grid.forClientNodes(cacheName, cacheNames);
+    }
+
+    /** {@inheritDoc} */
     @Override public ClusterGroup forStreamer(String streamerName, @Nullable String... streamerNames) {
         return grid.forStreamer(streamerName, streamerNames);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9629d0/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
index 35c8afb..8bcceb1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
@@ -53,11 +53,12 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
         cfg.setDiscoverySpi(discoverySpi());
 
         if (gridName.equals(getTestGridName(0)))
-            cfg.setCacheConfiguration(cacheConfiguration(null));
+            cfg.setCacheConfiguration(cacheConfiguration(null, CacheDistributionMode.PARTITIONED_ONLY));
         else if (gridName.equals(getTestGridName(1)))
-            cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME));
+            cfg.setCacheConfiguration(cacheConfiguration(CACHE_NAME, CacheDistributionMode.NEAR_ONLY));
         else if (gridName.equals(getTestGridName(2)) || gridName.equals(getTestGridName(3)))
-            cfg.setCacheConfiguration(cacheConfiguration(null), cacheConfiguration(CACHE_NAME));
+            cfg.setCacheConfiguration(cacheConfiguration(null, CacheDistributionMode.CLIENT_ONLY),
+                cacheConfiguration(CACHE_NAME, CacheDistributionMode.NEAR_PARTITIONED));
         else
             cfg.setCacheConfiguration();
 
@@ -79,11 +80,14 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
      * @param cacheName Cache name.
      * @return Cache configuration.
      */
-    private CacheConfiguration cacheConfiguration(@Nullable String cacheName) {
+    private CacheConfiguration cacheConfiguration(@Nullable String cacheName, CacheDistributionMode distributionMode) {
         CacheConfiguration cfg = defaultCacheConfiguration();
 
         cfg.setName(cacheName);
         cfg.setCacheMode(PARTITIONED);
+
+        cfg.setDistributionMode(distributionMode);
+
         cfg.setBackups(1);
 
         return cfg;
@@ -153,6 +157,38 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testProjectionForDataCaches() throws Exception {
+        ClusterGroup prj = ignite.cluster().forDataNodes(null);
+
+        assert prj != null;
+        assert prj.nodes().size() == 1;
+        assert prj.nodes().contains(grid(0).localNode());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testProjectionForClientCaches() throws Exception {
+        ClusterGroup prj = ignite.cluster().forClientNodes(CACHE_NAME);
+
+        assert prj != null;
+        assert prj.nodes().size() == 1;
+        assert prj.nodes().contains(grid(1).localNode());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testProjectionForClientBothCaches() throws Exception {
+        ClusterGroup prj = ignite.cluster().forClientNodes(null, CACHE_NAME);
+
+        assert prj != null;
+        assert prj.nodes().isEmpty();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testProjectionForWrongCacheName() throws Exception {
         ClusterGroup prj = ignite.cluster().forCacheNodes("wrong");
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9629d0/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
index 014f7c5..ca927ec 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java
@@ -1145,6 +1145,16 @@ public class GridHadoopDefaultMapReducePlannerSelfTest extends GridHadoopAbstrac
         }
 
         /** {@inheritDoc} */
+        @Override public ClusterGroup forDataNodes(String cacheName, @Nullable String... cacheNames) {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public ClusterGroup forClientNodes(String cacheName, @Nullable String... cacheNames) {
+            return null;
+        }
+
+        /** {@inheritDoc} */
         @Override public ClusterGroup forStreamer(String streamerName, @Nullable String... streamerNames) {
             return null;
         }