Ignite-54 Clear(key) removed from tests & most of classes & marked as deprecated


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

Branch: refs/heads/ignite-54
Commit: 8241e416ae621d31a953b6e539ca3cbf9a69bb5b
Parents: 3e3d66c
Author: avinogradov <avinogra...@gridgain.com>
Authored: Thu Jan 22 17:24:30 2015 +0300
Committer: avinogradov <avinogra...@gridgain.com>
Committed: Thu Jan 22 17:24:30 2015 +0300

----------------------------------------------------------------------
 .../grid/cache/GridCacheProjection.java         |   1 +
 .../kernal/processors/cache/GridCacheUtils.java |  11 -
 .../cache/GridCacheAbstractFullApiSelfTest.java | 228 +++++++++++--------
 .../GridCacheAbstractProjectionSelfTest.java    |  11 +-
 ...heAbstractTransformWriteThroughSelfTest.java |   3 +-
 .../dht/GridCacheDhtEntrySelfTest.java          |  45 ----
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java |  89 --------
 ...eAtomicNearOnlyMultiNodeFullApiSelfTest.java |  77 -------
 ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 134 -----------
 .../GridCacheNearPartitionedClearSelfTest.java  |   4 +-
 .../GridHibernateAccessStrategyAdapter.java     |  61 +----
 .../cache/GridCacheQueryLoadSelfTest.java       |  13 +-
 12 files changed, 156 insertions(+), 521 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java 
b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
index c9fe497..c4ae74b 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
@@ -1368,6 +1368,7 @@ public interface GridCacheProjection<K, V> extends 
Iterable<GridCacheEntry<K, V>
      *      if entry was in use at the time of this method invocation and 
could not be
      *      cleared.
      */
+    @Deprecated
     public boolean clear(K key);
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java
index cf10e91..9224c70 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java
@@ -1648,17 +1648,6 @@ public class GridCacheUtils {
     }
 
     /**
-     * Invalidate entry in cache.
-     *
-     * @param cache Cache.
-     * @param key Key.
-     * @return {@code True} if entry was invalidated.
-     */
-    public static <K, V> boolean invalidate(GridCacheProjection<K, V> cache, K 
key) {
-        return cache.clear(key);
-    }
-
-    /**
      * @param duration Duration.
      * @return TTL.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 5c6284d..2df8daa 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -195,7 +195,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         for (int i = 0; i < gridCount(); i++) {
             // Will actually delete entry from map.
-            CU.invalidate(cache(i), "key0");
+            cache(i).remove("key0");
 
             assertNull("Failed check for grid: " + i, cache(i).peek("key0"));
 
@@ -1849,19 +1849,34 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertEquals((Integer)3, cache().get("key3"));
 
         cache().evict("key2");
-        cache().clear("key3");
 
         // Same checks inside tx.
         tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assertEquals((Integer)1, cache().putIfAbsent("key2", 3));
-            assertEquals((Integer)3, cache().putIfAbsent("key3", 4));
 
             if (tx != null)
                 tx.commit();
 
             assertEquals((Integer)1, cache().get("key2"));
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
+        cache().globalClearAll();
+
+        // Same checks inside tx.
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assertEquals((Integer)3, cache().putIfAbsent("key3", 4));
+
+            if (tx != null)
+                tx.commit();
+
             assertEquals((Integer)3, cache().get("key3"));
         }
         finally {
@@ -1908,19 +1923,34 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertEquals((Integer)3, cache().putIfAbsentAsync("key3", 4).get());
 
         cache().evict("key2");
-        cache().clear("key3");
 
         // Same checks inside tx.
         tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assertEquals((Integer)1, cache().putIfAbsentAsync("key2", 
3).get());
-            assertEquals((Integer)3, cache().putIfAbsentAsync("key3", 
4).get());
 
             if (tx != null)
                 tx.commit();
 
             assertEquals((Integer)1, cache().get("key2"));
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
+        cache().globalClearAll();
+
+        // Same checks inside tx.
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assertEquals((Integer)3, cache().putIfAbsentAsync("key3", 
4).get());
+
+            if (tx != null)
+                tx.commit();
+
             assertEquals((Integer)3, cache().get("key3"));
         }
         finally {
@@ -1952,19 +1982,34 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertFalse(cache().putxIfAbsent("key3", 4));
 
         cache().evict("key2");
-        cache().clear("key3");
 
         // Same checks inside tx.
         IgniteTx tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assertFalse(cache().putxIfAbsent("key2", 3));
-            assertFalse(cache().putxIfAbsent("key3", 4));
 
             if (tx != null)
                 tx.commit();
 
             assertEquals((Integer)1, cache().get("key2"));
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
+        cache().globalClearAll();
+
+        // Same checks inside tx.
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assertFalse(cache().putxIfAbsent("key3", 4));
+
+            if (tx != null)
+                tx.commit();
+
             assertEquals((Integer)3, cache().get("key3"));
         }
         finally {
@@ -2016,14 +2061,12 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertFalse(cache().putxIfAbsentAsync("key3", 4).get());
 
         cache().evict("key2");
-        cache().clear("key3");
 
         // Same checks inside tx.
         IgniteTx tx = inTx ? cache().txStart() : null;
 
         try {
             assertFalse(cache().putxIfAbsentAsync("key2", 3).get());
-            assertFalse(cache().putxIfAbsentAsync("key3", 4).get());
 
             if (tx != null)
                 tx.commit();
@@ -2034,6 +2077,23 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         }
 
         assertEquals((Integer)1, cache().get("key2"));
+
+        cache().globalClearAll();
+
+        // Same checks inside tx.
+        tx = inTx ? cache().txStart() : null;
+
+        try {
+            assertFalse(cache().putxIfAbsentAsync("key3", 4).get());
+
+            if (tx != null)
+                tx.commit();
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
         assertEquals((Integer)3, cache().get("key3"));
     }
 
@@ -2111,24 +2171,39 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertEquals((Integer)6, cache().get("key2"));
 
         cache().evict("key");
-        cache().clear("key2");
 
         IgniteTx tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assert cache().replace("key", 4, 5);
-            assert cache().replace("key2", 6, 7);
 
             if (tx != null)
                 tx.commit();
 
             assert cache().get("key") == 5;
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
+        cache().globalClearAll();
+
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assert cache().replace("key2", 6, 7);
+
+            if (tx != null)
+                tx.commit();
+
             assert cache().get("key2") == 7;
         }
         finally {
             if (tx != null)
                 tx.close();
         }
+
     }
 
     /**
@@ -2158,13 +2233,11 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertEquals((Integer)6, cache().get("key2"));
 
         cache().evict("key");
-        cache().clear("key2");
 
         IgniteTx tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assert cache().replacex("key", 5);
-            assert cache().replacex("key2", 7);
 
             if (tx != null)
                 tx.commit();
@@ -2175,6 +2248,22 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         }
 
         assert cache().get("key") == 5;
+
+        cache().globalClearAll();
+
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assert cache().replacex("key2", 7);
+
+            if (tx != null)
+                tx.commit();
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
         assert cache().get("key2") == 7;
     }
 
@@ -2219,13 +2308,11 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assertEquals((Integer)6, cache().get("key2"));
 
         cache().evict("key");
-        cache().clear("key2");
 
         IgniteTx tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assert cache().replaceAsync("key", 4, 5).get();
-            assert cache().replaceAsync("key2", 6, 7).get();
 
             if (tx != null)
                 tx.commit();
@@ -2236,6 +2323,22 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         }
 
         assert cache().get("key") == 5;
+
+        cache().globalClearAll();
+
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assert cache().replaceAsync("key2", 6, 7).get();
+
+            if (tx != null)
+                tx.commit();
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
         assert cache().get("key2") == 7;
     }
 
@@ -2268,13 +2371,11 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         assert cache().get("key2") == 6;
 
         cache().evict("key");
-        cache().clear("key2");
 
         IgniteTx tx = txEnabled() ? cache().txStart() : null;
 
         try {
             assert cache().replacexAsync("key", 5).get();
-            assert cache().replacexAsync("key2", 7).get();
 
             if (tx != null)
                 tx.commit();
@@ -2285,6 +2386,22 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         }
 
         assert cache().get("key") == 5;
+
+        cache().globalClearAll();
+
+        tx = txEnabled() ? cache().txStart() : null;
+
+        try {
+            assert cache().replacexAsync("key2", 7).get();
+
+            if (tx != null)
+                tx.commit();
+        }
+        finally {
+            if (tx != null)
+                tx.close();
+        }
+
         assert cache().get("key2") == 7;
     }
 
@@ -2731,7 +2848,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         assertEquals((Integer)1, cache.peek(key));
 
-        cache.clear(key);
+        cache.globalClearAll();
 
         assertNull(cache.peek(key));
 
@@ -2849,11 +2966,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         cache.reloadAll(F.asList(keysArr));
 
-        for (String key : keys) {
-            assertEquals(vals.get(key), cache.peek(key));
-
-            cache.clear(key);
-        }
+        cache.globalClearAll();
 
         cache.reloadAll(keys);
 
@@ -2910,11 +3023,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         for (String key : keys)
             assertEquals(vals.get(key), cache.peek(key));
 
-        for (String key : keys) {
-            assertEquals(vals.get(key), cache.peek(key));
-
-            cache.clear(key);
-        }
+        cache.globalClearAll();
 
         cache.reloadAllAsync(keys).get();
 
@@ -3052,8 +3161,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         for (Integer k : keys)
             cache.put(k, k);
 
-        cache.clear(keys.get(0));
-        cache.clear(keys.get(1));
+        cache.globalClearAll();
 
         for (int g = 0; g < gridCount(); g++) {
             Ignite grid0 = grid(g);
@@ -3099,8 +3207,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         for (Integer k : keys)
             cache.put(k, k + 1);
 
-        cache.clear(keys.get(0));
-        cache.clear(keys.get(1));
+        cache.globalClearAll();
 
         for (int g = 0; g < gridCount(); g++) {
             Ignite grid0 = grid(g);
@@ -3177,14 +3284,6 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             cache.put(first, vals.get(first));
         }
 
-        cache.projection(gte100).clear(first);
-
-        assertNotNull(peek(cache, first));
-
-        cache.put(first, 101);
-
-        cache.projection(gte100).clear(first);
-
         assert cache.isEmpty() : "Values after clear: " + cache.values();
 
         i = 0;
@@ -3218,55 +3317,6 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
     /**
      * @throws Exception In case of error.
      */
-    public void testClearKeys() throws Exception {
-        GridCache<String, Integer> cache = cache();
-
-        Collection<String> keys = primaryKeysForCache(cache, 3);
-
-        for (String key : keys)
-            assertNull(cache.get(key));
-
-        String lastKey = F.last(keys);
-
-        Collection<String> subKeys = new ArrayList<>(keys);
-
-        subKeys.remove(lastKey);
-
-        Map<String, Integer> vals = new HashMap<>(keys.size());
-
-        int i = 0;
-
-        for (String key : keys)
-            vals.put(key, i++);
-
-        cache.putAll(vals);
-
-        for (String subKey : subKeys)
-            cache.clear(subKey);
-
-        for (String key : subKeys)
-            assertNull(cache.peek(key));
-
-        assertEquals(vals.get(lastKey), cache.peek(lastKey));
-
-        cache.clearAll();
-
-        vals.put(lastKey, 102);
-
-        cache.putAll(vals);
-
-        for (String key : keys)
-            cache.projection(gte100).clear(key);
-
-        assertNull(cache.peek(lastKey));
-
-        for (String key : subKeys)
-            assertEquals(vals.get(key), cache.peek(key));
-    }
-
-    /**
-     * @throws Exception In case of error.
-     */
     public void testGlobalClearAll() throws Exception {
         // Save entries only on their primary nodes. If we didn't do so, 
clearAll() will not remove all entries
         // because some of them were blocked due to having readers.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractProjectionSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractProjectionSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractProjectionSelfTest.java
index e04155e..5055419 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractProjectionSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractProjectionSelfTest.java
@@ -348,7 +348,7 @@ public abstract class GridCacheAbstractProjectionSelfTest 
extends GridCacheAbstr
 
         assert locPrj.containsKey("key");
 
-        locPrj.clear("key");
+        locPrj.globalClearAll();
 
         assert !locPrj.containsKey("key");
     }
@@ -487,8 +487,13 @@ public abstract class GridCacheAbstractProjectionSelfTest 
extends GridCacheAbstr
         assert prj.containsKey("key");
 
         assertFlagException(new CA() {
-            @Override public void apply() {
-                readPrj.clear("key");
+            @Override
+            public void apply() {
+                try {
+                    readPrj.globalClearAll();
+                } catch (IgniteCheckedException e) {
+                    log.error("globalClearAll method failed", e);
+                }
             }
         });
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
index a06f7f6..5f6dafe 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
@@ -251,8 +251,7 @@ public abstract class 
GridCacheAbstractTransformWriteThroughSelfTest extends Gri
 
         nearStore.reset();
 
-        for (String key : keys)
-            cache(0).clear(key);
+        cache(0).globalClearAll();
 
         info(">>> Starting transform transaction");
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
index 19c643a..e34835a 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
@@ -143,51 +143,6 @@ public class GridCacheDhtEntrySelfTest extends 
GridCommonAbstractTest {
     }
 
     /** @throws Exception If failed. */
-    public void testClearWithReaders() throws Exception {
-        Integer key = 1;
-
-        IgniteBiTuple<ClusterNode, ClusterNode> t = getNodes(key);
-
-        ClusterNode primary = t.get1();
-        ClusterNode other = t.get2();
-
-        GridCacheProjection<Integer, String> near0 = near(grid(primary.id()));
-        GridCacheProjection<Integer, String> near1 = near(grid(other.id()));
-
-        assert near0 != near1;
-
-        GridDhtCacheAdapter<Integer, String> dht0 = dht(grid(primary.id()));
-        GridDhtCacheAdapter<Integer, String> dht1 = dht(grid(other.id()));
-
-        // Put on primary node.
-        String val = "v1";
-
-        near0.put(key, val);
-
-        GridDhtCacheEntry<Integer, String> e0 = (GridDhtCacheEntry<Integer, 
String>)dht0.peekEx(key);
-        GridDhtCacheEntry<Integer, String> e1 = (GridDhtCacheEntry<Integer, 
String>)dht1.peekEx(key);
-
-        assert e0 == null || e0.readers().isEmpty();
-        assert e1 == null || e1.readers().isEmpty();
-
-        // Get value on other node.
-        assertEquals(val, near1.get(key));
-
-        assert e0 != null;
-
-        assert e0.readers().contains(other.id());
-        assert e1 == null || e1.readers().isEmpty();
-
-        assert !near0.clear(key);
-
-        assertEquals(1, near0.size());
-        assertEquals(1, dht0.size());
-
-        assertEquals(1, near1.size());
-        assertEquals(0, dht1.size());
-    }
-
-    /** @throws Exception If failed. */
     public void testRemoveWithReaders() throws Exception {
         Integer key = 1;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index 8ea4dff..47a74cb 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -131,95 +131,6 @@ public class 
GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache
 
         for (String key : keys)
             assertEquals(null, nearCache.peek(key));
-
-        String first = F.first(keys);
-
-        nearCache.projection(gte100).clear(first);
-
-        assertEquals(null, nearCache.peek(first));
-        assertEquals(vals.get(first), primary.peek(first));
-
-        nearCache.put(first, 101);
-
-        nearCache.projection(gte100).clear(first);
-
-        assertTrue(nearCache.isEmpty());
-        assertFalse(primary.isEmpty());
-
-        i = 0;
-
-        for (String key : keys) {
-            nearCache.put(key, i);
-
-            vals.put(key, i);
-
-            i++;
-        }
-
-        nearCache.put(first, 101);
-        vals.put(first, 101);
-
-        nearCache.projection(gte100).clear(first);
-
-        for (String key : keys)
-            assertEquals(vals.get(key), primary.peek(key));
-
-        for (String key : keys) {
-            if (first.equals(key))
-                assertNull(nearCache.peek(key));
-            else
-                assertEquals(null, nearCache.peek(key));
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void testClearKeys() throws Exception {
-        GridCache<String, Integer> nearCache = cache();
-        GridCache<String, Integer> primary = fullCache();
-
-        Collection<String> keys = primaryKeysForCache(primary, 3);
-
-        for (String key : keys)
-            assertNull(nearCache.get(key));
-
-        String lastKey = F.last(keys);
-
-        Collection<String> subKeys = new ArrayList<>(keys);
-
-        subKeys.remove(lastKey);
-
-        Map<String, Integer> vals = new HashMap<>(keys.size());
-
-        int i = 0;
-
-        for (String key : keys)
-            vals.put(key, i++);
-
-        nearCache.putAll(vals);
-
-        for (String subKey : subKeys)
-            nearCache.clear(subKey);
-
-        for (String key : subKeys) {
-            assertNull(nearCache.peek(key));
-            assertNotNull(primary.peek(key));
-        }
-
-        assertEquals(null, nearCache.peek(lastKey));
-
-        nearCache.clearAll();
-
-        vals.put(lastKey, 102);
-
-        nearCache.putAll(vals);
-
-        for (String key : keys)
-            nearCache.projection(gte100).clear(key);
-
-        assertNull(nearCache.peek(lastKey));
-
-        for (String key : subKeys)
-            assertEquals(null, nearCache.peek(key));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java
index 6861837..306034c 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java
@@ -74,83 +74,6 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest 
extends GridCacheNe
     }
 
     /** {@inheritDoc} */
-    @Override public void testClear() throws Exception {
-        GridCache<String, Integer> nearCache = cache();
-        GridCache<String, Integer> primary = fullCache();
-
-        Collection<String> keys = primaryKeysForCache(primary, 3);
-
-        Map<String, Integer> vals = new HashMap<>(keys.size());
-
-        int i = 0;
-
-        for (String key : keys) {
-            nearCache.put(key, i);
-
-            vals.put(key, i);
-
-            i++;
-        }
-
-        i = 0;
-
-        for (String key : keys)
-            assertEquals((Integer)i++, nearCache.peek(key));
-
-        nearCache.clearAll();
-
-        for (String key : keys)
-            assertNull(nearCache.peek(key));
-
-        for (Map.Entry<String, Integer> entry : vals.entrySet())
-            nearCache.put(entry.getKey(), entry.getValue());
-
-        i = 0;
-
-        for (String key : keys)
-            assertEquals((Integer)i++, nearCache.peek(key));
-
-        String first = F.first(keys);
-
-        nearCache.projection(gte100).clear(first);
-
-        assertEquals((Integer)0, nearCache.peek(first));
-        assertEquals(vals.get(first), primary.peek(first));
-
-        nearCache.put(first, 101);
-
-        nearCache.projection(gte100).clear(first);
-
-        assertNull(nearCache.peek(first));
-        assertFalse(primary.isEmpty());
-
-        i = 0;
-
-        for (String key : keys) {
-            nearCache.put(key, i);
-
-            vals.put(key, i);
-
-            i++;
-        }
-
-        nearCache.put(first, 101);
-        vals.put(first, 101);
-
-        nearCache.projection(gte100).clear(first);
-
-        for (String key : keys)
-            assertEquals(vals.get(key), primary.peek(key));
-
-        for (String key : keys) {
-            if (first.equals(key))
-                assertNull(nearCache.peek(key));
-            else
-                assertEquals(vals.get(key), nearCache.peek(key));
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public void testEvictExpired() throws Exception {
         GridCache<String, Integer> cache = cache();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
index 7cb1a5b..11cc51d 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
@@ -210,140 +210,6 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest 
extends GridCachePartitio
     }
 
     /** {@inheritDoc} */
-    @Override public void testClear() throws Exception {
-        GridCache<String, Integer> nearCache = cache();
-        GridCache<String, Integer> primary = fullCache();
-
-        Collection<String> keys = primaryKeysForCache(primary, 3);
-
-        info("Keys: " + keys);
-
-        Map<String, Integer> vals = new HashMap<>(keys.size());
-
-        int i = 0;
-
-        for (String key : keys) {
-            nearCache.put(key, i);
-
-            vals.put(key, i);
-
-            i++;
-        }
-
-        for (String key : keys)
-            assertEquals(vals.get(key), nearCache.peek(key));
-
-        nearCache.clearAll();
-
-        for (String key : keys)
-            assertNull(nearCache.peek(key));
-
-        for (Map.Entry<String, Integer> entry : vals.entrySet())
-            nearCache.put(entry.getKey(), entry.getValue());
-
-        for (String key : keys)
-            assertEquals(vals.get(key), nearCache.peek(key));
-
-        String first = F.first(keys);
-
-        assertTrue(nearCache.lock(first, 0L));
-
-        nearCache.clearAll();
-
-        assertEquals(vals.get(first), nearCache.peek(first));
-        assertEquals(vals.get(first), primary.peek(first));
-
-        nearCache.unlock(first);
-
-        nearCache.projection(gte100).clear(first);
-
-        assertEquals(vals.get(first), nearCache.peek(first));
-        assertEquals(vals.get(first), primary.peek(first));
-
-        nearCache.put(first, 101);
-
-        nearCache.projection(gte100).clear(first);
-
-        assertTrue(nearCache.isEmpty());
-        assertFalse(primary.isEmpty());
-
-        i = 0;
-
-        for (String key : keys) {
-            nearCache.put(key, i);
-
-            vals.put(key, i);
-
-            i++;
-        }
-
-        nearCache.put(first, 101);
-        vals.put(first, 101);
-
-        nearCache.projection(gte100).clear(first);
-
-        for (String key : keys)
-            assertEquals(vals.get(key), primary.peek(key));
-
-        for (String key : keys) {
-            if (first.equals(key))
-                assertNull(nearCache.peek(key));
-            else
-                assertEquals(vals.get(key), nearCache.peek(key));
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void testClearKeys() throws Exception {
-        GridCache<String, Integer> nearCache = cache();
-        GridCache<String, Integer> primary = fullCache();
-
-        Collection<String> keys = primaryKeysForCache(primary, 3);
-
-        for (String key : keys)
-            assertNull(nearCache.get(key));
-
-        String lastKey = F.last(keys);
-
-        Collection<String> subKeys = new ArrayList<>(keys);
-
-        subKeys.remove(lastKey);
-
-        Map<String, Integer> vals = new HashMap<>(keys.size());
-
-        int i = 0;
-
-        for (String key : keys)
-            vals.put(key, i++);
-
-        nearCache.putAll(vals);
-
-        for (String subKey : subKeys)
-            nearCache.clear(subKey);
-
-        for (String key : subKeys) {
-            assertNull(nearCache.peek(key));
-            assertNotNull(primary.peek(key));
-        }
-
-        assertEquals(vals.get(lastKey), nearCache.peek(lastKey));
-
-        nearCache.clearAll();
-
-        vals.put(lastKey, 102);
-
-        nearCache.putAll(vals);
-
-        for (String key : keys)
-            nearCache.projection(gte100).clear(key);
-
-        assertNull(nearCache.peek(lastKey));
-
-        for (String key : subKeys)
-            assertEquals(vals.get(key), nearCache.peek(key));
-    }
-
-    /** {@inheritDoc} */
     @Override public void testGlobalClearAll() throws Exception {
         // Save entries only on their primary nodes. If we didn't do so, 
clearAll() will not remove all entries
         // because some of them were blocked due to having readers.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
index d86cc95..7c0e5bd 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
@@ -104,7 +104,7 @@ public class GridCacheNearPartitionedClearSelfTest extends 
GridCommonAbstractTes
         int key = primaryKey0(grid(0), cache);
 
         cache.putx(key, 1);
-        cache.clear(key);
+        cache.globalClearAll();
 
         for (int i = 0; i < GRID_CNT; i++) {
             GridCache cache0 = cacheForIndex(i);
@@ -115,7 +115,7 @@ public class GridCacheNearPartitionedClearSelfTest extends 
GridCommonAbstractTes
         }
 
         cache.putx(key, 1);
-        cache.clear(key);
+        cache.globalClearAll();
 
         assertEquals(0, cache.size());
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/hibernate/src/main/java/org/gridgain/grid/cache/hibernate/GridHibernateAccessStrategyAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/hibernate/src/main/java/org/gridgain/grid/cache/hibernate/GridHibernateAccessStrategyAdapter.java
 
b/modules/hibernate/src/main/java/org/gridgain/grid/cache/hibernate/GridHibernateAccessStrategyAdapter.java
index f25e390..a9cfa49 100644
--- 
a/modules/hibernate/src/main/java/org/gridgain/grid/cache/hibernate/GridHibernateAccessStrategyAdapter.java
+++ 
b/modules/hibernate/src/main/java/org/gridgain/grid/cache/hibernate/GridHibernateAccessStrategyAdapter.java
@@ -285,7 +285,7 @@ public abstract class GridHibernateAccessStrategyAdapter {
      */
     static void evict(Ignite ignite, GridCacheProjection<Object,Object> cache, 
Object key) throws CacheException {
         try {
-            ignite.compute(cache.gridProjection()).call(new 
ClearKeyCallable(key, cache.name()));
+            cache.remove(key);
         }
         catch (IgniteCheckedException e) {
             throw new CacheException(e);
@@ -306,63 +306,4 @@ public abstract class GridHibernateAccessStrategyAdapter {
             throw new CacheException(e);
         }
     }
-
-    /**
-     * Callable invalidates given key.
-     */
-    private static class ClearKeyCallable implements Callable<Void>, 
Externalizable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        private Object key;
-
-        /** */
-        private String cacheName;
-
-        /**
-         * Empty constructor required by {@link Externalizable}.
-         */
-        public ClearKeyCallable() {
-            // No-op.
-        }
-
-        /**
-         * @param key Key to clear.
-         * @param cacheName Cache name.
-         */
-        private ClearKeyCallable(Object key, String cacheName) {
-            this.key = key;
-            this.cacheName = cacheName;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() throws IgniteCheckedException {
-            GridCache<Object, Object> cache = ignite.cache(cacheName);
-
-            assert cache != null;
-
-            cache.clear(key);
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
-            out.writeObject(key);
-
-            U.writeString(out, cacheName);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-            key = in.readObject();
-
-            cacheName = U.readString(in);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8241e416/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
index 86947cd..ea94cdf 100644
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
+++ 
b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
@@ -251,8 +251,7 @@ public class GridCacheQueryLoadSelfTest extends 
GridCommonAbstractTest {
         assert res.size() == PUT_CNT - 5;
         assert size(ValueObject.class) == PUT_CNT - 5;
 
-        for (Integer key : keys)
-            cache.clear(key);
+        cache.globalClearAll();
 
         assert cache.isEmpty();
         assertEquals(0, cache.size());
@@ -293,9 +292,7 @@ public class GridCacheQueryLoadSelfTest extends 
GridCommonAbstractTest {
         assert res.size() == PUT_CNT - 5;
         assert size(ValueObject.class) == PUT_CNT - 5;
 
-        // Invalidate will remove entries.
-        for (Integer key : keys)
-            cache.clear(key);
+        cache.globalClearAll();
 
         assert cache.isEmpty();
         assertEquals(0, cache.size());
@@ -327,8 +324,7 @@ public class GridCacheQueryLoadSelfTest extends 
GridCommonAbstractTest {
         for (int i = 0; i < PUT_CNT; i++)
             keys[i] = i;
 
-        for (Integer key : keys)
-            cache.clear(key);
+        cache.globalClearAll();
 
         assert cache.isEmpty();
         assertEquals(0, cache.size());
@@ -365,8 +361,7 @@ public class GridCacheQueryLoadSelfTest extends 
GridCommonAbstractTest {
         for (int i = 0; i < PUT_CNT; i++)
             keys[i] = i;
 
-        for (Integer key : keys)
-            cache.clear(key);
+        cache.globalClearAll();
 
         assert cache.isEmpty();
         assertEquals(0, cache.size());

Reply via email to