http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 index 81c0799..7725b19 100644 --- 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 @@ -1022,7 +1022,7 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra // Swap and offheap are disabled for near cache. IgniteCacheOffheapManager offheapManager = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap(); //First count entries... - int cnt = (int)offheapManager.entriesCount(part); + int cnt = (int)offheapManager.cacheEntriesCount(ctx.cacheId(), part); GridCacheAffinityManager affinity = ctx.affinity(); AffinityTopologyVersion topVer = affinity.affinityTopologyVersion();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java index eb8077f..c889c31 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStartTest.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.CU; @@ -176,8 +176,9 @@ public class IgniteCacheStartTest extends GridCommonAbstractTest { * @param idx Node index. * @param cacheName Cache name. * @param expCache {@code True} if cache should be created. + * @throws IgniteCheckedException If failed. */ - private void checkCache(int idx, final String cacheName, final boolean expCache) throws IgniteInterruptedCheckedException { + private void checkCache(int idx, final String cacheName, final boolean expCache) throws IgniteCheckedException { final IgniteKernal node = (IgniteKernal)ignite(idx); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() { http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java index a5cb3f2..bccebaa 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteOnePhaseCommitInvokeTest.java @@ -127,10 +127,12 @@ public class IgniteOnePhaseCommitInvokeTest extends GridCommonAbstractTest { final Ignite clientNode = startGrid(1); + final int grpId = groupIdForCache(srv0, CACHE_NAME); + TestRecordingCommunicationSpi.spi(srv0).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() { @Override public boolean apply(ClusterNode node, Message msg) { return msg instanceof GridDhtPartitionSupplyMessage && - ((GridDhtPartitionSupplyMessage)msg).cacheId() == CU.cacheId(CACHE_NAME); + ((GridDhtPartitionSupplyMessage)msg).groupId() == grpId; } }); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java index 057b0d6..2e551f9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTopologyValidatorGridSplitCacheTest.java @@ -202,6 +202,8 @@ public class IgniteTopologyValidatorGridSplitCacheTest extends GridCommonAbstrac /** * Resolves split by client node join. + * + * @throws Exception If failed. */ private void resolveSplit() throws Exception { startGrid(RESOLVER_GRID_IDX); @@ -305,6 +307,7 @@ public class IgniteTopologyValidatorGridSplitCacheTest extends GridCommonAbstrac return true; } + /** {@inheritDoc} */ @Override public void start() throws IgniteException { if (ignite.cluster().localNode().isClient()) return; @@ -327,12 +330,15 @@ public class IgniteTopologyValidatorGridSplitCacheTest extends GridCommonAbstrac /** * @param node Node. + * @return {@code True} if this is marker node. */ private boolean isMarkerNode(ClusterNode node) { return node.isClient() && node.attribute(ACTIVATOR_NODE_ATTR) != null; } - @Override public void stop() throws IgniteException { + /** {@inheritDoc} */ + @Override public void stop() { + // No-op. } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java index 872fe77..863ab38 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java @@ -370,7 +370,7 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb GridCacheAdapter cache = grid.internalCache(DEFAULT_CACHE_NAME); - GridCacheMapEntry entry = cache.map().getEntry(cache.context().toCacheKeyObject(key)); + GridCacheMapEntry entry = cache.map().getEntry(cache.context(), cache.context().toCacheKeyObject(key)); log.info("Entry: " + entry); @@ -383,7 +383,7 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb } if (cache.isNear()) { - entry = ((GridNearCacheAdapter)cache).dht().map().getEntry(cache.context().toCacheKeyObject(key)); + entry = ((GridNearCacheAdapter)cache).dht().map().getEntry(cache.context(), cache.context().toCacheKeyObject(key)); log.info("Dht entry: " + entry); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java index 06d62e4..5dace92 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java @@ -175,7 +175,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA for (int i = 0; i < gridCount(); i++) { GridCacheAdapter<Object, Object> c = ((IgniteKernal)grid(i)).internalCache(DEFAULT_CACHE_NAME); - for (GridCacheEntryEx e : c.map().entries()) { + for (GridCacheEntryEx e : c.map().entries(c.context().cacheId())) { Object key = e.key().value(c.context().cacheObjectContext(), false); Object val = CU.value(e.rawGet(), c.context(), false); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java index 654e729..75183b0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueCleanupSelfTest.java @@ -21,9 +21,11 @@ import java.util.Iterator; import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteQueue; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CollectionConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; @@ -177,20 +179,15 @@ public class GridCacheQueueCleanupSelfTest extends IgniteCollectionAbstractTest // Check that items of removed queue are removed, items of new queue not. assertTrue(GridTestUtils.waitForCondition(new PAX() { @SuppressWarnings("WhileLoopReplaceableByForEach") - @Override public boolean applyx() { + @Override public boolean applyx() throws IgniteCheckedException { int cnt = 0; for (int i = 0; i < gridCount(); i++) { GridCacheAdapter<Object, Object> cache = - ((IgniteKernal)grid(i)).context().cache().internalCache(queueCacheName); - - Iterator<GridCacheMapEntry> entries = cache.map().entries().iterator(); + grid(i).context().cache().internalCache(queueCacheName); - while (entries.hasNext()) { + for (Object e : cache.localEntries(new CachePeekMode[]{CachePeekMode.ALL})) cnt++; - - entries.next(); - } } if (cnt > 501) { // 500 items + header. http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java index 517a7ad..53c1eb7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetAbstractSelfTest.java @@ -34,14 +34,14 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSet; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.CollectionConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; -import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.internal.U; @@ -804,17 +804,12 @@ public abstract class GridCacheSetAbstractSelfTest extends IgniteCollectionAbstr GridCacheContext cctx = GridTestUtils.getFieldValue(set0, "cctx"); for (int i = 0; i < gridCount(); i++) { - Iterator<GridCacheMapEntry> entries = - (grid(i)).context().cache().internalCache(cctx.name()).map().entries().iterator(); + GridCacheAdapter cache = grid(i).context().cache().internalCache(cctx.name()); - while (entries.hasNext()) { - GridCacheEntryEx entry = entries.next(); + for (Object e : cache.localEntries(new CachePeekMode[]{CachePeekMode.ALL})) { + cnt++; - if (entry.hasValue()) { - cnt++; - - log.info("Unexpected entry: " + entry); - } + log.info("Unexpected entry: " + e); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java index 1e11c06..f8af2a2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetFailoverAbstractSelfTest.java @@ -29,6 +29,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSet; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.internal.processors.datastructures.SetItemKey; @@ -174,8 +175,9 @@ public abstract class GridCacheSetFailoverAbstractSelfTest extends IgniteCollect Set<IgniteUuid> setIds = new HashSet<>(); for (int i = 0; i < gridCount(); i++) { - Iterator<GridCacheMapEntry> entries = - grid(i).context().cache().internalCache(DEFAULT_CACHE_NAME).map().entries().iterator(); + GridCacheAdapter cache = grid(i).context().cache().internalCache(DEFAULT_CACHE_NAME); + + Iterator<GridCacheMapEntry> entries = cache.map().entries(cache.context().cacheId()).iterator(); while (entries.hasNext()) { GridCacheEntryEx entry = entries.next(); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java index 67b7f8f..aa075c0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedQueueNoBackupsTest.java @@ -24,6 +24,7 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.configuration.CollectionConfiguration; import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.testframework.GridTestUtils; @@ -72,8 +73,9 @@ public class IgnitePartitionedQueueNoBackupsTest extends GridCachePartitionedQue for (int i = 0; i < gridCount(); i++) { IgniteKernal grid = (IgniteKernal)grid(i); - Iterator<GridCacheMapEntry> entries = - grid.context().cache().internalCache(cctx.name()).map().entries().iterator(); + GridCacheAdapter cache = grid.context().cache().internalCache(cctx.name()); + + Iterator<GridCacheMapEntry> entries = cache.map().entries(cache.context().cacheId()).iterator(); if (entries.hasNext()) { if (setNodeId == null) http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java index a73aa4a..4daaeca 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/IgnitePartitionedSetNoBackupsSelfTest.java @@ -22,6 +22,7 @@ import java.util.Set; import java.util.UUID; import org.apache.ignite.configuration.CollectionConfiguration; import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheMapEntry; import org.apache.ignite.testframework.GridTestUtils; @@ -57,8 +58,9 @@ public class IgnitePartitionedSetNoBackupsSelfTest extends GridCachePartitionedS for (int i = 0; i < gridCount(); i++) { IgniteKernal grid = (IgniteKernal)grid(i); - Iterator<GridCacheMapEntry> entries = - grid.context().cache().internalCache(cctx.name()).map().entries().iterator(); + GridCacheAdapter cache = grid.context().cache().internalCache(cctx.name()); + + Iterator<GridCacheMapEntry> entries = cache.map().entries(cache.context().cacheId()).iterator(); if (entries.hasNext()) { if (setNodeId == null) http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java index a80830a..4cf89b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java @@ -57,6 +57,9 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest /** */ private ThreadLocal<Integer> staticCaches = new ThreadLocal<>(); + /** */ + private boolean withCacheGrp; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -158,11 +161,22 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest } } + checkCacheDiscoveryDataConsistent(); + stopAllGrids(); } } /** + * @throws Exception If failed. + */ + public void testConcurrentJoinCacheWithGroup() throws Exception { + withCacheGrp = true; + + testConcurrentJoin(); + } + + /** * @param caches Number of caches. * @return Cache configurations. */ @@ -186,6 +200,9 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setAffinity(new RendezvousAffinityFunction(false, 16)); + if (withCacheGrp) + ccfg.setGroupName("group1"); + return ccfg; } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java new file mode 100644 index 0000000..8859638 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGroupsPreloadTest.java @@ -0,0 +1,194 @@ +/* + * 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.distributed; + +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * + */ +public class CacheGroupsPreloadTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** */ + private static final String CACHE1 = "cache1"; + + /** */ + private static final String CACHE2 = "cache2"; + + /** */ + private static final String GROUP1 = "group1"; + + /** */ + private static final String GROUP2 = "group2"; + + /** */ + private CacheAtomicityMode atomicityMode = CacheAtomicityMode.ATOMIC; + + /** */ + private CacheMode cacheMode = CacheMode.PARTITIONED; + + /** */ + private boolean sameGrp = true; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + CacheConfiguration cfg1 = defaultCacheConfiguration() + .setName(CACHE1) + .setGroupName(GROUP1) + .setCacheMode(cacheMode) + .setAtomicityMode(atomicityMode) + .setBackups(1); + + CacheConfiguration cfg2 = new CacheConfiguration(cfg1) + .setName(CACHE2); + + if (!sameGrp) + cfg2.setGroupName(GROUP2); + + cfg.setCacheConfiguration(cfg1, cfg2); + + return cfg; + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload1() throws Exception { + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload2() throws Exception { + atomicityMode = CacheAtomicityMode.TRANSACTIONAL; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload3() throws Exception { + cacheMode = CacheMode.REPLICATED; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload4() throws Exception { + cacheMode = CacheMode.REPLICATED; + atomicityMode = CacheAtomicityMode.TRANSACTIONAL; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload5() throws Exception { + sameGrp = false; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload6() throws Exception { + sameGrp = false; + atomicityMode = CacheAtomicityMode.TRANSACTIONAL; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload7() throws Exception { + sameGrp = false; + cacheMode = CacheMode.REPLICATED; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + public void testCachePreload8() throws Exception { + sameGrp = false; + cacheMode = CacheMode.REPLICATED; + atomicityMode = CacheAtomicityMode.TRANSACTIONAL; + + cachePreloadTest(); + } + + /** + * @throws Exception If failed. + */ + private void cachePreloadTest() throws Exception { + IgniteCache<Object, Object> cache = startGrid(0).cache(CACHE1); + + for (int i = 0; i < 1000; i++) + cache.put(i, CACHE1 + "-" + i); + + cache = startGrid(1).cache(CACHE1); + + for (int i = 0; i < 1000; i++) + assertEquals(CACHE1 + "-" + i, cache.get(i)); + + cache = ignite(1).cache(CACHE2); + + for (int i = 0; i < 1000; i++) + cache.put(i, CACHE2 + "-" + i); + + cache = startGrid(2).cache(CACHE1); + + for (int i = 0; i < 1000; i++) + assertEquals(CACHE1 + "-" + i, cache.get(i)); + + cache = ignite(2).cache(CACHE2); + + for (int i = 0; i < 1000; i++) + assertEquals(CACHE2 + "-" + i, cache.get(i)); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java index bc435e2..20cef30 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java @@ -2008,12 +2008,14 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { * @param cacheName Cache name. */ private void blockSupplySend(TestRecordingCommunicationSpi spi, final String cacheName) { + final int grpId = groupIdForCache(spi.ignite(), cacheName); + spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() { @Override public boolean apply(ClusterNode node, Message msg) { if (!msg.getClass().equals(GridDhtPartitionSupplyMessage.class)) return false; - return ((GridDhtPartitionSupplyMessage)msg).cacheId() == CU.cacheId(cacheName); + return ((GridDhtPartitionSupplyMessage)msg).groupId() == grpId; } }); } @@ -2420,7 +2422,7 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { Collection<ClusterNode> allNodes = ctx.discovery().cacheNodes(topVer0); - for (DynamicCacheDescriptor cacheDesc : ctx.cache().cacheDescriptors()) { + for (DynamicCacheDescriptor cacheDesc : ctx.cache().cacheDescriptors().values()) { if (assignments.get(cacheDesc.cacheId()) != null) continue; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java index 5bbeef9..47fefe5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java @@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache.distributed; import java.util.Collection; import java.util.Collections; -import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.cache.CacheException; @@ -42,7 +41,6 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.util.TestTcpCommunicationSpi; import static org.apache.ignite.cache.CacheMode.PARTITIONED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; @@ -67,23 +65,8 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - disco.setIpFinder(ipFinder); - cfg.setDiscoverySpi(disco); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); - if (gridName.matches(".*\\d")) { - String idStr = UUID.randomUUID().toString(); - - char[] chars = idStr.toCharArray(); - - chars[chars.length - 3] = '0'; - chars[chars.length - 2] = '0'; - chars[chars.length - 1] = gridName.charAt(gridName.length() - 1); - - cfg.setNodeId(UUID.fromString(new String(chars))); - } - - cfg.setCommunicationSpi(new TestTcpCommunicationSpi()); cfg.setClientMode(client); CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(CACHE_NAME); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java index 1433daa..9907937 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java @@ -41,7 +41,6 @@ import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; @@ -196,12 +195,14 @@ public class IgniteCacheReadFromBackupTest extends GridCommonAbstractTest { TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi)ignite.configuration().getCommunicationSpi(); + final int grpId = groupIdForCache(ignite, ccfg.getName()); + spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() { @Override public boolean apply(ClusterNode node, Message msg) { if (!msg.getClass().equals(GridDhtPartitionSupplyMessage.class)) return false; - return ((GridDhtPartitionSupplyMessage)msg).cacheId() == CU.cacheId(ccfg.getName()); + return ((GridDhtPartitionSupplyMessage)msg).groupId() == grpId; } }); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.java new file mode 100644 index 0000000..3eafe68 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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.distributed.dht; + +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * + */ +public class GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest + extends GridCachePartitionedNearDisabledMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setGroupName("group1"); + + return ccfg; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java index 888fae3..749ebe8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java @@ -34,12 +34,11 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.TestRecordingCommunicationSpi; -import org.apache.ignite.internal.processors.cache.GridCacheMessage; +import org.apache.ignite.internal.processors.cache.GridCacheGroupIdMessage; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage; import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; @@ -100,11 +99,13 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest { * */ private void blockRebalance() { + final int grpId = groupIdForCache(ignite(0), TEST_CACHE); + for (Ignite node : G.allGrids()) { testSpi(node).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() { @Override public boolean apply(ClusterNode node, Message msg) { return (msg instanceof GridDhtPartitionSupplyMessage) - && ((GridCacheMessage)msg).cacheId() == CU.cacheId(TEST_CACHE); + && ((GridCacheGroupIdMessage)msg).groupId() == grpId; } }); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeWithGroupFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeWithGroupFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeWithGroupFullApiSelfTest.java new file mode 100644 index 0000000..30337d9 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeWithGroupFullApiSelfTest.java @@ -0,0 +1,34 @@ +/* + * 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.distributed.near; + +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * + */ +public class GridCacheAtomicMultiNodeWithGroupFullApiSelfTest extends GridCacheAtomicMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setGroupName("group1"); + + return ccfg; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest.java new file mode 100644 index 0000000..f57d81a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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.distributed.near; + +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * + */ +public class GridCacheAtomicNearEnabledMultiNodeWithGroupFullApiSelfTest extends + GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setGroupName("group1"); + + return ccfg; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 40a3af2..cbb2032 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 @@ -253,11 +253,12 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest { awaitPartitionMapExchange(); - GridCacheContext ctx = ((IgniteKernal) g1).internalCache(DEFAULT_CACHE_NAME).context(); + GridCacheContext ctx = ((IgniteKernal)g1).internalCache(DEFAULT_CACHE_NAME).context(); List<KeyCacheObject> cacheKeys = F.asList(ctx.toCacheKeyObject(1), ctx.toCacheKeyObject(2)); IgniteInternalFuture<Object> f1 = ((IgniteKernal)g1).internalCache(DEFAULT_CACHE_NAME).preloader().request( + ctx, cacheKeys, new AffinityTopologyVersion(2)); @@ -266,6 +267,7 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest { IgniteInternalFuture<Object> f2 = ((IgniteKernal)g2).internalCache(DEFAULT_CACHE_NAME).preloader().request( + ((IgniteKernal)g2).internalCache(DEFAULT_CACHE_NAME).context(), cacheKeys, new AffinityTopologyVersion(2)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.java new file mode 100644 index 0000000..542628a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeWithGroupFullApiSelfTest.java @@ -0,0 +1,34 @@ +/* + * 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.distributed.near; + +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * + */ +public class GridCachePartitionedMultiNodeWithGroupFullApiSelfTest extends GridCachePartitionedMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setGroupName("group1"); + + return ccfg; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 346f908..e90b7e1 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 @@ -268,7 +268,8 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { break; } - assert evts != null && evts.size() == 2 : "Wrong events received: " + evts; + assertNotNull(evts); + assertEquals("Wrong events received: " + evts, 2, evts.size()); Iterator<Event> iter = evts.iterator(); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java index f7164a0..3417ba8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheClientNearCacheExpiryTest.java @@ -28,8 +28,7 @@ import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap; -import org.apache.ignite.internal.processors.cache.GridCacheProxyImpl; +import org.apache.ignite.internal.processors.cache.GridCacheLocalConcurrentMap; import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.internal.U; @@ -84,6 +83,13 @@ public class IgniteCacheClientNearCacheExpiryTest extends IgniteCacheAbstractTes public void testExpirationOnClient() throws Exception { Ignite ignite = grid(NODES - 1); + // Check size of near entries via reflection because entries is filtered for size() API call. + IgniteEx igniteEx = (IgniteEx)ignite; + + GridCacheAdapter internalCache = igniteEx.context().cache().internalCache(DEFAULT_CACHE_NAME); + + GridCacheLocalConcurrentMap map = GridTestUtils.getFieldValue(internalCache, GridCacheAdapter.class, "map"); + assertTrue(ignite.configuration().isClientMode()); IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME); @@ -103,17 +109,11 @@ public class IgniteCacheClientNearCacheExpiryTest extends IgniteCacheAbstractTes assertEquals(i, cacheWithExpiry.localPeek(i)); } + assertEquals(KEYS_COUNT * 2, map.publicSize(internalCache.context().cacheId())); U.sleep(1000); - // Check size of near entries via reflection because entries is filtered for size() API call. - IgniteEx igniteEx = (IgniteEx)ignite; - GridCacheConcurrentMap map = GridTestUtils.getFieldValue( - ((GridCacheProxyImpl)igniteEx.cachex(DEFAULT_CACHE_NAME)).delegate(), - GridCacheAdapter.class, - "map"); - - assertEquals(KEYS_COUNT, map.publicSize()); + assertEquals(KEYS_COUNT, map.publicSize(internalCache.context().cacheId())); assertEquals(KEYS_COUNT, cache.size()); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java index 9d21823..227fe1f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java @@ -82,6 +82,6 @@ public class IgniteCacheTtlCleanupSelfTest extends GridCacheAbstractSelfTest { CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext(); for (int i = 0; i < 100; i++) - assertNull(cacheAdapter.map().getEntry(cacheObjects.toCacheKeyObject(cacheObjCtx, null, i, true))); + assertNull(cacheAdapter.map().getEntry(cacheAdapter.context(), cacheObjects.toCacheKeyObject(cacheObjCtx, null, i, true))); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheJdbcBlobStoreNodeRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheJdbcBlobStoreNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheJdbcBlobStoreNodeRestartTest.java index 1c29098..83ddf67 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheJdbcBlobStoreNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheJdbcBlobStoreNodeRestartTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.cache.store.CacheStore; import org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStore; import org.apache.ignite.configuration.NearCacheConfiguration; +/** + * + */ public class IgniteCacheJdbcBlobStoreNodeRestartTest extends IgniteCacheStoreNodeRestartAbstractTest { /** {@inheritDoc} */ @Override protected CacheStore getStore() { http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalAtomicWithGroupFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalAtomicWithGroupFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalAtomicWithGroupFullApiSelfTest.java new file mode 100644 index 0000000..4597a75 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalAtomicWithGroupFullApiSelfTest.java @@ -0,0 +1,34 @@ +/* + * 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.local; + +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * + */ +public class GridCacheLocalAtomicWithGroupFullApiSelfTest extends GridCacheLocalAtomicFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setGroupName("group1"); + + return ccfg; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java index 0c7a217..8cb9369 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalFullApiSelfTest.java @@ -22,7 +22,6 @@ import java.util.Map; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest; import org.apache.ignite.internal.util.typedef.F; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalWithGroupFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalWithGroupFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalWithGroupFullApiSelfTest.java new file mode 100644 index 0000000..867a2de --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalWithGroupFullApiSelfTest.java @@ -0,0 +1,34 @@ +/* + * 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.local; + +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * + */ +public class GridCacheLocalWithGroupFullApiSelfTest extends GridCacheLocalFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setGroupName("group1"); + + return ccfg; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java index 9c7c836..6c74f79 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java @@ -35,6 +35,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.util.lang.GridAbsPredicate; +import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; @@ -78,52 +79,74 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo * @throws Exception If failed. */ public void testConcurrentUpdatePartitionAtomic() throws Exception { - concurrentUpdatePartition(ATOMIC); + concurrentUpdatePartition(ATOMIC, false); } /** * @throws Exception If failed. */ public void testConcurrentUpdatePartitionTx() throws Exception { - concurrentUpdatePartition(TRANSACTIONAL); + concurrentUpdatePartition(TRANSACTIONAL, false); + } + + /** + * @throws Exception If failed. + */ + public void testConcurrentUpdatePartitionAtomicCacheGroup() throws Exception { + concurrentUpdatePartition(ATOMIC, true); + } + + /** + * @throws Exception If failed. + */ + public void testConcurrentUpdatePartitionTxCacheGroup() throws Exception { + concurrentUpdatePartition(TRANSACTIONAL, true); } /** * @param atomicityMode Cache atomicity mode. + * @param cacheGrp {@code True} if test cache multiple caches in the same group. * @throws Exception If failed. */ - private void concurrentUpdatePartition(CacheAtomicityMode atomicityMode) throws Exception { + private void concurrentUpdatePartition(CacheAtomicityMode atomicityMode, boolean cacheGrp) throws Exception { Ignite srv = startGrid(0); client = true; Ignite client = startGrid(1); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + List<AtomicInteger> cntrs = new ArrayList<>(); + List<String> caches = new ArrayList<>(); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setAtomicityMode(atomicityMode); + if (cacheGrp) { + for (int i = 0; i < 3; i++) { + CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME + i); - IgniteCache clientCache = client.createCache(ccfg); + ccfg.setGroupName("testGroup"); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setAtomicityMode(atomicityMode); - final AtomicInteger evtCnt = new AtomicInteger(); + IgniteCache<Object, Object> cache = client.createCache(ccfg); - ContinuousQuery<Object, Object> qry = new ContinuousQuery<>(); - - qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() { - @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) { - for (CacheEntryEvent evt : evts) { - assertNotNull(evt.getKey()); - assertNotNull(evt.getValue()); + caches.add(cache.getName()); - evtCnt.incrementAndGet(); - } + cntrs.add(startListener(cache).get1()); } - }); + } + else { + CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); - clientCache.query(qry); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setAtomicityMode(atomicityMode); - Affinity<Integer> aff = srv.affinity(DEFAULT_CACHE_NAME); + IgniteCache<Object, Object> cache = client.createCache(ccfg); + + caches.add(cache.getName()); + + cntrs.add(startListener(cache).get1()); + } + + Affinity<Integer> aff = srv.affinity(caches.get(0)); final List<Integer> keys = new ArrayList<>(); @@ -143,7 +166,10 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo final int THREADS = 10; final int UPDATES = 1000; - final IgniteCache<Object, Object> srvCache = srv.cache(DEFAULT_CACHE_NAME); + final List<IgniteCache<Object, Object>> srvCaches = new ArrayList<>(); + + for (String cacheName : caches) + srvCaches.add(srv.cache(cacheName)); for (int i = 0; i < 15; i++) { log.info("Iteration: " + i); @@ -152,60 +178,124 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo @Override public Void call() throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); - for (int i = 0; i < UPDATES; i++) - srvCache.put(keys.get(rnd.nextInt(KEYS)), i); + for (int i = 0; i < UPDATES; i++) { + for (int c = 0; c < srvCaches.size(); c++) + srvCaches.get(c).put(keys.get(rnd.nextInt(KEYS)), i); + } return null; } }, THREADS, "update"); - GridTestUtils.waitForCondition(new GridAbsPredicate() { - @Override public boolean apply() { - log.info("Events: " + evtCnt.get()); + for (final AtomicInteger evtCnt : cntrs) { + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + log.info("Events: " + evtCnt.get()); - return evtCnt.get() >= THREADS * UPDATES; - } - }, 5000); + return evtCnt.get() >= THREADS * UPDATES; + } + }, 5000); - assertEquals(THREADS * UPDATES, evtCnt.get()); + assertEquals(THREADS * UPDATES, evtCnt.get()); - evtCnt.set(0); + evtCnt.set(0); + } } } /** + * @param cache Cache. + * @return Event counter. + */ + private T2<AtomicInteger, QueryCursor> startListener(IgniteCache<Object, Object> cache) { + final AtomicInteger evtCnt = new AtomicInteger(); + + ContinuousQuery<Object, Object> qry = new ContinuousQuery<>(); + + qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() { + @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) { + for (CacheEntryEvent evt : evts) { + assertNotNull(evt.getKey()); + assertNotNull(evt.getValue()); + + if ((Integer)evt.getValue() >= 0) + evtCnt.incrementAndGet(); + } + } + }); + + QueryCursor cur = cache.query(qry); + + return new T2<>(evtCnt, cur); + } + + /** * @throws Exception If failed. */ public void testConcurrentUpdatesAndQueryStartAtomic() throws Exception { - concurrentUpdatesAndQueryStart(ATOMIC); + concurrentUpdatesAndQueryStart(ATOMIC, false); } /** * @throws Exception If failed. */ public void testConcurrentUpdatesAndQueryStartTx() throws Exception { - concurrentUpdatesAndQueryStart(TRANSACTIONAL); + concurrentUpdatesAndQueryStart(TRANSACTIONAL, false); + } + + /** + * @throws Exception If failed. + */ + public void _testConcurrentUpdatesAndQueryStartAtomicCacheGroup() throws Exception { + concurrentUpdatesAndQueryStart(ATOMIC, true); + } + + /** + * @throws Exception If failed. + */ + public void _testConcurrentUpdatesAndQueryStartTxCacheGroup() throws Exception { + concurrentUpdatesAndQueryStart(TRANSACTIONAL, true); } /** * @param atomicityMode Cache atomicity mode. + * @param cacheGrp {@code True} if test cache multiple caches in the same group. * @throws Exception If failed. */ - private void concurrentUpdatesAndQueryStart(CacheAtomicityMode atomicityMode) throws Exception { + private void concurrentUpdatesAndQueryStart(CacheAtomicityMode atomicityMode, boolean cacheGrp) throws Exception { Ignite srv = startGrid(0); client = true; Ignite client = startGrid(1); - CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + List<String> caches = new ArrayList<>(); + + if (cacheGrp) { + for (int i = 0; i < 3; i++) { + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME + i); - ccfg.setWriteSynchronizationMode(FULL_SYNC); - ccfg.setAtomicityMode(atomicityMode); + ccfg.setGroupName("testGroup"); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setAtomicityMode(atomicityMode); - IgniteCache clientCache = client.createCache(ccfg); + IgniteCache cache = client.createCache(ccfg); - Affinity<Integer> aff = srv.affinity(DEFAULT_CACHE_NAME); + caches.add(cache.getName()); + } + } + else { + CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); + + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setAtomicityMode(atomicityMode); + + IgniteCache cache = client.createCache(ccfg); + + caches.add(cache.getName()); + } + + Affinity<Integer> aff = srv.affinity(caches.get(0)); final List<Integer> keys = new ArrayList<>(); @@ -225,38 +315,27 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo final int THREADS = 10; final int UPDATES = 1000; - for (int i = 0; i < 5; i++) { - log.info("Iteration: " + i); - - ContinuousQuery<Object, Object> qry = new ContinuousQuery<>(); - - final AtomicInteger evtCnt = new AtomicInteger(); - - qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() { - @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) { - for (CacheEntryEvent evt : evts) { - assertNotNull(evt.getKey()); - assertNotNull(evt.getValue()); + final List<IgniteCache<Object, Object>> srvCaches = new ArrayList<>(); - if ((Integer)evt.getValue() >= 0) - evtCnt.incrementAndGet(); - } - } - }); - - QueryCursor cur; + for (String cacheName : caches) + srvCaches.add(srv.cache(cacheName)); - final IgniteCache<Object, Object> srvCache = srv.cache(DEFAULT_CACHE_NAME); + for (int i = 0; i < 5; i++) { + log.info("Iteration: " + i); final AtomicBoolean stop = new AtomicBoolean(); + List<T2<AtomicInteger, QueryCursor> > qrys = new ArrayList<>(); + try { IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() { @Override public Void call() throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); - while (!stop.get()) - srvCache.put(keys.get(rnd.nextInt(KEYS)), rnd.nextInt(100) - 200); + while (!stop.get()) { + for (IgniteCache<Object, Object> srvCache : srvCaches) + srvCache.put(keys.get(rnd.nextInt(KEYS)), rnd.nextInt(100) - 200); + } return null; } @@ -264,7 +343,8 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo U.sleep(1000); - cur = clientCache.query(qry); + for (String cache : caches) + qrys.add(startListener(client.cache(cache))); U.sleep(1000); @@ -280,25 +360,30 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo @Override public Void call() throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); - for (int i = 0; i < UPDATES; i++) - srvCache.put(keys.get(rnd.nextInt(KEYS)), i); + for (int i = 0; i < UPDATES; i++) { + for (IgniteCache<Object, Object> srvCache : srvCaches) + srvCache.put(keys.get(rnd.nextInt(KEYS)), i); + } return null; } }, THREADS, "update"); + for (T2<AtomicInteger, QueryCursor> qry : qrys) { + final AtomicInteger evtCnt = qry.get1(); - GridTestUtils.waitForCondition(new GridAbsPredicate() { - @Override public boolean apply() { - log.info("Events: " + evtCnt.get()); + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + log.info("Events: " + evtCnt.get()); - return evtCnt.get() >= THREADS * UPDATES; - } - }, 5000); + return evtCnt.get() >= THREADS * UPDATES; + } + }, 5000); - assertEquals(THREADS * UPDATES, evtCnt.get()); + assertEquals(THREADS * UPDATES, qry.get1().get()); - cur.close(); + qry.get2().close(); + } } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java index 2fb7fcb..54791d7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java @@ -2243,13 +2243,11 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC * @throws Exception If failed. */ public void testNoEventLossOnTopologyChange() throws Exception { - final int stableNodeCnt = 1; - final int batchLoadSize = 2000; final int restartCycles = 5; - Ignite qryClient = startGridsMultiThreaded(stableNodeCnt); + Ignite qryClient = startGrid(0); final CacheEventListener4 lsnr = new CacheEventListener4(atomicityMode() == CacheAtomicityMode.ATOMIC); @@ -2282,7 +2280,7 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC log.info("Batch loaded. Iteration: " + iteration); - final long expCnt = putCnt * stableNodeCnt + ignoredDupEvts; + final long expCnt = putCnt + ignoredDupEvts; GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { @@ -2316,7 +2314,6 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC String msg = sb.toString(); // In atomic mode CQ can receive duplicate update events if update retried after fails. - // E.g. topology change if (atomicityMode() == CacheAtomicityMode.ATOMIC && msg.isEmpty() && cnt > expCnt) ignoredDupEvts += cnt - expCnt; else http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java index b48c4ba..1573576 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java @@ -399,7 +399,7 @@ public class TxOptimisticDeadlockDetectionTest extends GridCommonAbstractTest { KeyCacheObject keyCacheObj = intCache.context().toCacheKeyObject(key0); - GridCacheMapEntry entry = map.getEntry(keyCacheObj); + GridCacheMapEntry entry = map.getEntry(intCache.context(), keyCacheObj); if (entry != null) assertNull("Entry still has locks " + entry, entry.mvccAllLocal()); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java index bc297a2..61f7125 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java @@ -408,7 +408,7 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest { KeyCacheObject keyCacheObj = intCache.context().toCacheKeyObject(key0); - GridCacheMapEntry entry = map.getEntry(keyCacheObj); + GridCacheMapEntry entry = map.getEntry(intCache.context(), keyCacheObj); if (entry != null) assertNull("Entry still has locks " + entry, entry.mvccAllLocal()); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java index f12537b..310082d 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java @@ -81,14 +81,11 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> { null ), defaultCacheConfiguration(), + null, CacheType.USER, AffinityTopologyVersion.ZERO, - UUID.randomUUID(), true, true, - null, - null, - null, new GridCacheEventManager(), new CacheOsStoreManager(null, new CacheConfiguration()), new GridCacheEvictionManager(), @@ -97,7 +94,6 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> { new CacheDataStructuresManager(), new GridCacheTtlManager(), new GridOsCacheDrManager(), - null, new CacheOsConflictResolutionManager<K, V>(), new CachePluginManager(ctx, new CacheConfiguration()), new GridCacheAffinityManager() http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java index 25ff2fd..4a6b765 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java @@ -216,6 +216,16 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @Override public int handlerId() { + return 0; + } + + /** {@inheritDoc} */ + @Override public boolean cacheGroupMessage() { + return false; + } + + /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; } @@ -311,6 +321,16 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @Override public int handlerId() { + return 0; + } + + /** {@inheritDoc} */ + @Override public boolean cacheGroupMessage() { + return false; + } + + /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; } @@ -434,6 +454,16 @@ public class GridCacheMessageSelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @Override public int handlerId() { + return 0; + } + + /** {@inheritDoc} */ + @Override public boolean cacheGroupMessage() { + return false; + } + + /** {@inheritDoc} */ @Override public boolean addDeploymentInfo() { return false; } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index 46d97a0..cbcbaee 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -101,6 +101,8 @@ import org.apache.ignite.testframework.config.GridTestProperties; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static org.springframework.util.FileSystemUtils.deleteRecursively; + /** * Utility class for tests. */ @@ -1876,4 +1878,11 @@ public final class GridTestUtils { return b.toString(); } + + /** + * @throws Exception If failed. + */ + public static void deleteDbFiles() throws Exception { + deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false)); + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index 281901a..9d0af5d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -68,6 +68,7 @@ import org.apache.ignite.internal.binary.BinaryContext; import org.apache.ignite.internal.binary.BinaryEnumCache; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.resource.GridSpringResourceContext; import org.apache.ignite.internal.util.GridClassLoaderCache; import org.apache.ignite.internal.util.GridTestClockTimer; @@ -2102,6 +2103,22 @@ public abstract class GridAbstractTest extends TestCase { } /** + * @param node Node. + * @param cacheName Cache name. + * @return Cache group ID for given cache name. + */ + protected final int groupIdForCache(Ignite node, String cacheName) { + for (CacheGroupContext grp : ((IgniteKernal)node).context().cache().cacheGroups()) { + if (grp.hasCache(cacheName)) + return grp.groupId(); + } + + fail("Failed to find group for cache: " + cacheName); + + return 0; + } + + /** * */ private static interface WriteReplaceOwner {
