ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [01/50] [abbrv] incubator-ignite git commit: ignite-645 Remove GridCachePeekMode
Date Fri, 03 Apr 2015 22:45:53 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-674 7e86251e8 -> 0e3e6d096


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
index 1ab738f..a0d9f03 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
@@ -158,13 +158,13 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         assertTrue(cache1.containsKey(1));
         assertTrue(cache1.containsKey(2));
 
-        assertNotNull(near(cache1).peek(1));
-        assertNotNull(near(cache1).peek(2));
-        assertNotNull(dht(cache1).peek(1));
-        assertNull(dht(cache1).peek(2));
+        assertNotNull(nearPeek(cache1, 1));
+        assertNotNull(nearPeek(cache1, 2));
+        assertNotNull(dhtPeek(cache1, 1));
+        assertNull(dhtPeek(cache1, 2));
 
-        assertNull(near(cache2).peek(1));
-        assertNotNull(dht(cache2).peek(2));
+        assertNull(nearPeek(cache2, 1));
+        assertNotNull(dhtPeek(cache2, 2));
 
         // Node2 should have node1 in reader's map, since request to
         // put key 2 came from node1.
@@ -177,7 +177,7 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         assertEquals("v1", cache2.get(1));
 
         // Check that key1 is in near cache of cache2.
-        assertNotNull(near(cache2).peek(1));
+        assertNotNull(nearPeek(cache2, 1));
 
         // Now node1 should have node2 in readers map.
         assertTrue(e1.readers().contains(n2.id()));
@@ -185,8 +185,8 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         // Evict locally from cache2.
         cache2.localEvict(Collections.singleton(1));
 
-        assertNull(near(cache2).peek(1));
-        assertNull(dht(cache2).peek(1));
+        assertNull(nearPeek(cache2, 1));
+        assertNull(dhtPeek(cache2, 1));
 
         // Node 1 still has node2 in readers map.
         assertTrue(e1.readers().contains(n2.id()));
@@ -240,10 +240,10 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         assertTrue(cache1.containsKey(1));
         assertTrue(cache2.containsKey(1));
 
-        assertEquals("v1", near(cache1).peek(1));
-        assertEquals("v1", near(cache2).peek(1));
-        assertEquals("v1", dht(cache1).peek(1));
-        assertEquals("v1", dht(cache2).peek(1));
+        assertEquals("v1", nearPeek(cache1, 1));
+        assertEquals("v1", nearPeek(cache2, 1));
+        assertEquals("v1", dhtPeek(cache1, 1));
+        assertEquals("v1", dhtPeek(cache2, 1));
 
         assertNull(near(cache1).peekNearOnly(1));
         assertNull(near(cache2).peekNearOnly(1));
@@ -256,10 +256,10 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         assertTrue(cache1.containsKey(2));
         assertTrue(cache2.containsKey(2));
 
-        assertEquals("v2", near(cache1).peek(2));
-        assertEquals("v2", near(cache2).peek(2));
-        assertEquals("v2", dht(cache1).peek(2));
-        assertEquals("v2", dht(cache2).peek(2));
+        assertEquals("v2", nearPeek(cache1, 2));
+        assertEquals("v2", nearPeek(cache2, 2));
+        assertEquals("v2", dhtPeek(cache1, 2));
+        assertEquals("v2", dhtPeek(cache2, 2));
 
         assertNull(near(cache1).peekNearOnly(2));
         assertNull(near(cache2).peekNearOnly(2));
@@ -284,7 +284,7 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         cache2.localEvict(Collections.singleton(1));
 
         assertNull(near(cache2).peekNearOnly(1));
-        assertEquals("v1", dht(cache2).peek(1));
+        assertEquals("v1", dhtPeek(cache2, 1));
 
         assertEquals("v1", cache1.getAndPut(1, "z1"));
 
@@ -292,7 +292,7 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
         assertFalse(e1.readers().contains(n2.id()));
 
         assertNull(near(cache2).peekNearOnly(1));
-        assertEquals("z1", dht(cache2).peek(1));
+        assertEquals("z1", dhtPeek(cache2, 1));
     }
 
     /** @throws Exception If failed. */
@@ -443,9 +443,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
         assertNull(cache.getAndPut(key1, val1));
 
-        assertEquals(val1, dht(0).peek(key1));
-        assertEquals(val1, dht(1).peek(key1));
-        assertNull(dht(2).peek(key1));
+        assertEquals(val1, dhtPeek(0, key1));
+        assertEquals(val1, dhtPeek(1, key1));
+        assertNull(dhtPeek(2, key1));
 
         assertNull(near(0).peekNearOnly(key1));
         assertNull(near(1).peekNearOnly(key1));
@@ -453,9 +453,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
         cache.put(key2, val2);
 
-        assertNull(dht(0).peek(key2));
-        assertEquals(val2, dht(1).peek(key2));
-        assertEquals(val2, dht(2).peek(key2));
+        assertNull(dhtPeek(0, key2));
+        assertEquals(val2, dhtPeek(1, key2));
+        assertEquals(val2, dhtPeek(2, key2));
 
         assertEquals(val2, near(0).peekNearOnly(key2));
         assertNull(near(1).peekNearOnly(key2));
@@ -465,9 +465,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
         cache.put(key2, val22);
 
-        assertNull(dht(0).peek(key2));
-        assertEquals(val22, dht(1).peek(key2));
-        assertEquals(val22, dht(2).peek(key2));
+        assertNull(dhtPeek(0, key2));
+        assertEquals(val22, dhtPeek(1, key2));
+        assertEquals(val22, dhtPeek(2, key2));
 
         assertEquals(val22, near(0).peekNearOnly(key2));
         assertNull(near(1).peekNearOnly(key2));
@@ -475,9 +475,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
         cache.remove(key2);
 
-        assertNull(dht(0).peek(key2));
-        assertNull(dht(1).peek(key2));
-        assertNull(dht(2).peek(key2));
+        assertNull(dhtPeek(0, key2));
+        assertNull(dhtPeek(1, key2));
+        assertNull(dhtPeek(2, key2));
 
         assertNull(near(0).peekNearOnly(key2));
         assertNull(near(1).peekNearOnly(key2));
@@ -485,9 +485,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
         cache.remove(key1);
 
-        assertNull(dht(0).peek(key1));
-        assertNull(dht(1).peek(key1));
-        assertNull(dht(2).peek(key1));
+        assertNull(dhtPeek(0, key1));
+        assertNull(dhtPeek(1, key1));
+        assertNull(dhtPeek(2, key1));
 
         assertNull(near(0).peekNearOnly(key1));
         assertNull(near(1).peekNearOnly(key1));
@@ -536,9 +536,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
             try {
                 assertNull(cache.getAndPut(key1, val1));
 
-                assertEquals(val1, dht(0).peek(key1));
-                assertEquals(val1, dht(1).peek(key1));
-                assertNull(dht(2).peek(key1));
+                assertEquals(val1, dhtPeek(0, key1));
+                assertEquals(val1, dhtPeek(1, key1));
+                assertNull(dhtPeek(2, key1));
 
                 // Since near entry holds the lock, it should
                 // contain correct value.
@@ -549,9 +549,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
                 cache.put(key2, val2);
 
-                assertNull(dht(0).peek(key2));
-                assertEquals(val2, dht(1).peek(key2));
-                assertEquals(val2, dht(2).peek(key2));
+                assertNull(dhtPeek(0, key2));
+                assertEquals(val2, dhtPeek(1, key2));
+                assertEquals(val2, dhtPeek(2, key2));
 
                 assertEquals(val2, near(0).peekNearOnly(key2));
                 assertNull(near(1).peekNearOnly(key2));
@@ -561,9 +561,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
                 cache.put(key2, val22);
 
-                assertNull(dht(0).peek(key2));
-                assertEquals(val22, dht(1).peek(key2));
-                assertEquals(val22, dht(2).peek(key2));
+                assertNull(dhtPeek(0, key2));
+                assertEquals(val22, dhtPeek(1, key2));
+                assertEquals(val22, dhtPeek(2, key2));
 
                 assertEquals(val22, near(0).peekNearOnly(key2));
                 assertNull(near(1).peekNearOnly(key2));
@@ -571,9 +571,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest
{
 
                 cache.remove(key2);
 
-                assertNull(dht(0).peek(key2));
-                assertNull(dht(1).peek(key2));
-                assertNull(dht(2).peek(key2));
+                assertNull(dhtPeek(0, key2));
+                assertNull(dhtPeek(1, key2));
+                assertNull(dhtPeek(2, key2));
 
                 assertNull(dht(0).peekEx(key2));
                 assertNotNull(dht(1).peekEx(key2));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 51c2047..9ebbebc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -148,7 +148,6 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If test failed.
      */
-    @SuppressWarnings({"BusyWait"})
     public void testIntegrity() throws Exception {
         preloadMode = SYNC;
 
@@ -188,12 +187,14 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest
{
             assertEquals(EVT_CACHE_REBALANCE_STARTED, iter.next().type());
             assertEquals(EVT_CACHE_REBALANCE_STOPPED, iter.next().type());
 
-            GridCacheAdapter<Integer, String> cache2 = ((IgniteKernal)g2).internalCache(null);
+            IgniteCache<Integer, String> cache2 = g2.cache(null);
+
+            assertEquals("val1", cache2.localPeek(1, CachePeekMode.ONHEAP));
+            assertEquals("val2", cache2.localPeek(2, CachePeekMode.ONHEAP));
 
-            assertEquals("val1", cache2.peek(1));
-            assertEquals("val2", cache2.peek(2));
+            GridCacheAdapter<Integer, String> cacheAdapter2 = ((IgniteKernal)g2).internalCache(null);
 
-            GridCacheEntryEx e2 = cache2.peekEx(1);
+            GridCacheEntryEx e2 = cacheAdapter2.peekEx(1);
 
             assert e2 != null;
             assert e2 != e1;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index b110bfa..96229c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -209,7 +209,8 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
             IgfsFileImpl info = (IgfsFileImpl)igfs.info(path);
 
             for (int i = 0; i < nodesCount(); i++) {
-                IgfsFileInfo fileInfo = (IgfsFileInfo)grid(i).cachex(metaCacheName).peek(info.fileId());
+                IgfsFileInfo fileInfo =
+                    (IgfsFileInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(),
ONHEAP_PEEK_MODES, null);
 
                 assertNotNull(fileInfo);
                 assertNotNull(fileInfo.listing());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index 3a49e6c..2b6c62a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@ -404,7 +404,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
             // Await for actual delete to occur.
             for (IgfsBlock block : file.blocks()) {
                 for (int i = 0; i < GRID_CNT; i++) {
-                    while (cache(grid(i).localNode().id()).peek(block.key()) != null)
+                    while (localPeek(cache(grid(i).localNode().id()), block.key()) != null)
                         U.sleep(100);
                 }
             }
@@ -651,39 +651,6 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
-     * Create block key.
-     *
-     * @param path Path.
-     * @param blockId Block ID.
-     * @return Block key.
-     * @throws Exception If failed.
-     */
-    private IgfsBlockKey blockKey(IgfsPath path, long blockId) throws Exception {
-        IgfsEx igfs0 = (IgfsEx)grid(0).fileSystem(IGFS_NAME);
-
-        IgniteUuid fileId = igfs0.context().meta().fileId(path);
-
-        return new IgfsBlockKey(fileId, null, true, blockId);
-    }
-
-    /**
-     * Determine primary node for the given block key.
-     *
-     * @param key Block key.
-     * @return Node ID.
-     */
-    private UUID primary(IgfsBlockKey key) {
-        IgniteEx grid = grid(0);
-
-        for (ClusterNode node : grid.cluster().nodes()) {
-            if (grid.affinity(DATA_CACHE_NAME).isPrimary(node, key))
-                return node.id();
-        }
-
-        return null;
-    }
-
-    /**
      * Determine primary and backup node IDs for the given block key.
      *
      * @param key Block key.
@@ -714,17 +681,6 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
     }
 
     /**
-     * Get IGFS of the given node.
-     *
-     * @param ignite Node;
-     * @return IGFS.
-     * @throws Exception If failed.
-     */
-    private IgfsImpl igfs(Ignite ignite) throws Exception {
-        return (IgfsImpl) ignite.fileSystem(IGFS_NAME);
-    }
-
-    /**
      * Get data cache for the given node ID.
      *
      * @param nodeId Node ID.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 9dd40d0..b890692 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -52,6 +52,9 @@ import static org.apache.ignite.internal.processors.cache.GridCacheUtils.*;
  * Super class for all common tests.
  */
 public abstract class GridCommonAbstractTest extends GridAbstractTest {
+    /**Cache peek modes array that consist of only ONHEAP mode. */
+    protected static final CachePeekMode[] ONHEAP_PEEK_MODES = new CachePeekMode[] {CachePeekMode.ONHEAP};
+
     /**
      * @param startGrid If {@code true}, then grid node will be auto-started.
      */
@@ -552,6 +555,45 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest
{
     }
 
     /**
+     * @param key Key.
+     */
+    protected <K, V> V dhtPeek(K key) throws IgniteCheckedException {
+        return localPeek(this.<K, V>dht(), key);
+    }
+
+    /**
+     * @param idx Index.
+     * @param key Key.
+     */
+    protected <K, V> V dhtPeek(int idx, K key) throws IgniteCheckedException {
+        return localPeek(this.<K, V>dht(idx), key);
+    }
+
+    /**
+     * @param cache Cache.
+     * @param key Key.
+     */
+    protected <K, V> V nearPeek(IgniteCache<K, V> cache, K key) throws IgniteCheckedException
{
+        return localPeek(near(cache), key);
+    }
+
+    /**
+     * @param cache Cache.
+     * @param key Key.
+     */
+    protected static <K, V> V dhtPeek(IgniteCache<K, V> cache, K key) throws
IgniteCheckedException {
+        return localPeek(dht(cache), key);
+    }
+
+    /**
+     * @param cache Cache.
+     * @param key Key.
+     */
+    protected static <K, V> V localPeek(GridCacheAdapter<K, V> cache, K key)
throws IgniteCheckedException {
+        return cache.localPeek(key, ONHEAP_PEEK_MODES, null);
+    }
+
+    /**
      * @param comp Compute.
      * @param task Task.
      * @param arg Task argument.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
index c650b6b..ad41bc5 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
@@ -99,7 +99,7 @@ public class GridIndexingWithNoopSwapSelfTest extends GridCommonAbstractTest
{
             cache.put(i, new ObjectValue("test" + i, i));
 
         for (int i = 0; i < cnt; i++) {
-            assertNotNull(cache.peek(i));
+            assertNotNull(localPeek(cache, i));
 
             cache.evict(i); // Swap.
         }


Mime
View raw message