ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [08/50] [abbrv] incubator-ignite git commit: #ignite-333: Fix tests.
Date Mon, 16 Mar 2015 12:51:40 GMT
#ignite-333: Fix tests.


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

Branch: refs/heads/ignite-gg-9858
Commit: bdf76343b85518ee58650edfbedd356ae09a057d
Parents: 6da0acf
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Thu Mar 12 18:23:44 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Thu Mar 12 18:23:44 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheProjection.java       |   4 +-
 .../processors/cache/GridCacheAdapter.java      |  14 +-
 .../cache/GridCacheProjectionImpl.java          |   8 +-
 .../processors/cache/GridCacheProxyImpl.java    |   8 +-
 .../processors/cache/IgniteCacheProxy.java      |   2 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java | 146 +++++++++++--------
 6 files changed, 107 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdf76343/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
index d027aec..5ca17a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
@@ -1274,7 +1274,7 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K,
V>> {
      *      if entry was in use at the time of this method invocation and could not be
      *      cleared.
      */
-    public void clearLocally(Set<K> keys);
+    public void clearLocallyAll(Set<K> keys);
 
     /**
      * Clears key on all nodes that store it's data. That is, caches are cleared on remote
@@ -1304,7 +1304,7 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K,
V>> {
      * @param keys Keys to clear.
      * @throws IgniteCheckedException In case of cache could not be cleared on any of the
nodes.
      */
-    public void clear(Set<K> keys) throws IgniteCheckedException;
+    public void clearAll(Set<K> keys) throws IgniteCheckedException;
 
     /**
      * Clears cache on all nodes that store it's data. That is, caches are cleared on remote

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdf76343/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 c6732ae..a0111ac 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
@@ -1339,7 +1339,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocally(Set<K> keys) {
+    @Override public void clearLocallyAll(Set<K> keys) {
         clearLocally0(keys);
     }
 
@@ -1444,11 +1444,11 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
     }
 
     /** {@inheritDoc} */
-    @Override public void clear(Set<K> keys) throws IgniteCheckedException {
+    @Override public void clearAll(Set<K> keys) throws IgniteCheckedException {
         // Clear local cache synchronously.
-        clearLocally(keys);
+        clearLocallyAll(keys);
 
-        clearRemotes(0, new GlobalClearKeySetCallable<K>(name(), keys));
+        clearRemotes(0, new GlobalClearKeySetCallable(name(), keys));
     }
 
     /** {@inheritDoc} */
@@ -1458,7 +1458,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<?> clearAsync(Set<K> keys) {
-        return clearAsync(new GlobalClearKeySetCallable<K>(name(), keys));
+        return clearAsync(new GlobalClearKeySetCallable(name(), keys));
     }
 
     /** {@inheritDoc} */
@@ -5624,7 +5624,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
      * Global clear keys.
      */
     @GridInternal
-    private static class GlobalClearKeySetCallable<K> extends GlobalClearCallable {
+    private static class GlobalClearKeySetCallable<K, V> extends GlobalClearCallable
{
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -5650,7 +5650,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
 
         /** {@inheritDoc} */
         @Override public Object call() throws Exception {
-            ((IgniteEx)ignite).cachex(cacheName).clearLocally(keys);
+            ((IgniteEx)ignite).<K, V>cachex(cacheName).clearLocallyAll(keys);
 
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdf76343/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
index 191c2a3..5c05f30 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
@@ -875,8 +875,8 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocally(Set<K> keys) {
-        cache.clearLocally(keys);
+    @Override public void clearLocallyAll(Set<K> keys) {
+        cache.clearLocallyAll(keys);
     }
 
     /** {@inheritDoc} */
@@ -890,8 +890,8 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public void clear(Set<K> keys) throws IgniteCheckedException {
-        cache.clear(keys);
+    @Override public void clearAll(Set<K> keys) throws IgniteCheckedException {
+        cache.clearAll(keys);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdf76343/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 6d1b58d..218b812 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -1312,11 +1312,11 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K,
V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Override public void clearLocally(Set<K> keys) {
+    @Override public void clearLocallyAll(Set<K> keys) {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 
         try {
-            delegate.clearLocally(keys);
+            delegate.clearLocallyAll(keys);
         }
         finally {
             gate.leave(prev);
@@ -1336,11 +1336,11 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K,
V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Override public void clear(Set<K> keys) throws IgniteCheckedException {
+    @Override public void clearAll(Set<K> keys) throws IgniteCheckedException {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 
         try {
-            delegate.clear(keys);
+            delegate.clearAll(keys);
         }
         finally {
             gate.leave(prev);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdf76343/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 5b9d801..14481cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -1068,7 +1068,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
             if (isAsync())
                 setFuture(delegate.clearAsync(keys));
             else
-                delegate.clear(keys);
+                delegate.clearAll(keys);
         }
         catch (IgniteCheckedException e) {
             throw cacheException(e);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bdf76343/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 0479d9b..b15d7ae 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
@@ -4098,92 +4098,121 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
      * @throws Exception If failed.
      */
     public void testLocalClearKey() throws Exception {
-        testLocalClearKey(false, Arrays.asList("key25"));
-    }
+        addKeys();
 
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLocalClearKeyAsync() throws Exception {
-        testLocalClearKey(true, Arrays.asList("key25"));
+        String keyToRemove = "key" + 25;
+
+        Ignite g = primaryIgnite(keyToRemove);
+
+        g.<String, Integer>jcache(null).localClear(keyToRemove);
+
+        for (int i = 0; i < 500; ++i) {
+            String key = "key" + i;
+
+            boolean found = primaryIgnite(key).jcache(null).localPeek(key) != null;
+
+            if (keyToRemove.equals(key))
+                assertFalse("Found removed key " + key, found);
+            else
+                assertTrue("Not found key " + key, found);
+        }
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testLocalClearKeys() throws Exception {
-        testLocalClearKey(false, Arrays.asList("key25", "key100", "key150"));
-    }
+        Map<String, List<String>> keys = addKeys();
 
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLocalClearKeysAsync() throws Exception {
-        testLocalClearKey(true, Arrays.asList("key25", "key100", "key150"));
+        Ignite g = grid(0);
+
+        Set<String> keysToRemove = new HashSet<>();
+
+        for (int i = 0; i < gridCount(); ++i) {
+            List<String> gridKeys = keys.get(grid(i).name());
+
+            if (gridKeys.size() > 2) {
+                keysToRemove.add(gridKeys.get(0));
+
+                keysToRemove.add(gridKeys.get(1));
+
+                g = grid(i);
+
+                break;
+            }
+        }
+
+        g.<String, Integer>jcache(null).localClearAll(keysToRemove);
+
+        for (int i = 0; i < 500; ++i) {
+            String key = "key" + i;
+
+            boolean found = primaryIgnite(key).jcache(null).localPeek(key) != null;
+
+            if (keysToRemove.contains(key))
+                assertFalse("Found removed key " + key, found);
+            else
+                assertTrue("Not found key " + key, found);
+        }
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testLocalClear() throws Exception {
-        testLocalClearKey(false, null);
-    }
+        Map<String, List<String>> keys = addKeys();
 
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLocalClearAsync() throws Exception {
-        testLocalClearKey(true, null);
-    }
+        Set<String> keysToRemove = new HashSet<>();
 
-    /**
-     * @param async If {@code true} uses async method.
-     * @throws Exception If failed.
-     */
-    protected void testLocalClearKey(boolean async, Collection<String> keysToRemove)
throws Exception {
-        // Save entries only on their primary nodes. If we didn't do so, clearLocally() will
not remove all entries
-        // because some of them were blocked due to having readers.
-        for (int i = 0; i < 500; ++i) {
-            Ignite g = primaryIgnite("key" + i);
+        Ignite g = grid(0);
 
-            g.jcache(null).put("key" + i, "value" + i);
-        }
+        for (int i = 0; i < gridCount(); ++i) {
+            List<String> gridKeys = keys.get(grid(i).name());
 
-        if (async) {
-            IgniteCache<String, Integer> asyncCache = jcache().withAsync();
+            if (gridKeys.size() > 0) {
+                keysToRemove.addAll(gridKeys);
 
-            if (keysToRemove == null)
-                asyncCache.localClear();
-            else if (keysToRemove.size() == 1)
-                asyncCache.localClear(F.first(keysToRemove));
-            else
-                asyncCache.localClearAll(new HashSet(keysToRemove));
+                g = grid(i);
 
-            asyncCache.future().get();
-        }
-        else {
-            if (keysToRemove == null)
-                jcache().localClear();
-            else if (keysToRemove.size() == 1)
-                jcache().localClear(F.first(keysToRemove));
-            else
-                jcache().localClearAll(new HashSet(keysToRemove));
+                break;
+            }
         }
 
+        g.jcache(null).localClear();
+
         for (int i = 0; i < 500; ++i) {
             String key = "key" + i;
 
-            boolean found = false;
-
-            for (int j = 0; j < gridCount(); j++)
-                if (jcache(j).localPeek(key) != null)
-                    found = true;
+            boolean found = primaryIgnite(key).jcache(null).localPeek(key) != null;
 
-            if (keysToRemove == null || keysToRemove.contains(key))
+            if (keysToRemove.contains(key))
                 assertFalse("Found removed key " + key, found);
             else
                 assertTrue("Not found key " + key, found);
         }
+
+        assertEquals(0, g.jcache(null).localSize());
+    }
+
+    private Map<String, List<String>> addKeys() {
+        // Save entries only on their primary nodes. If we didn't do so, clearLocally() will
not remove all entries
+        // because some of them were blocked due to having readers.
+        Map<String, List<String>> keys = new HashMap<>();
+
+        for (int i = 0; i < gridCount(); ++i)
+            keys.put(grid(i).name(), new ArrayList<String>());
+
+        for (int i = 0; i < 500; ++i) {
+            String key = "key" + i;
+
+            Ignite g = primaryIgnite(key);
+
+            g.jcache(null).put(key, "value" + i);
+
+            keys.get(g.name()).add(key);
+        }
+
+        return keys;
     }
 
     /**
@@ -4247,9 +4276,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             boolean found = false;
 
             for (int j = 0; j < gridCount(); j++)
-                if (jcache(j).localPeek(key) != null)
+                if (jcache(j).localPeek(key) != null) {
                     found = true;
 
+                    info("Found key " + key + " on node " + j);
+                }
+
             if (!keysToRemove.contains(key))
                 assertTrue("Not found key " + key, found);
             else


Mime
View raw message