ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [07/40] incubator-ignite git commit: # ignite-57
Date Mon, 09 Feb 2015 23:21:52 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
new file mode 100644
index 0000000..653b064
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
@@ -0,0 +1,824 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.eviction.fifo.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.*;
+import org.apache.ignite.spi.swapspace.file.*;
+
+import java.util.*;
+
+import static org.apache.ignite.cache.CacheDistributionMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CachePeekMode.*;
+
+/**
+ * Tests for methods using {@link CachePeekMode}:
+ * <ul>
+ *     <li>{@link IgniteCache#localPeek(Object, CachePeekMode...)}</li>
+ *     <li>{@link IgniteCache#localSize(CachePeekMode...)}</li>
+ *     <li>{@link IgniteCache#size(CachePeekMode...)}</li>
+ *     <li>{@link IgniteCache#localEntries(CachePeekMode...)}</li>
+ * </ul>
+ */
+public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstractTest {
+    /** */
+    private static final int HEAP_ENTRIES = 10;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheDistributionMode distributionMode() {
+        return PARTITIONED_ONLY;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
+        CacheConfiguration ccfg = super.cacheConfiguration(gridName);
+
+        ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
+
+        ccfg.setOffHeapMaxMemory(512);
+
+        ccfg.setBackups(1);
+
+        if (gridName.equals(getTestGridName(0)))
+            ccfg.setDistributionMode(NEAR_PARTITIONED);
+
+        ccfg.setEvictionPolicy(new CacheFifoEvictionPolicy(HEAP_ENTRIES));
+
+        return ccfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean swapEnabled() {
+        return true;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLocalPeek() throws Exception {
+        if (cacheMode() == LOCAL) {
+            checkAffinityLocalCache();
+
+            checkStorage(0);
+        }
+        else {
+            checkAffinityPeek(0);
+
+            checkAffinityPeek(1);
+
+            checkStorage(0);
+
+            checkStorage(1);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void checkAffinityLocalCache() throws Exception {
+        IgniteCache<Integer, String> cache0 = jcache(0);
+
+        final String val = "1";
+
+        for (int i = 0; i < HEAP_ENTRIES; i++)
+            cache0.put(i, val);
+
+        try {
+            for (int i = 0; i < HEAP_ENTRIES; i++) {
+                assertEquals(val, cache0.localPeek(i));
+                assertEquals(val, cache0.localPeek(i, ALL));
+                assertEquals(val, cache0.localPeek(i, PRIMARY));
+                assertEquals(val, cache0.localPeek(i, BACKUP));
+                assertEquals(val, cache0.localPeek(i, NEAR));
+            }
+        }
+        finally {
+            for (int i = 0; i < HEAP_ENTRIES; i++)
+                cache0.remove(i);
+        }
+    }
+
+    /**
+     * @param nodeIdx Node index.
+     * @throws Exception If failed.
+     */
+    private void checkAffinityPeek(int nodeIdx) throws Exception {
+        IgniteCache<Integer, String> cache0 = jcache(nodeIdx);
+
+        final String val = "1";
+
+        Integer key = null;
+
+        try {
+            if (cacheMode() == REPLICATED) {
+                key = backupKey(cache0);
+
+                cache0.put(key, val);
+
+                assertEquals(val, cache0.localPeek(key, ALL));
+                assertEquals(val, cache0.localPeek(key, BACKUP));
+                assertNull(cache0.localPeek(key, NEAR));
+                assertNull(cache0.localPeek(key, PRIMARY));
+            }
+            else {
+                key = nearKey(cache0);
+
+                cache0.put(key, val);
+
+                boolean hasNearCache = nodeIdx == 0 ;
+
+                if (hasNearCache) {
+                    assertEquals(val, cache0.localPeek(key, NEAR));
+                    assertEquals(val, cache0.localPeek(key, ALL));
+                }
+                else {
+                    assertNull(cache0.localPeek(key, NEAR));
+                    assertNull(cache0.localPeek(key, ALL));
+                }
+
+                assertNull(cache0.localPeek(key, PRIMARY));
+                assertNull(cache0.localPeek(key, BACKUP));
+            }
+
+            CacheAffinity<Integer> aff = ignite(0).affinity(null);
+
+            for (int i = 0; i < gridCount(); i++) {
+                if (i == nodeIdx)
+                    continue;
+
+                IgniteCache<Integer, String> cache = jcache(i);
+
+                assertNull(cache.localPeek(key, NEAR));
+
+                if (aff.isPrimary(ignite(i).cluster().localNode(), key)) {
+                    assertEquals(val, cache.localPeek(key, PRIMARY));
+                    assertEquals(val, cache.localPeek(key, ALL));
+                    assertNull(cache.localPeek(key, BACKUP));
+                    assertNull(cache.localPeek(key, NEAR));
+                }
+                else if (aff.isBackup(ignite(i).cluster().localNode(), key)) {
+                    assertEquals(val, cache.localPeek(key, BACKUP));
+                    assertEquals(val, cache.localPeek(key, ALL));
+                    assertNull(cache.localPeek(key, PRIMARY));
+                    assertNull(cache.localPeek(key, NEAR));
+                }
+                else {
+                    assertNull(cache.localPeek(key, ALL));
+                    assertNull(cache.localPeek(key, PRIMARY));
+                    assertNull(cache.localPeek(key, BACKUP));
+                    assertNull(cache.localPeek(key, NEAR));
+                }
+            }
+        }
+        finally {
+            if (key != null)
+                cache0.remove(key);
+        }
+    }
+
+    /**
+     * @param nodeIdx Node index.
+     * @throws Exception If failed.
+     */
+    private void checkStorage(int nodeIdx) throws Exception {
+        IgniteCache<Integer, String> cache0 = jcache(nodeIdx);
+
+        List<Integer> keys = primaryKeys(cache0, 100, 10_000);
+
+        try {
+            final String val = "test_value";
+
+            for (Integer key : keys)
+                cache0.put(key, val);
+
+            FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi();
+
+            Set<Integer> swapKeys = new HashSet<>();
+
+            final String spaceName = "gg-swap-cache-dflt";
+
+            IgniteSpiCloseableIterator<Integer> it = swap.keyIterator(spaceName, null);
+
+            assertNotNull(it);
+
+            while (it.hasNext())
+                assertTrue(swapKeys.add(it.next()));
+
+            assertFalse(swapKeys.isEmpty());
+
+            assertTrue(swapKeys.size() + HEAP_ENTRIES < 100);
+
+            Set<Integer> offheapKeys = new HashSet<>();
+
+            GridCacheAdapter<Integer, String> internalCache =
+                ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache();
+
+            Iterator<Map.Entry<Integer, String>> offheapIt;
+
+            if (internalCache.context().isNear())
+                offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator();
+            else
+                offheapIt = internalCache.context().swap().lazyOffHeapIterator();
+
+            while (offheapIt.hasNext()) {
+                Map.Entry<Integer, String> e = offheapIt.next();
+
+                assertTrue(offheapKeys.add(e.getKey()));
+
+                assertFalse(swapKeys.contains(e.getKey()));
+            }
+
+            assertFalse(offheapKeys.isEmpty());
+
+            Set<Integer> heapKeys = new HashSet<>(keys);
+
+            heapKeys.removeAll(offheapKeys);
+            heapKeys.removeAll(swapKeys);
+
+            assertFalse(heapKeys.isEmpty());
+
+            log.info("Keys [swap=" + swapKeys.size() +
+                ", offheap=" + offheapKeys.size() +
+                ", heap=" + heapKeys.size() + ']');
+
+            assertEquals(100, swapKeys.size() + offheapKeys.size() + heapKeys.size());
+
+            for (Integer key : swapKeys) {
+                assertEquals(val, cache0.localPeek(key, SWAP));
+                assertEquals(val, cache0.localPeek(key, PRIMARY, SWAP));
+                assertEquals(val, cache0.localPeek(key, ONHEAP, SWAP));
+                assertEquals(val, cache0.localPeek(key, ONHEAP, OFFHEAP, SWAP));
+                assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP, SWAP));
+                assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP, OFFHEAP, SWAP));
+
+                if (cacheMode() == LOCAL) {
+                    assertEquals(val, cache0.localPeek(key, SWAP, BACKUP));
+                    assertEquals(val, cache0.localPeek(key, SWAP, NEAR));
+                }
+                else {
+                    assertNull(cache0.localPeek(key, SWAP, BACKUP));
+                    assertNull(cache0.localPeek(key, SWAP, NEAR));
+                }
+
+                assertNull(cache0.localPeek(key, ONHEAP));
+                assertNull(cache0.localPeek(key, OFFHEAP));
+            }
+
+            for (Integer key : offheapKeys) {
+                assertEquals(val, cache0.localPeek(key, OFFHEAP));
+                assertEquals(val, cache0.localPeek(key, ONHEAP, OFFHEAP));
+                assertEquals(val, cache0.localPeek(key, ONHEAP, SWAP, OFFHEAP));
+                assertEquals(val, cache0.localPeek(key, PRIMARY, OFFHEAP));
+
+                if (cacheMode() == LOCAL) {
+                    assertEquals(val, cache0.localPeek(key, OFFHEAP, BACKUP));
+                    assertEquals(val, cache0.localPeek(key, OFFHEAP, NEAR));
+                }
+                else {
+                    assertNull(cache0.localPeek(key, OFFHEAP, BACKUP));
+                    assertNull(cache0.localPeek(key, OFFHEAP, NEAR));
+                }
+
+                assertNull(cache0.localPeek(key, ONHEAP));
+                assertNull(cache0.localPeek(key, SWAP));
+            }
+
+            for (Integer key : heapKeys) {
+                assertEquals(val, cache0.localPeek(key, ONHEAP));
+                assertEquals(val, cache0.localPeek(key, SWAP, ONHEAP));
+                assertEquals(val, cache0.localPeek(key, SWAP, OFFHEAP, ONHEAP));
+                assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP));
+
+                if (cacheMode() == LOCAL) {
+                    assertEquals(val, cache0.localPeek(key, ONHEAP, BACKUP));
+                    assertEquals(val, cache0.localPeek(key, ONHEAP, NEAR));
+                }
+                else {
+                    assertNull(cache0.localPeek(key, ONHEAP, BACKUP));
+                    assertNull(cache0.localPeek(key, ONHEAP, NEAR));
+                }
+
+                assertNull(cache0.localPeek(key, SWAP));
+                assertNull(cache0.localPeek(key, OFFHEAP));
+            }
+        }
+        finally {
+            cache0.removeAll(new HashSet<>(keys));
+        }
+    }
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSize() throws Exception {
+        checkEmpty();
+
+        if (cacheMode() == LOCAL) {
+            IgniteCache<Integer, String> cache0 = jcache(0);
+
+            IgniteCache<Integer, String> cacheAsync0 = cache0.withAsync();
+
+            for (int i = 0; i < HEAP_ENTRIES; i++) {
+                cache0.put(i, String.valueOf(i));
+
+                final int size = i + 1;
+
+                assertEquals(size, cache0.localSize());
+                assertEquals(size, cache0.localSize(PRIMARY));
+                assertEquals(size, cache0.localSize(BACKUP));
+                assertEquals(size, cache0.localSize(NEAR));
+                assertEquals(size, cache0.localSize(ALL));
+
+                assertEquals(size, cache0.size());
+                assertEquals(size, cache0.size(PRIMARY));
+                assertEquals(size, cache0.size(BACKUP));
+                assertEquals(size, cache0.size(NEAR));
+                assertEquals(size, cache0.size(ALL));
+
+                cacheAsync0.size();
+
+                assertEquals(size, cacheAsync0.future().get());
+
+                cacheAsync0.size(PRIMARY);
+
+                assertEquals(size, cacheAsync0.future().get());
+            }
+
+            for (int i = 0; i < HEAP_ENTRIES; i++) {
+                cache0.remove(i, String.valueOf(i));
+
+                final int size = HEAP_ENTRIES - i - 1;
+
+                assertEquals(size, cache0.localSize());
+                assertEquals(size, cache0.localSize(PRIMARY));
+                assertEquals(size, cache0.localSize(BACKUP));
+                assertEquals(size, cache0.localSize(NEAR));
+                assertEquals(size, cache0.localSize(ALL));
+
+                assertEquals(size, cache0.size());
+                assertEquals(size, cache0.size(PRIMARY));
+                assertEquals(size, cache0.size(BACKUP));
+                assertEquals(size, cache0.size(NEAR));
+                assertEquals(size, cache0.size(ALL));
+
+                cacheAsync0.size();
+
+                assertEquals(size, cacheAsync0.future().get());
+            }
+
+            checkEmpty();
+
+            Set<Integer> keys = new HashSet<>();
+
+            for (int i = 0; i < 200; i++) {
+                cache0.put(i, "test_val");
+
+                keys.add(i);
+            }
+
+            try {
+                int totalKeys = 200;
+
+                T2<Integer, Integer> swapKeys = swapKeys(0);
+
+                T2<Integer, Integer> offheapKeys = offheapKeys(0);
+
+                int totalSwap = swapKeys.get1() + swapKeys.get2();
+                int totalOffheap = offheapKeys.get1() + offheapKeys.get2();
+
+                log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']');
+
+                assertTrue(totalSwap + totalOffheap < totalKeys);
+
+                assertEquals(totalKeys, cache0.localSize());
+                assertEquals(totalKeys, cache0.localSize(ALL));
+
+                assertEquals(totalOffheap, cache0.localSize(OFFHEAP));
+                assertEquals(totalSwap, cache0.localSize(SWAP));
+                assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP));
+
+                assertEquals(totalOffheap, cache0.size(OFFHEAP));
+                assertEquals(totalSwap, cache0.size(SWAP));
+                assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.size(ONHEAP));
+
+                assertEquals(totalOffheap, cache0.localSize(OFFHEAP, PRIMARY));
+                assertEquals(totalSwap, cache0.localSize(SWAP, PRIMARY));
+                assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, PRIMARY));
+
+                assertEquals(totalOffheap, cache0.localSize(OFFHEAP, BACKUP));
+                assertEquals(totalSwap, cache0.localSize(SWAP, BACKUP));
+                assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, BACKUP));
+            }
+            finally {
+                cache0.removeAll(keys);
+            }
+        }
+        else {
+            //checkSizeAffinityFilter(0);
+
+            //checkSizeAffinityFilter(1);
+
+            checkSizeStorageFilter(0);
+
+            checkSizeStorageFilter(1);
+        }
+    }
+
+    /**
+     * @param nodeIdx Node index.
+     * @throws Exception If failed.
+     */
+    private void checkSizeAffinityFilter(int nodeIdx) throws Exception {
+        IgniteCache<Integer, String> cache0 = jcache(nodeIdx);
+
+        final int PUT_KEYS = 10;
+
+        List<Integer> keys = null;
+
+        try {
+            if (cacheMode() == REPLICATED) {
+                keys = backupKeys(cache0, 10, 0);
+
+                for (Integer key : keys)
+                    cache0.put(key, String.valueOf(key));
+
+                assertEquals(PUT_KEYS, cache0.localSize());
+                assertEquals(PUT_KEYS, cache0.localSize(BACKUP));
+                assertEquals(PUT_KEYS, cache0.localSize(ALL));
+                assertEquals(0, cache0.localSize(PRIMARY));
+                assertEquals(0, cache0.localSize(NEAR));
+
+                for (int i = 0; i < gridCount(); i++) {
+                    IgniteCache<Integer, String> cache = jcache(i);
+
+                    assertEquals(0, cache.size(NEAR));
+                    assertEquals(PUT_KEYS, cache.size(PRIMARY));
+                    assertEquals(PUT_KEYS * (gridCount() - 1), cache.size(BACKUP));
+                    assertEquals(PUT_KEYS * gridCount(), cache.size(PRIMARY, BACKUP));
+                    assertEquals(PUT_KEYS * gridCount(), cache.size()); // Primary + backups.
+                }
+            }
+            else {
+                keys = nearKeys(cache0, PUT_KEYS, 0);
+
+                for (Integer key : keys)
+                    cache0.put(key, String.valueOf(key));
+
+                boolean hasNearCache = nodeIdx == 0 ;
+
+                if (hasNearCache) {
+                    assertEquals(PUT_KEYS, cache0.localSize());
+                    assertEquals(PUT_KEYS, cache0.localSize(ALL));
+                    assertEquals(PUT_KEYS, cache0.localSize(NEAR));
+
+                    for (int i = 0; i < gridCount(); i++) {
+                        IgniteCache<Integer, String> cache = jcache(i);
+
+                        assertEquals(PUT_KEYS, cache.size(NEAR));
+                        assertEquals(PUT_KEYS, cache.size(BACKUP));
+                        assertEquals(PUT_KEYS * 2, cache.size(PRIMARY, BACKUP));
+                        assertEquals(PUT_KEYS * 2 + PUT_KEYS, cache.size()); // Primary + backups + near.
+                    }
+                }
+                else {
+                    assertEquals(0, cache0.localSize());
+                    assertEquals(0, cache0.localSize(ALL));
+                    assertEquals(0, cache0.localSize(NEAR));
+
+                    for (int i = 0; i < gridCount(); i++) {
+                        IgniteCache<Integer, String> cache = jcache(i);
+
+                        assertEquals(0, cache.size(NEAR));
+                        assertEquals(PUT_KEYS, cache.size(BACKUP));
+                        assertEquals(PUT_KEYS * 2, cache.size(PRIMARY, BACKUP));
+                        assertEquals(PUT_KEYS * 2, cache.size()); // Primary + backups.
+                    }
+                }
+
+                assertEquals(0, cache0.localSize(BACKUP));
+                assertEquals(0, cache0.localSize(PRIMARY));
+            }
+
+            checkPrimarySize(PUT_KEYS);
+
+            CacheAffinity<Integer> aff = ignite(0).affinity(null);
+
+            for (int i = 0; i < gridCount(); i++) {
+                if (i == nodeIdx)
+                    continue;
+
+                ClusterNode node = ignite(i).cluster().localNode();
+
+                int primary = 0;
+                int backups = 0;
+
+                for (Integer key : keys) {
+                    if (aff.isPrimary(node, key))
+                        primary++;
+                    else if (aff.isBackup(node, key))
+                        backups++;
+                }
+
+                IgniteCache<Integer, String> cache = jcache(i);
+
+                assertEquals(primary, cache.localSize(PRIMARY));
+                assertEquals(backups, cache.localSize(BACKUP));
+                assertEquals(primary + backups, cache.localSize(PRIMARY, BACKUP));
+                assertEquals(primary + backups, cache.localSize(BACKUP, PRIMARY));
+                assertEquals(primary + backups, cache.localSize(ALL));
+            }
+
+            cache0.remove(keys.get(0));
+
+            checkPrimarySize(PUT_KEYS - 1);
+
+            if (cacheMode() == REPLICATED) {
+                assertEquals(PUT_KEYS - 1, cache0.localSize());
+                assertEquals(0, cache0.localSize(PRIMARY));
+                assertEquals(PUT_KEYS - 1, cache0.localSize(BACKUP));
+            }
+            else {
+                boolean hasNearCache = nodeIdx == 0;
+
+                if (hasNearCache)
+                    assertEquals(PUT_KEYS - 1, cache0.localSize());
+                else
+                    assertEquals(0, cache0.localSize());
+            }
+        }
+        finally {
+            if (keys != null)
+                cache0.removeAll(new HashSet<>(keys));
+        }
+
+        checkEmpty();
+    }
+
+    /**
+     * Checks size is zero.
+     */
+    private void checkEmpty() {
+        for (int i = 0; i < gridCount(); i++) {
+            IgniteCache<Integer, String> cache = jcache(i);
+
+            assertEquals(0, cache.localSize());
+
+            assertEquals(0, cache.size());
+
+            for (CachePeekMode peekMode : CachePeekMode.values()) {
+                assertEquals(0, cache.localSize(peekMode));
+
+                assertEquals(0, cache.size(peekMode));
+            }
+        }
+
+        checkPrimarySize(0);
+    }
+
+    /**
+     * @param nodeIdx Node index.
+     * @return Tuple with number of primary and backup keys.
+     */
+    private T2<Integer, Integer> swapKeys(int nodeIdx) {
+        FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi();
+
+        final String spaceName = "gg-swap-cache-dflt";
+
+        IgniteSpiCloseableIterator<Integer> it = swap.keyIterator(spaceName, null);
+
+        assertNotNull(it);
+
+        CacheAffinity aff = ignite(nodeIdx).affinity(null);
+
+        ClusterNode node = ignite(nodeIdx).cluster().localNode();
+
+        int primary = 0;
+        int backups = 0;
+
+        while (it.hasNext()) {
+            Integer key = it.next();
+
+            if (aff.isPrimary(node, key))
+                primary++;
+            else {
+                assertTrue(aff.isBackup(node, key));
+
+                backups++;
+            }
+        }
+
+        return new T2<>(primary, backups);
+    }
+
+    /**
+     * @param nodeIdx Node index.
+     * @return Tuple with number of primary and backup keys.
+     */
+    private T2<Integer, Integer> offheapKeys(int nodeIdx) {
+        GridCacheAdapter<Integer, String> internalCache =
+            ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache();
+
+        Iterator<Map.Entry<Integer, String>> offheapIt;
+
+        if (internalCache.context().isNear())
+            offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator();
+        else
+            offheapIt = internalCache.context().swap().lazyOffHeapIterator();
+
+        CacheAffinity aff = ignite(nodeIdx).affinity(null);
+
+        ClusterNode node = ignite(nodeIdx).cluster().localNode();
+
+        int primary = 0;
+        int backups = 0;
+
+        while (offheapIt.hasNext()) {
+            Map.Entry<Integer, String> e = offheapIt.next();
+
+            if (aff.isPrimary(node, e.getKey()))
+                primary++;
+            else {
+                assertTrue(aff.isBackup(node, e.getKey()));
+
+                backups++;
+            }
+        }
+
+        return new T2<>(primary, backups);
+    }
+
+    /**
+     * @param nodeIdx Node index.
+     * @throws Exception If failed.
+     */
+    private void checkSizeStorageFilter(int nodeIdx) throws Exception {
+        IgniteCache<Integer, String> cache0 = jcache(nodeIdx);
+
+        List<Integer> primaryKeys = primaryKeys(cache0, 100, 10_000);
+        List<Integer> backupKeys = backupKeys(cache0, 100, 10_000);
+
+        try {
+            final String val = "test_value";
+
+            for (int i = 0; i < 100; i++) {
+                cache0.put(primaryKeys.get(i), val);
+                cache0.put(backupKeys.get(i), val);
+            }
+
+            int totalKeys = 200;
+
+            T2<Integer, Integer> swapKeys = swapKeys(nodeIdx);
+
+            assertTrue(swapKeys.get1() > 0);
+            assertTrue(swapKeys.get2() > 0);
+
+            T2<Integer, Integer> offheapKeys = offheapKeys(nodeIdx);
+
+            assertTrue(offheapKeys.get1() > 0);
+            assertTrue(offheapKeys.get2() > 0);
+
+            int totalSwap = swapKeys.get1() + swapKeys.get2();
+            int totalOffheap = offheapKeys.get1() + offheapKeys.get2();
+
+            log.info("Local keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']');
+
+            assertTrue(totalSwap + totalOffheap < totalKeys);
+
+            assertEquals(totalKeys, cache0.localSize());
+            assertEquals(totalKeys, cache0.localSize(ALL));
+            assertEquals(totalOffheap, cache0.localSize(OFFHEAP));
+            assertEquals(totalSwap, cache0.localSize(SWAP));
+            assertEquals(totalKeys - (totalOffheap + totalSwap), cache0.localSize(ONHEAP));
+            assertEquals(totalKeys, cache0.localSize(SWAP, OFFHEAP, ONHEAP));
+
+            assertEquals(swapKeys.get1(), (Integer)cache0.localSize(SWAP, PRIMARY));
+            assertEquals(swapKeys.get2(), (Integer)cache0.localSize(SWAP, BACKUP));
+
+            assertEquals(offheapKeys.get1(), (Integer)cache0.localSize(OFFHEAP, PRIMARY));
+            assertEquals(offheapKeys.get2(), (Integer)cache0.localSize(OFFHEAP, BACKUP));
+
+            assertEquals(swapKeys.get1() + offheapKeys.get1(), cache0.localSize(SWAP, OFFHEAP, PRIMARY));
+            assertEquals(swapKeys.get2() + offheapKeys.get2(), cache0.localSize(SWAP, OFFHEAP, BACKUP));
+
+            assertEquals(totalSwap + totalOffheap, cache0.localSize(SWAP, OFFHEAP));
+
+            int globalSwapPrimary = 0;
+            int globalSwapBackup = 0;
+
+            int globalOffheapPrimary = 0;
+            int globalOffheapBackup = 0;
+
+            for (int i = 0; i < gridCount(); i++) {
+                T2<Integer, Integer> swap = swapKeys(i);
+
+                globalSwapPrimary += swap.get1();
+                globalSwapBackup += swap.get2();
+
+                T2<Integer, Integer> offheap = offheapKeys(i);
+
+                globalOffheapPrimary += offheap.get1();
+                globalOffheapBackup += offheap.get2();
+            }
+
+            int backups;
+
+            if (cacheMode() == LOCAL)
+                backups = 0;
+            else if (cacheMode() == PARTITIONED)
+                backups = 1;
+            else // REPLICATED.
+                backups = gridCount() - 1;
+
+            int globalTotal = totalKeys + totalKeys * backups;
+            int globalTotalSwap = globalSwapPrimary + globalSwapBackup;
+            int globalTotalOffheap = globalOffheapPrimary + globalOffheapBackup;
+
+            log.info("Global keys [total=" + globalTotal +
+                ", offheap=" + globalTotalOffheap +
+                ", swap=" + globalTotalSwap + ']');
+
+            for (int i = 0; i < gridCount(); i++) {
+                IgniteCache<Integer, String> cache = jcache(i);
+
+                assertEquals(globalTotal, cache.size());
+                assertEquals(globalTotal, cache.size(ALL));
+                assertEquals(globalTotal, cache.size(ONHEAP, OFFHEAP, SWAP));
+                assertEquals(globalTotal, cache.size(ONHEAP, OFFHEAP, SWAP, PRIMARY, BACKUP));
+
+                assertEquals(globalTotalSwap, cache.size(SWAP));
+                assertEquals(globalSwapPrimary, cache.size(SWAP, PRIMARY));
+                assertEquals(globalSwapBackup, cache.size(SWAP, BACKUP));
+
+                assertEquals(globalTotalOffheap, cache.size(OFFHEAP));
+                assertEquals(globalOffheapPrimary, cache.size(OFFHEAP, PRIMARY));
+                assertEquals(globalOffheapBackup, cache.size(OFFHEAP, BACKUP));
+
+                assertEquals(globalTotalSwap + globalTotalOffheap, cache.size(SWAP, OFFHEAP));
+                assertEquals(globalSwapPrimary + globalOffheapPrimary, cache.size(SWAP, OFFHEAP, PRIMARY));
+                assertEquals(globalSwapBackup + globalOffheapBackup, cache.size(SWAP, OFFHEAP, BACKUP));
+
+                assertEquals(globalTotal - (globalTotalOffheap + globalTotalSwap), cache.size(ONHEAP));
+            }
+        }
+        finally {
+            cache0.removeAll(new HashSet<>(primaryKeys));
+            cache0.removeAll(new HashSet<>(backupKeys));
+        }
+
+        checkEmpty();
+    }
+
+    /**
+     * @param exp Expected size.
+     */
+    private void checkPrimarySize(int exp) {
+        int size = 0;
+
+        for (int i = 0; i < gridCount(); i++) {
+            IgniteCache<Integer, String> cache = jcache(i);
+
+            IgniteCache<Integer, String> cacheAsync = cache.withAsync();
+
+            assertEquals(exp, cache.size(PRIMARY));
+
+            size += cache.localSize(PRIMARY);
+
+            cacheAsync.size(PRIMARY);
+
+            assertEquals(exp, cacheAsync.future().get());
+        }
+
+        assertEquals(exp, size);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java
deleted file mode 100644
index dbc2e9a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.affinity.*;
-import org.apache.ignite.cache.eviction.fifo.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.spi.*;
-import org.apache.ignite.spi.swapspace.file.*;
-
-import java.util.*;
-
-import static org.apache.ignite.cache.CacheDistributionMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.cache.CachePeekMode.*;
-
-/**
- *
- */
-public abstract class IgniteCacheSizeAbstractTest extends IgniteCacheAbstractTest {
-    /** */
-    private static final int HEAP_ENTRIES = 10;
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheDistributionMode distributionMode() {
-        return PARTITIONED_ONLY;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
-        CacheConfiguration ccfg = super.cacheConfiguration(gridName);
-
-        ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
-
-        ccfg.setOffHeapMaxMemory(512);
-
-        ccfg.setBackups(1);
-
-        if (gridName.equals(getTestGridName(0)))
-            ccfg.setDistributionMode(NEAR_PARTITIONED);
-
-        ccfg.setEvictionPolicy(new CacheFifoEvictionPolicy(HEAP_ENTRIES));
-
-        return ccfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean swapEnabled() {
-        return true;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSize() throws Exception {
-        checkEmpty();
-
-        if (cacheMode() == LOCAL) {
-            IgniteCache<Integer, String> cache0 = jcache(0);
-
-            IgniteCache<Integer, String> cacheAsync0 = cache0.withAsync();
-
-            for (int i = 0; i < HEAP_ENTRIES; i++) {
-                cache0.put(i, String.valueOf(i));
-
-                final int size = i + 1;
-
-                assertEquals(size, cache0.localSize());
-                assertEquals(size, cache0.localSize(PRIMARY));
-                assertEquals(size, cache0.localSize(BACKUP));
-                assertEquals(size, cache0.localSize(NEAR));
-                assertEquals(size, cache0.localSize(ALL));
-
-                assertEquals(size, cache0.size());
-                assertEquals(size, cache0.size(PRIMARY));
-                assertEquals(size, cache0.size(BACKUP));
-                assertEquals(size, cache0.size(NEAR));
-                assertEquals(size, cache0.size(ALL));
-
-                cacheAsync0.size();
-
-                assertEquals(size, cacheAsync0.future().get());
-
-                cacheAsync0.size(PRIMARY);
-
-                assertEquals(size, cacheAsync0.future().get());
-            }
-
-            for (int i = 0; i < HEAP_ENTRIES; i++) {
-                cache0.remove(i, String.valueOf(i));
-
-                final int size = HEAP_ENTRIES - i - 1;
-
-                assertEquals(size, cache0.localSize());
-                assertEquals(size, cache0.localSize(PRIMARY));
-                assertEquals(size, cache0.localSize(BACKUP));
-                assertEquals(size, cache0.localSize(NEAR));
-                assertEquals(size, cache0.localSize(ALL));
-
-                assertEquals(size, cache0.size());
-                assertEquals(size, cache0.size(PRIMARY));
-                assertEquals(size, cache0.size(BACKUP));
-                assertEquals(size, cache0.size(NEAR));
-                assertEquals(size, cache0.size(ALL));
-
-                cacheAsync0.size();
-
-                assertEquals(size, cacheAsync0.future().get());
-            }
-
-            checkEmpty();
-
-            for (int i = 0; i < 200; i++)
-                cache0.put(i, "test_val");
-
-            int totalKeys = 200;
-
-            T2<Integer, Integer> swapKeys = swapKeys(0);
-
-            T2<Integer, Integer> offheapKeys = offheapKeys(0);
-
-            int totalSwap = swapKeys.get1() + swapKeys.get2();
-            int totalOffheap = offheapKeys.get1() + offheapKeys.get2();
-
-            log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']');
-
-            assertTrue(totalSwap + totalOffheap < totalKeys);
-
-            assertEquals(totalKeys, cache0.localSize());
-            assertEquals(totalKeys, cache0.localSize(ALL));
-
-            assertEquals(totalOffheap, cache0.localSize(OFFHEAP));
-            assertEquals(totalSwap, cache0.localSize(SWAP));
-            assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP));
-
-            assertEquals(totalOffheap, cache0.size(OFFHEAP));
-            assertEquals(totalSwap, cache0.size(SWAP));
-            assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.size(ONHEAP));
-
-            assertEquals(totalOffheap, cache0.localSize(OFFHEAP, PRIMARY));
-            assertEquals(totalSwap, cache0.localSize(SWAP, PRIMARY));
-            assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, PRIMARY));
-
-            assertEquals(totalOffheap, cache0.localSize(OFFHEAP, BACKUP));
-            assertEquals(totalSwap, cache0.localSize(SWAP, BACKUP));
-            assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, BACKUP));
-        }
-        else {
-            checkSizeAffinityFilter(0);
-
-            checkSizeAffinityFilter(1);
-
-            checkSizeStorageFilter(0);
-
-            checkSizeStorageFilter(1);
-        }
-    }
-
-    /**
-     * @param nodeIdx Node index.
-     * @throws Exception If failed.
-     */
-    private void checkSizeAffinityFilter(int nodeIdx) throws Exception {
-        IgniteCache<Integer, String> cache0 = jcache(nodeIdx);
-
-        final int PUT_KEYS = 10;
-
-        List<Integer> keys = null;
-
-        try {
-            if (cacheMode() == REPLICATED) {
-                keys = backupKeys(cache0, 10, 0);
-
-                for (Integer key : keys)
-                    cache0.put(key, String.valueOf(key));
-
-                assertEquals(PUT_KEYS, cache0.localSize());
-                assertEquals(PUT_KEYS, cache0.localSize(BACKUP));
-                assertEquals(PUT_KEYS, cache0.localSize(ALL));
-                assertEquals(0, cache0.localSize(PRIMARY));
-                assertEquals(0, cache0.localSize(NEAR));
-
-                for (int i = 0; i < gridCount(); i++) {
-                    IgniteCache<Integer, String> cache = jcache(i);
-
-                    assertEquals(0, cache.size(NEAR));
-                    assertEquals(PUT_KEYS, cache.size(PRIMARY));
-                    assertEquals(PUT_KEYS * (gridCount() - 1), cache.size(BACKUP));
-                    assertEquals(PUT_KEYS * gridCount(), cache.size(PRIMARY, BACKUP));
-                    assertEquals(PUT_KEYS * gridCount(), cache.size()); // Primary + backups.
-                }
-            }
-            else {
-                keys = nearKeys(cache0, PUT_KEYS, 0);
-
-                for (Integer key : keys)
-                    cache0.put(key, String.valueOf(key));
-
-                boolean hasNearCache = nodeIdx == 0 ;
-
-                if (hasNearCache) {
-                    assertEquals(PUT_KEYS, cache0.localSize());
-                    assertEquals(PUT_KEYS, cache0.localSize(ALL));
-                    assertEquals(PUT_KEYS, cache0.localSize(NEAR));
-
-                    for (int i = 0; i < gridCount(); i++) {
-                        IgniteCache<Integer, String> cache = jcache(i);
-
-                        assertEquals(PUT_KEYS, cache.size(NEAR));
-                        assertEquals(PUT_KEYS, cache.size(BACKUP));
-                        assertEquals(PUT_KEYS * 2, cache.size(PRIMARY, BACKUP));
-                        assertEquals(PUT_KEYS * 2 + PUT_KEYS, cache.size()); // Primary + backups + near.
-                    }
-                }
-                else {
-                    assertEquals(0, cache0.localSize());
-                    assertEquals(0, cache0.localSize(ALL));
-                    assertEquals(0, cache0.localSize(NEAR));
-
-                    for (int i = 0; i < gridCount(); i++) {
-                        IgniteCache<Integer, String> cache = jcache(i);
-
-                        assertEquals(0, cache.size(NEAR));
-                        assertEquals(PUT_KEYS, cache.size(BACKUP));
-                        assertEquals(PUT_KEYS * 2, cache.size(PRIMARY, BACKUP));
-                        assertEquals(PUT_KEYS * 2, cache.size()); // Primary + backups.
-                    }
-                }
-
-                assertEquals(0, cache0.localSize(BACKUP));
-                assertEquals(0, cache0.localSize(PRIMARY));
-            }
-
-            checkPrimarySize(PUT_KEYS);
-
-            CacheAffinity<Integer> aff = ignite(0).affinity(null);
-
-            for (int i = 0; i < gridCount(); i++) {
-                if (i == nodeIdx)
-                    continue;
-
-                ClusterNode node = ignite(i).cluster().localNode();
-
-                int primary = 0;
-                int backups = 0;
-
-                for (Integer key : keys) {
-                    if (aff.isPrimary(node, key))
-                        primary++;
-                    else if (aff.isBackup(node, key))
-                        backups++;
-                }
-
-                IgniteCache<Integer, String> cache = jcache(i);
-
-                assertEquals(primary, cache.localSize(PRIMARY));
-                assertEquals(backups, cache.localSize(BACKUP));
-                assertEquals(primary + backups, cache.localSize(PRIMARY, BACKUP));
-                assertEquals(primary + backups, cache.localSize(BACKUP, PRIMARY));
-                assertEquals(primary + backups, cache.localSize(ALL));
-            }
-
-            cache0.remove(keys.get(0));
-
-            checkPrimarySize(PUT_KEYS - 1);
-
-            if (cacheMode() == REPLICATED) {
-                assertEquals(PUT_KEYS - 1, cache0.localSize());
-                assertEquals(0, cache0.localSize(PRIMARY));
-                assertEquals(PUT_KEYS - 1, cache0.localSize(BACKUP));
-            }
-            else {
-                boolean hasNearCache = nodeIdx == 0;
-
-                if (hasNearCache)
-                    assertEquals(PUT_KEYS - 1, cache0.localSize());
-                else
-                    assertEquals(0, cache0.localSize());
-            }
-        }
-        finally {
-            if (keys != null)
-                cache0.removeAll(new HashSet<>(keys));
-        }
-
-        checkEmpty();
-    }
-
-    /**
-     * Checks size is zero.
-     */
-    private void checkEmpty() {
-        for (int i = 0; i < gridCount(); i++) {
-            IgniteCache<Integer, String> cache = jcache(i);
-
-            assertEquals(0, cache.localSize());
-
-            assertEquals(0, cache.size());
-
-            for (CachePeekMode peekMode : CachePeekMode.values()) {
-                assertEquals(0, cache.localSize(peekMode));
-
-                assertEquals(0, cache.size(peekMode));
-            }
-        }
-
-        checkPrimarySize(0);
-    }
-
-    /**
-     * @param nodeIdx Node index.
-     * @return Tuple with number of primary and backup keys.
-     */
-    private T2<Integer, Integer> swapKeys(int nodeIdx) {
-        FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi();
-
-        final String spaceName = "gg-swap-cache-dflt";
-
-        IgniteSpiCloseableIterator<Integer> it = swap.keyIterator(spaceName, null);
-
-        assertNotNull(it);
-
-        CacheAffinity aff = ignite(nodeIdx).affinity(null);
-
-        ClusterNode node = ignite(nodeIdx).cluster().localNode();
-
-        int primary = 0;
-        int backups = 0;
-
-        while (it.hasNext()) {
-            Integer key = it.next();
-
-            if (aff.isPrimary(node, key))
-                primary++;
-            else {
-                assertTrue(aff.isBackup(node, key));
-
-                backups++;
-            }
-        }
-
-        return new T2<>(primary, backups);
-    }
-
-    /**
-     * @param nodeIdx Node index.
-     * @return Tuple with number of primary and backup keys.
-     */
-    private T2<Integer, Integer> offheapKeys(int nodeIdx) {
-        GridCacheAdapter<Integer, String> internalCache =
-            ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache();
-
-        Iterator<Map.Entry<Integer, String>> offheapIt;
-
-        if (internalCache.context().isNear())
-            offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator();
-        else
-            offheapIt = internalCache.context().swap().lazyOffHeapIterator();
-
-        CacheAffinity aff = ignite(nodeIdx).affinity(null);
-
-        ClusterNode node = ignite(nodeIdx).cluster().localNode();
-
-        int primary = 0;
-        int backups = 0;
-
-        while (offheapIt.hasNext()) {
-            Map.Entry<Integer, String> e = offheapIt.next();
-
-            if (aff.isPrimary(node, e.getKey()))
-                primary++;
-            else {
-                assertTrue(aff.isBackup(node, e.getKey()));
-
-                backups++;
-            }
-        }
-
-        return new T2<>(primary, backups);
-    }
-
-    /**
-     * @param nodeIdx Node index.
-     * @throws Exception If failed.
-     */
-    private void checkSizeStorageFilter(int nodeIdx) throws Exception {
-        IgniteCache<Integer, String> cache0 = jcache(nodeIdx);
-
-        List<Integer> primaryKeys = primaryKeys(cache0, 100, 10_000);
-        List<Integer> backupKeys = backupKeys(cache0, 100, 10_000);
-
-        try {
-            final String val = "test_value";
-
-            for (int i = 0; i < 100; i++) {
-                cache0.put(primaryKeys.get(i), val);
-                cache0.put(backupKeys.get(i), val);
-            }
-
-            int totalKeys = 200;
-
-            T2<Integer, Integer> swapKeys = swapKeys(nodeIdx);
-
-            assertTrue(swapKeys.get1() > 0);
-            assertTrue(swapKeys.get2() > 0);
-
-            T2<Integer, Integer> offheapKeys = offheapKeys(nodeIdx);
-
-            assertTrue(offheapKeys.get1() > 0);
-            assertTrue(offheapKeys.get2() > 0);
-
-            int totalSwap = swapKeys.get1() + swapKeys.get2();
-            int totalOffheap = offheapKeys.get1() + offheapKeys.get2();
-
-            log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']');
-
-            assertTrue(totalSwap + totalOffheap < totalKeys);
-
-            assertEquals(totalKeys, cache0.localSize());
-            assertEquals(totalKeys, cache0.localSize(ALL));
-            assertEquals(totalOffheap, cache0.localSize(OFFHEAP));
-            assertEquals(totalSwap, cache0.localSize(SWAP));
-            assertEquals(totalKeys - (totalOffheap + totalSwap), cache0.localSize(ONHEAP));
-            assertEquals(totalKeys, cache0.localSize(SWAP, OFFHEAP, ONHEAP));
-
-            assertEquals(swapKeys.get1(), (Integer)cache0.localSize(SWAP, PRIMARY));
-            assertEquals(swapKeys.get2(), (Integer)cache0.localSize(SWAP, BACKUP));
-
-            assertEquals(offheapKeys.get1(), (Integer)cache0.localSize(OFFHEAP, PRIMARY));
-            assertEquals(offheapKeys.get2(), (Integer)cache0.localSize(OFFHEAP, BACKUP));
-
-            assertEquals(swapKeys.get1() + offheapKeys.get1(), cache0.localSize(SWAP, OFFHEAP, PRIMARY));
-            assertEquals(swapKeys.get2() + offheapKeys.get2(), cache0.localSize(SWAP, OFFHEAP, BACKUP));
-
-            assertEquals(totalSwap + totalOffheap, cache0.localSize(SWAP, OFFHEAP));
-        }
-        finally {
-            cache0.removeAll(new HashSet<>(primaryKeys));
-            cache0.removeAll(new HashSet<>(backupKeys));
-        }
-
-        checkEmpty();
-    }
-
-    /**
-     * @param exp Expected size.
-     */
-    private void checkPrimarySize(int exp) {
-        int size = 0;
-
-        for (int i = 0; i < gridCount(); i++) {
-            IgniteCache<Integer, String> cache = jcache(i);
-
-            IgniteCache<Integer, String> cacheAsync = cache.withAsync();
-
-            assertEquals(exp, cache.size(PRIMARY));
-
-            size += cache.localSize(PRIMARY);
-
-            cacheAsync.size(PRIMARY);
-
-            assertEquals(exp, cacheAsync.future().get());
-        }
-
-        assertEquals(exp, size);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java
new file mode 100644
index 0000000..234d501
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxLocalPeekModesTest extends IgniteCachePeekModesAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return LOCAL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java
deleted file mode 100644
index f4b70cf..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteCacheTxLocalPeekTest extends IgniteCachePeekAbstractTest {
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicityMode atomicityMode() {
-        return TRANSACTIONAL;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return LOCAL;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java
deleted file mode 100644
index 5b0ddf7..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteCacheTxLocalSizeTest extends IgniteCacheSizeAbstractTest {
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicityMode atomicityMode() {
-        return TRANSACTIONAL;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 1;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return LOCAL;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
new file mode 100644
index 0000000..08a2c7d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxPeekModesTest extends IgniteCachePeekModesAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 4;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+        return PRIMARY;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java
deleted file mode 100644
index 0ddeaaf..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteCacheTxPeekTest extends IgniteCachePeekAbstractTest {
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 4;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return PARTITIONED;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicityMode atomicityMode() {
-        return TRANSACTIONAL;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
-        return PRIMARY;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java
new file mode 100644
index 0000000..616ca3a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxReplicatedPeekModesTest extends IgniteCacheTxPeekModesTest {
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return REPLICATED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java
deleted file mode 100644
index 3b0f0f6..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteCacheTxReplicatedPeekTest extends IgniteCacheTxPeekTest {
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return REPLICATED;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java
deleted file mode 100644
index a971bb8..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteCacheTxReplicatedSizeTest extends IgniteCacheTxSizeTest {
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return REPLICATED;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java
deleted file mode 100644
index 70ff8b5..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- *
- */
-public class IgniteCacheTxSizeTest extends IgniteCacheSizeAbstractTest {
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicityMode atomicityMode() {
-        return TRANSACTIONAL;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 4;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return PARTITIONED;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
-        return PRIMARY;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b9c3467/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index d992295..0bb95a5 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -367,19 +367,12 @@ public class IgniteCacheTestSuite extends TestSuite {
         suite.addTestSuite(IgniteCacheTxNearEnabledNoWriteThroughTest.class);
         suite.addTestSuite(IgniteCacheTxLocalNoWriteThroughTest.class);
 
-        suite.addTestSuite(IgniteCacheAtomicPeekTest.class);
-        suite.addTestSuite(IgniteCacheAtomicReplicatedPeekTest.class);
-        suite.addTestSuite(IgniteCacheAtomicLocalPeekTest.class);
-        suite.addTestSuite(IgniteCacheTxPeekTest.class);
-        suite.addTestSuite(IgniteCacheTxLocalPeekTest.class);
-        suite.addTestSuite(IgniteCacheTxReplicatedPeekTest.class);
-
-        suite.addTestSuite(IgniteCacheAtomicSizeTest.class);
-        suite.addTestSuite(IgniteCacheAtomicReplicatedSizeTest.class);
-        suite.addTestSuite(IgniteCacheAtomicLocalSizeTest.class);
-        suite.addTestSuite(IgniteCacheTxSizeTest.class);
-        suite.addTestSuite(IgniteCacheTxReplicatedSizeTest.class);
-        suite.addTestSuite(IgniteCacheTxLocalSizeTest.class);
+        suite.addTestSuite(IgniteCacheAtomicPeekModesTest.class);
+        suite.addTestSuite(IgniteCacheAtomicReplicatedPeekModesTest.class);
+        suite.addTestSuite(IgniteCacheAtomicLocalPeekModesTest.class);
+        suite.addTestSuite(IgniteCacheTxPeekModesTest.class);
+        suite.addTestSuite(IgniteCacheTxLocalPeekModesTest.class);
+        suite.addTestSuite(IgniteCacheTxReplicatedPeekModesTest.class);
 
         // TODO: IGNITE-114.
         // suite.addTestSuite(IgniteCacheInvokeReadThroughTest.class);


Mime
View raw message