Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-565 0729b898f -> 848e1de73


#ignite-565: remove GridCache from 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/848e1de7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/848e1de7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/848e1de7

Branch: refs/heads/ignite-565
Commit: 848e1de73402624589b28ba5944167cc22007711
Parents: 0729b89
Author: ivasilinets <ivasilin...@gridgain.com>
Authored: Tue Mar 24 19:58:12 2015 +0300
Committer: ivasilinets <ivasilin...@gridgain.com>
Committed: Tue Mar 24 19:58:12 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheOffHeapSelfTest.java         |  24 ----
 .../IgniteCacheSystemTransactionsSelfTest.java  |   2 +-
 .../cache/GridCacheOffHeapAndSwapSelfTest.java  | 119 ++++++++-----------
 .../processors/cache/GridCacheSwapSelfTest.java |  24 ----
 4 files changed, 50 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/848e1de7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
index ab9c5ad..2e2b01e 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
@@ -185,30 +185,6 @@ public class GridCacheOffHeapSelfTest extends 
GridCommonAbstractTest {
     }
 
     /**
-     * @param cache Cache.
-     * @param timeout Timeout.
-     * @return {@code True} if success.
-     * @throws InterruptedException If thread was interrupted.
-     */
-    @SuppressWarnings({"BusyWait"})
-    private boolean waitCacheEmpty(CacheProjection<Integer,Object> cache, long 
timeout)
-        throws InterruptedException {
-        assert cache != null;
-        assert timeout >= 0;
-
-        long end = System.currentTimeMillis() + timeout;
-
-        while (end - System.currentTimeMillis() >= 0) {
-            if (cache.isEmpty())
-                return true;
-
-            Thread.sleep(500);
-        }
-
-        return cache.isEmpty();
-    }
-
-    /**
      * @throws Exception If failed.
      */
     public void testOffHeap() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/848e1de7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
index 0d72d35..f06838a 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
@@ -110,7 +110,7 @@ public class IgniteCacheSystemTransactionsSelfTest extends 
GridCacheAbstractSelf
             utilityCache.get("1");
             utilityCache.put("1", "11");
 
-            CacheProjection<String,String> marshallerCache = 
(GridCacheAdapter<String, 
String>)(GridCacheAdapter)ignite.context().cache().marshallerCache();
+            GridCacheAdapter<String,String> marshallerCache = 
(GridCacheAdapter<String, 
String>)(GridCacheAdapter)ignite.context().cache().marshallerCache();
 
             marshallerCache.putIfAbsent("2", "2");
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/848e1de7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
index 582655b..0cfd0d6 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
@@ -32,6 +33,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.spi.swapspace.file.*;
 import org.apache.ignite.testframework.junits.common.*;
 
+import javax.cache.*;
 import java.util.*;
 import java.util.concurrent.atomic.*;
 
@@ -39,7 +41,6 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.configuration.DeploymentMode.*;
 import static org.apache.ignite.events.EventType.*;
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
 
 /**
  * Tests off heap storage when both offheaped and swapped entries exists.
@@ -185,11 +186,11 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @return Cache to use in tests.
      * @throws Exception If failed.
      */
-    private GridCache<Long, Long> populate() throws Exception {
-        GridCache<Long, Long> cache = ((IgniteKernal)grid(0)).getCache(null);
+    private IgniteCache<Long, Long> populate() throws Exception {
+        IgniteCache<Long, Long> cache = grid(0).cache(null);
 
         assertEquals(0, cache.size());
-        assertEquals(0, cache.offHeapEntriesCount());
+        assertEquals(0, cache.localSize(CachePeekMode.OFFHEAP));
 
         assert offheapedCnt.get() == 0;
         assert onheapedCnt.get() == 0;
@@ -201,7 +202,7 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
 
             cache.put(i, i);
 
-            Long val = cache.peek(i);
+            Long val = cache.localPeek(i);
 
             assert val != null;
             assert val == i;
@@ -219,25 +220,25 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
         assertEquals(0, unswapedCnt.get());
 
         assertEquals(ENTRY_CNT, cache.size());
-        assertEquals(0, cache.offHeapEntriesCount());
+        assertEquals(0, cache.localSize(CachePeekMode.OFFHEAP));
 
         for (long i = 0; i < ENTRY_CNT; i++) {
-            cache.evict(i);
+            cache.localEvict(Collections.singleton(i));
 
             assertEquals(ENTRY_CNT - i - 1, cache.size());
         }
 
         // Ensure that part of entries located in off-heap memory and part is 
swapped.
         assertEquals(0, cache.size());
-        assertTrue(cache.offHeapEntriesCount() > 0);
-        assertTrue(cache.offHeapEntriesCount() < ENTRY_CNT);
+        assertTrue(cache.localSize(CachePeekMode.OFFHEAP) > 0);
+        assertTrue(cache.localSize(CachePeekMode.OFFHEAP) < ENTRY_CNT);
 
         // Setting test window to catch near half of both offheaped and 
swapped entries.
-        from = cache.offHeapEntriesCount() / 2;
-        to = (ENTRY_CNT + cache.offHeapEntriesCount()) / 2;
+        from = cache.localSize(CachePeekMode.OFFHEAP) / 2;
+        to = (ENTRY_CNT + cache.localSize(CachePeekMode.OFFHEAP)) / 2;
 
         for (long i = 0; i < ENTRY_CNT; i++)
-            assertNull(cache.peek(i));
+            assertNull(cache.localPeek(i));
 
         assertEquals(ENTRY_CNT, offheapedCnt.get());
         assertEquals(0, onheapedCnt.get());
@@ -256,9 +257,9 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @param cache Cache.
      * @throws Exception In case of error.
      */
-    private void checkEntries(GridCache<Long, Long> cache) throws Exception {
+    private void checkEntries(IgniteCache<Long, Long> cache) throws Exception {
         for (long i = from; i < to; i++) {
-            cache.promote(i);
+            cache.localPromote(Collections.singleton(i));
 
             GridCacheEntryEx entry = dht(cache).entryEx(i);
 
@@ -338,15 +339,12 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testIterators() throws Exception {
-        GridCache<Long, Long> cache = populate();
+        IgniteCache<Long, Long> cache = populate();
 
         int cnt = 0;
 
-        Iterator<Map.Entry<Long, Long>> ohIt = cache.offHeapIterator();
-
-        while (ohIt.hasNext()) {
-            Map.Entry<Long, Long> e = ohIt.next();
 
+        for (Cache.Entry<Long, Long> e : 
cache.localEntries(CachePeekMode.OFFHEAP)) {
             assertEquals(e.getKey(), e.getValue());
 
             cnt++;
@@ -356,11 +354,7 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
 
         assertTrue(cnt > 0);
 
-        Iterator<Map.Entry<Long, Long>> sIt = cache.swapIterator();
-
-        while (sIt.hasNext()) {
-            Map.Entry<Long, Long> e = sIt.next();
-
+        for (Cache.Entry<Long, Long> e : 
cache.localEntries(CachePeekMode.SWAP)) {
             assertEquals(e.getKey(), e.getValue());
 
             cnt++;
@@ -376,16 +370,16 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testSql() throws Exception {
-        GridCache<Long, Long> cache = populate();
+        IgniteCache<Long, Long> cache = populate();
 
-        Collection<Map.Entry<Long, Long>> res = cache.queries().
-            createSqlQuery(Long.class, "_val >= ? and _val < ?").
-            execute(from, to).
-            get();
+        Collection<Cache.Entry<Long, Long>> res = cache.query(
+            new SqlQuery<Long, Long>(Long.class, "_val >= ? and _val < ?").
+            setArgs(from, to)).
+            getAll();
 
         assertEquals(to - from, res.size());
 
-        for (Map.Entry<Long, Long> entry : res) {
+        for (Cache.Entry<Long, Long> entry : res) {
             assertNotNull(entry);
             assertNotNull(entry.getKey());
             assertNotNull(entry.getValue());
@@ -402,15 +396,17 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
     }
 
     /**
-     * Tests {@link CacheProjection#promote(Object)} behavior on offheaped 
entries.
+     * Tests {@link IgniteCache#localPromote(java.util.Set)} behavior on 
offheaped entries.
      *
      * @throws Exception If failed.
      */
     public void testUnswap() throws Exception {
-        GridCache<Long, Long> cache = populate();
+        IgniteCache<Long, Long> cache = populate();
 
         for (long i = from; i < to; i++) {
-            Long val = cache.promote(i);
+            cache.localPromote(Collections.singleton(i));
+
+            Long val = cache.localPeek(i);
 
             assertNotNull(val);
             assertEquals(i, val.longValue());
@@ -433,14 +429,14 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testUnswapAll() throws Exception {
-        GridCache<Long, Long> cache = populate();
+        IgniteCache<Long, Long> cache = populate();
 
-        Collection<Long> keys = new HashSet<>();
+        Set<Long> keys = new HashSet<>();
 
         for (long i = from; i < to; i++)
             keys.add(i);
 
-        cache.promoteAll(keys);
+        cache.localPromote(keys);
 
         assertEquals(0, swappedCnt.get());
         assertEquals(to - from, unswapedCnt.get() + onheapedCnt.get());
@@ -456,7 +452,7 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testGet() throws Exception {
-        GridCache<Long, Long> cache = populate();
+        IgniteCache<Long, Long> cache = populate();
 
         for (long i = from; i < to; i++) {
             Long val = cache.get(i);
@@ -480,12 +476,12 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testPeek() throws Exception {
-        GridCache<Long, Long> cache = populate();
+        IgniteCache<Long, Long> cache = populate();
 
         for (long i = from; i < to; i++) {
-            assertNull(cache.peek(i));
+            assertNull(cache.localPeek(i));
 
-            Long val = cache.peek(i, F.asList(SWAP));
+            Long val = cache.localPeek(i, CachePeekMode.SWAP);
 
             assertNotNull(val);
             assertEquals(i, val.longValue());
@@ -505,51 +501,34 @@ public class GridCacheOffHeapAndSwapSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testIteratorsCleanup() throws Exception {
-        final GridCache<Long, Long> cache = populate();
+        final IgniteCache<Long, Long> cache = populate();
 
         IgniteInternalFuture<?> offHeapFut = multithreadedAsync(new Runnable() 
{
             @Override public void run() {
-                try {
-                    Iterator<Map.Entry<Long, Long>> ohIt = 
cache.offHeapIterator();
+                int cnt = 0;
 
-                    int cnt = 0;
+                for (Cache.Entry<Long, Long> e : 
cache.localEntries(CachePeekMode.OFFHEAP)) {
+                    assertEquals(e.getKey(), e.getValue());
 
-                    while (ohIt.hasNext()) {
-                        Map.Entry<Long, Long> e = ohIt.next();
-
-                        assertEquals(e.getKey(), e.getValue());
+                    cnt++;
+                }
 
-                        cnt++;
-                    }
+                assertEquals(cache.localSize(CachePeekMode.OFFHEAP), cnt);
 
-                    assertEquals(cache.offHeapEntriesCount(), cnt);
-                }
-                catch (IgniteCheckedException ignored) {
-                    fail();
-                }
             }
         }, 20);
 
         IgniteInternalFuture<?> swapFut = multithreadedAsync(new Runnable() {
             @Override public void run() {
-                try {
-                    Iterator<Map.Entry<Long, Long>> ohIt = 
cache.swapIterator();
-
-                    int cnt = 0;
-
-                    while (ohIt.hasNext()) {
-                        Map.Entry<Long, Long> e = ohIt.next();
+                int cnt = 0;
 
-                        assertEquals(e.getKey(), e.getValue());
+                for (Cache.Entry<Long, Long> e : 
cache.localEntries(CachePeekMode.SWAP)) {
+                    assertEquals(e.getKey(), e.getValue());
 
-                        cnt++;
-                    }
-
-                    assertEquals(ENTRY_CNT - cache.offHeapEntriesCount(), cnt);
-                }
-                catch (IgniteCheckedException ignored) {
-                    fail();
+                    cnt++;
                 }
+
+                assertEquals(ENTRY_CNT - 
cache.localSize(CachePeekMode.OFFHEAP), cnt);
             }
         }, 20);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/848e1de7/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSelfTest.java
index 053cd6e..d0a20fa 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSelfTest.java
@@ -238,30 +238,6 @@ public class GridCacheSwapSelfTest extends 
GridCommonAbstractTest {
     }
 
     /**
-     * @param cache Cache.
-     * @param timeout Timeout.
-     * @return {@code True} if success.
-     * @throws InterruptedException If thread was interrupted.
-     */
-    @SuppressWarnings({"BusyWait"})
-    private boolean waitCacheEmpty(CacheProjection<Integer,Object> cache, long 
timeout)
-        throws InterruptedException {
-        assert cache != null;
-        assert timeout >= 0;
-
-        long end = System.currentTimeMillis() + timeout;
-
-        while (end - System.currentTimeMillis() >= 0) {
-            if (cache.isEmpty())
-                return true;
-
-            Thread.sleep(500);
-        }
-
-        return cache.isEmpty();
-    }
-
-    /**
      * @throws Exception If failed.
      */
     // TODO: enable when GG-7341 is fixed.

Reply via email to