Repository: ignite Updated Branches: refs/heads/ignite-971-1 [created] 32c7805c4
ignite-971 Fix swap/unswap. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/32c7805c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/32c7805c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/32c7805c Branch: refs/heads/ignite-971-1 Commit: 32c7805c4878595f4b8e8ec5a45621a28432958e Parents: 3e09aa3 Author: sboikov <[email protected]> Authored: Mon Sep 7 13:24:23 2015 +0300 Committer: sboikov <[email protected]> Committed: Mon Sep 7 13:28:23 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheEntryEx.java | 12 +- .../cache/GridCacheEvictionManager.java | 2 + .../processors/cache/GridCacheMapEntry.java | 11 +- .../distributed/dht/GridDhtCacheAdapter.java | 14 +- .../distributed/dht/GridDhtLocalPartition.java | 23 +- .../distributed/dht/GridDhtLockFuture.java | 6 +- .../distributed/dht/GridDhtTxLocalAdapter.java | 22 +- .../dht/preloader/GridDhtPreloader.java | 17 +- .../distributed/near/GridNearTxRemote.java | 6 +- .../transactions/IgniteTxLocalAdapter.java | 20 +- .../cache/CacheSwapUnswapGetTest.java | 209 +++++++++++++++++++ .../testsuites/IgniteCacheTestSuite4.java | 3 + 12 files changed, 308 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java index 698d043..98e86ed 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java @@ -641,8 +641,10 @@ public interface GridCacheEntryEx { * * @return Versioned entry. * @throws IgniteCheckedException In case of error. + * @throws GridCacheEntryRemovedException If entry was removed. */ - public <K, V> GridCacheVersionedEntryEx<K, V> versionedEntry() throws IgniteCheckedException; + public <K, V> GridCacheVersionedEntryEx<K, V> versionedEntry() + throws IgniteCheckedException, GridCacheEntryRemovedException; /** * Sets new value if passed in version matches the current version @@ -867,8 +869,10 @@ public interface GridCacheEntryEx { /** * @return Value. * @throws IgniteCheckedException If failed to read from swap storage. + * @throws GridCacheEntryRemovedException If entry was removed. */ - @Nullable public CacheObject unswap() throws IgniteCheckedException; + @Nullable public CacheObject unswap() + throws IgniteCheckedException, GridCacheEntryRemovedException; /** * Unswap ignoring flags. @@ -876,8 +880,10 @@ public interface GridCacheEntryEx { * @param needVal If {@code false} then do not need to deserialize value during unswap. * @return Value. * @throws IgniteCheckedException If failed. + * @throws GridCacheEntryRemovedException If entry was removed. */ - @Nullable public CacheObject unswap(boolean needVal) throws IgniteCheckedException; + @Nullable public CacheObject unswap(boolean needVal) + throws IgniteCheckedException, GridCacheEntryRemovedException; /** * Tests whether or not given metadata is set. http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java index b2fa2dd..f60c0eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java @@ -994,6 +994,8 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter { notRemove = new HashSet<>(); notRemove.add(entry); + + continue; } if (obsoleteVer == null) http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index e4882e5..eb4d864 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -433,7 +433,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme } /** {@inheritDoc} */ - @Override public CacheObject unswap() throws IgniteCheckedException { + @Override public CacheObject unswap() throws IgniteCheckedException, GridCacheEntryRemovedException { return unswap(true); } @@ -444,13 +444,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme * @return Value. * @throws IgniteCheckedException If failed. */ - @Nullable @Override public CacheObject unswap(boolean needVal) throws IgniteCheckedException { + @Nullable @Override public CacheObject unswap(boolean needVal) + throws IgniteCheckedException, GridCacheEntryRemovedException { boolean swapEnabled = cctx.swap().swapEnabled(); if (!swapEnabled && !cctx.isOffHeapEnabled()) return null; synchronized (this) { + checkObsolete(); + if (isStartVersion() && ((flags & IS_UNSWAPPED_MASK) == 0)) { GridCacheSwapEntry e; @@ -3056,7 +3059,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme } /** {@inheritDoc} */ - @Override public synchronized GridCacheVersionedEntryEx versionedEntry() throws IgniteCheckedException { + @Override public synchronized GridCacheVersionedEntryEx versionedEntry() + throws IgniteCheckedException, GridCacheEntryRemovedException { boolean isNew = isStartVersion(); CacheObject val = isNew ? unswap(true) : rawGetOrUnmarshalUnlocked(false); @@ -3757,6 +3761,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme throws IgniteCheckedException { assert Thread.holdsLock(this); assert cctx.isSwapOrOffheapEnabled(); + assert !obsolete(); GridCacheBatchSwapEntry ret = null; http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index ee56b16..3ce9ee9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -839,9 +839,19 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap try { if (swap) { - entry = cache.entryEx(keys.get(i)); + while (true) { + try { + entry = cache.entryEx(keys.get(i)); - entry.unswap(false); + entry.unswap(false); + + break; + } + catch (GridCacheEntryRemovedException e) { + if (log.isDebugEnabled()) + log.debug("Got removed entry: " + entry); + } + } } else entry = cache.peekEx(keys.get(i)); http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java index 6d22dc7..215a1b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java @@ -34,6 +34,7 @@ import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; import org.apache.ignite.internal.processors.cache.GridCacheSwapEntry; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader; @@ -717,17 +718,23 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>, byte[] keyBytes = entry.getKey(); - try { - KeyCacheObject key = cctx.toCacheKeyObject(keyBytes); + while (true) { + try { + KeyCacheObject key = cctx.toCacheKeyObject(keyBytes); - lastEntry = (GridDhtCacheEntry)cctx.cache().entryEx(key, false); + lastEntry = (GridDhtCacheEntry)cctx.cache().entryEx(key, false); - lastEntry.unswap(true); + lastEntry.unswap(true); - return lastEntry; - } - catch (IgniteCheckedException e) { - throw new CacheException(e); + return lastEntry; + } + catch (GridCacheEntryRemovedException e) { + if (log.isDebugEnabled()) + log.debug("Got removed entry: " + lastEntry); + } + catch (IgniteCheckedException e) { + throw new CacheException(e); + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index 4275623..2c16534 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -872,12 +872,12 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean> for (ListIterator<GridDhtCacheEntry> it = dhtMapping.listIterator(); it.hasNext();) { GridDhtCacheEntry e = it.next(); - // Must unswap entry so that isNewLocked returns correct value. - e.unswap(false); - boolean needVal = false; try { + // Must unswap entry so that isNewLocked returns correct value. + e.unswap(false); + needVal = e.isNewLocked(); if (needVal) { http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java index 194da15..762d26f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java @@ -622,11 +622,27 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter { // First time access. if (txEntry == null) { - GridDhtCacheEntry cached = dhtCache.entryExx(key, topVer); + GridDhtCacheEntry cached; - addActiveCache(dhtCache.context()); + if (dhtCache.context().isSwapOrOffheapEnabled()) { + while (true) { + try { + cached = dhtCache.entryExx(key, topVer); + + cached.unswap(read); + + break; + } + catch (GridCacheEntryRemovedException e) { + if (log.isDebugEnabled()) + log.debug("Get removed entry: " + key); + } + } + } + else + cached = dhtCache.entryExx(key, topVer); - cached.unswap(read); + addActiveCache(dhtCache.context()); txEntry = addEntry(NOOP, null, http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java index 501d624..9c2c28f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java @@ -35,6 +35,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo; +import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; import org.apache.ignite.internal.processors.cache.GridCachePreloaderAdapter; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentRequest; @@ -378,9 +379,19 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter { GridCacheEntryEx entry; if (cctx.isSwapOrOffheapEnabled()) { - entry = cctx.dht().entryEx(k, true); - - entry.unswap(); + while (true) { + try { + entry = cctx.dht().entryEx(k, true); + + entry.unswap(); + + break; + } + catch (GridCacheEntryRemovedException ignore) { + if (log.isDebugEnabled()) + log.debug("Got removed entry: " + k); + } + } } else entry = cctx.dht().peekEx(k); http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java index fff6dde..4395198 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java @@ -280,9 +280,9 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter { return false; } else { - cached.unswap(); - try { + cached.unswap(); + CacheObject val = cached.peek(true, false, false, null); if (val == null && cached.evictInternal(false, xidVer, null)) { @@ -313,7 +313,9 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter { } /** + * @param cacheCtx Cache context. * @param key Key to add to read set. + * @param op Operation. * @param val Value. * @param drVer Data center replication version. * @param skipStore Skip store flag. http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 97e88a7..7d32401 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -2159,20 +2159,20 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter // First time access. if (txEntry == null) { while (true) { - GridCacheEntryEx entry; + GridCacheEntryEx entry = null; - if (cached != null) { - entry = cached; + try { + if (cached != null) { + entry = cached; - cached = null; - } - else { - entry = entryEx(cacheCtx, txKey, topologyVersion()); + cached = null; + } + else { + entry = entryEx(cacheCtx, txKey, topologyVersion()); - entry.unswap(false); - } + entry.unswap(false); + } - try { // Check if lock is being explicitly acquired by the same thread. if (!implicit && cctx.kernalContext().config().isCacheSanityCheckEnabled() && entry.lockedByThread(threadId, xidVer)) http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTest.java new file mode 100644 index 0000000..6af64ca --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSwapUnswapGetTest.java @@ -0,0 +1,209 @@ +/* + * 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 java.util.Collections; +import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.typedef.CAX; +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.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.eclipse.jetty.util.ConcurrentHashSet; + +import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; + +/** + * + */ +public class CacheSwapUnswapGetTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** */ + private static final long DURATION = 30_000; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + return cfg; + } + + /** + * @param atomicityMode Cache atomicity mode. + * @param swap {@code True} if swap enabled. + * @return Cache configuration. + */ + private CacheConfiguration<Integer, String> cacheConfiguration(CacheAtomicityMode atomicityMode, boolean swap) { + CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>(); + + ccfg.setAtomicityMode(atomicityMode); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + + LruEvictionPolicy plc = new LruEvictionPolicy(); + plc.setMaxSize(100); + + ccfg.setEvictionPolicy(plc); + + if (swap) { + ccfg.setSwapEnabled(true); + + ccfg.setOffHeapMaxMemory(1000); + } + else + ccfg.setOffHeapMaxMemory(0); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + startGrid(0); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + super.afterTestsStopped(); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return DURATION + 60_000; + } + + /** + * @throws Exception If failed. + */ + public void testTxCacheOffheap() throws Exception { + swapUnswap(TRANSACTIONAL, false); + } + + /** + * @throws Exception If failed. + */ + public void testAtomicCacheOffheap() throws Exception { + swapUnswap(ATOMIC, false); + } + + /** + * @param atomicityMode Cache atomicity mode. + * @param swap {@code True} if swap enabled. + * @throws Exception If failed. + */ + private void swapUnswap(CacheAtomicityMode atomicityMode, boolean swap) throws Exception { + log.info("Start test [mode=" + atomicityMode + ", swap=" + swap + ']'); + + int threadCnt = 20; + final int keyCnt = 1000; + final int valCnt = 10000; + + final Ignite g = grid(0); + + final ConcurrentHashSet<Integer> keys = new ConcurrentHashSet<>(); + + final AtomicBoolean done = new AtomicBoolean(); + + g.destroyCache(null); + + final IgniteCache<Integer, String> cache = g.createCache(cacheConfiguration(atomicityMode, swap)); + + try { + IgniteInternalFuture<?> fut = multithreadedAsync(new CAX() { + @Override public void applyx() throws IgniteCheckedException { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + while (!done.get()) { + Integer key = rnd.nextInt(keyCnt); + + switch (rnd.nextInt(3)) { + case 0: + cache.put(key, String.valueOf(rnd.nextInt(valCnt))); + + keys.add(key); + + break; + + case 1: + cache.localEvict(Collections.singletonList(key)); + + break; + + case 2: + if (keys.contains(key)) { + String val = cache.get(key); + + assertNotNull(val); + } + + break; + + default: + assert false; + } + } + } + }, threadCnt, "update-thread"); + + IgniteInternalFuture<?> getFut = GridTestUtils.runAsync(new Callable<Void>() { + @Override public Void call() throws Exception { + Thread.currentThread().setName("get-thread"); + + while (!done.get()) { + for (Integer key : keys) { + String val = cache.get(key); + + assertNotNull(val); + } + } + + return null; + } + }); + + Thread.sleep(DURATION); + + done.set(true); + + fut.get(); + getFut.get(); + } + finally { + done.set(true); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/32c7805c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index f8ef097..88977fb 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeDynam import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeDynamicStartTxTest; import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartAtomicTest; import org.apache.ignite.internal.processors.cache.CacheStoreUsageMultinodeStaticStartTxTest; +import org.apache.ignite.internal.processors.cache.CacheSwapUnswapGetTest; import org.apache.ignite.internal.processors.cache.GridCacheMarshallingNodeJoinSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicNearEnabledSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheMultinodeUpdateAtomicSelfTest; @@ -256,6 +257,8 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(CacheVersionedEntryReplicatedAtomicOffHeapSelfTest.class); suite.addTestSuite(CacheVersionedEntryReplicatedTransactionalOffHeapSelfTest.class); + suite.addTestSuite(CacheSwapUnswapGetTest.class); + return suite; } } \ No newline at end of file
