You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/07/01 16:49:47 UTC

[13/40] incubator-ignite git commit: # ignite-648: fix tests (based on primaryKeysForCache)

# ignite-648: fix tests (based on primaryKeysForCache)


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

Branch: refs/heads/ignite-648-failover
Commit: 1146e41136c2ed76dc948b38b8437d0898fa2985
Parents: cc48ec5
Author: ashutak <as...@gridgain.com>
Authored: Mon Jun 29 20:18:31 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Jun 29 20:18:31 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheAbstractFullApiSelfTest.java | 27 +++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1146e411/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 2986e02..483fc20 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -4009,10 +4009,31 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
      * @param cnt Keys count.
      * @return Collection of keys for which given cache is primary.
      */
-    protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) {
-        List<String> found = new ArrayList<>(cnt);
+    protected List<String> primaryKeysForCache(final IgniteCache<String, Integer> cache, final int cnt, final int startFrom) {
+        Ignite grid = cache.unwrap(Ignite.class);
+
+        if (!(cache instanceof IgniteCacheProcessProxy))
+            return primaryKeysForCache0(grid.name(), cnt, startFrom);
+        else {
+            final IgniteProcessProxy proxy = (IgniteProcessProxy)grid;
+
+            final String name = proxy.name();
+
+            return proxy.remoteCompute().call(new IgniteCallable<List<String>>() {
+                @Override public List<String> call() throws Exception {
+                    return primaryKeysForCache0(name, cnt, startFrom);
+                }
+            });
+        }
+    }
+
+    private List<String> primaryKeysForCache0(String name, int cnt, int startFrom) {
+        List<String> found = new ArrayList<>();
+
+        IgniteEx ignite = grid(name);
+
+        final IgniteCache<String, Integer> cache = ignite.cache(null);
 
-        Ignite ignite = cache.unwrap(Ignite.class);
         Affinity<Object> affinity = ignite.affinity(cache.getName());
 
         for (int i = startFrom; i < startFrom + 100_000; i++) {