GG-9141 - More fixes for commented tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/77dc56cb Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/77dc56cb Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/77dc56cb Branch: refs/heads/ignite-1 Commit: 77dc56cb8543f673b118348a45f3afe884f32ffa Parents: 5e14612 Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Fri Dec 19 14:33:45 2014 -0800 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Fri Dec 19 14:33:45 2014 -0800 ---------------------------------------------------------------------- .../affinity/GridAffinityAssignmentCache.java | 1 - .../cache/GridCacheEvictionManager.java | 70 ++++++++++++-------- .../processors/cache/GridCacheTxHandler.java | 5 +- .../distributed/GridDistributedCacheEntry.java | 42 ------------ .../distributed/dht/GridDhtTxPrepareFuture.java | 6 ++ .../distributed/near/GridNearCacheEntry.java | 11 --- .../cache/distributed/near/GridNearTxLocal.java | 6 +- .../near/GridNearTxPrepareFuture.java | 4 +- .../GridCacheEvictionSelfTestSuite.java | 4 +- 9 files changed, 60 insertions(+), 89 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/affinity/GridAffinityAssignmentCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/affinity/GridAffinityAssignmentCache.java index 926f717..f42ddba 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/affinity/GridAffinityAssignmentCache.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/affinity/GridAffinityAssignmentCache.java @@ -14,7 +14,6 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.lang.*; import org.apache.ignite.portables.*; -import org.gridgain.grid.*; import org.gridgain.grid.cache.affinity.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.processors.cache.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionManager.java index e07211c..c61a037 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionManager.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionManager.java @@ -243,8 +243,13 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K, V if (plcEnabled && evictSync && !cctx.isNear()) { // Add dummy event to worker. - backupWorker.addEvent(new IgniteDiscoveryEvent(cctx.localNode(), "Dummy event.", - EVT_NODE_JOINED, cctx.localNode())); + ClusterNode locNode = cctx.localNode(); + + IgniteDiscoveryEvent evt = new IgniteDiscoveryEvent(locNode, "Dummy event.", EVT_NODE_JOINED, locNode); + + evt.topologySnapshot(locNode.order(), cctx.discovery().topology(locNode.order())); + + backupWorker.addEvent(evt); backupWorkerThread = new IgniteThread(backupWorker); backupWorkerThread.start(); @@ -1371,45 +1376,54 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K, V /** {@inheritDoc} */ @Override protected void body() throws InterruptedException, GridInterruptedException { - assert !cctx.isNear() && evictSync; + try { + assert !cctx.isNear() && evictSync; - ClusterNode loc = cctx.localNode(); + ClusterNode loc = cctx.localNode(); - // Initialize. - primaryParts.addAll(cctx.affinity().primaryPartitions(cctx.localNodeId(), - cctx.affinity().affinityTopologyVersion())); + // Initialize. + primaryParts.addAll(cctx.affinity().primaryPartitions(cctx.localNodeId(), + cctx.affinity().affinityTopologyVersion())); - while (!isCancelled()) { - IgniteDiscoveryEvent evt = evts.take(); + while (!isCancelled()) { + IgniteDiscoveryEvent evt = evts.take(); - if (log.isDebugEnabled()) - log.debug("Processing event: " + evt); - - // Remove partitions that are no longer primary. - for (Iterator<Integer> it = primaryParts.iterator(); it.hasNext();) { - if (!evts.isEmpty()) - break; + if (log.isDebugEnabled()) + log.debug("Processing event: " + evt); - if (!cctx.affinity().primary(loc, it.next(), evt.topologyVersion())) - it.remove(); - } + // Remove partitions that are no longer primary. + for (Iterator<Integer> it = primaryParts.iterator(); it.hasNext();) { + if (!evts.isEmpty()) + break; - // Move on to next event. - if (!evts.isEmpty()) - continue; + if (!cctx.affinity().primary(loc, it.next(), evt.topologyVersion())) + it.remove(); + } - for (GridDhtLocalPartition<K, V> part : cctx.topology().localPartitions()) { + // Move on to next event. if (!evts.isEmpty()) - break; + continue; - if (part.primary(evt.topologyVersion()) && primaryParts.add(part.id())) { - if (log.isDebugEnabled()) - log.debug("Touching partition entries: " + part); + for (GridDhtLocalPartition<K, V> part : cctx.topology().localPartitions()) { + if (!evts.isEmpty()) + break; - touchOnTopologyChange(part.entries()); + if (part.primary(evt.topologyVersion()) && primaryParts.add(part.id())) { + if (log.isDebugEnabled()) + log.debug("Touching partition entries: " + part); + + touchOnTopologyChange(part.entries()); + } } } } + catch (InterruptedException ignored) { + // No-op. + } + catch (IgniteException e) { + if (!e.hasCause(InterruptedException.class)) + throw e; + } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxHandler.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxHandler.java index 88def0e..abd7e78 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxHandler.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxHandler.java @@ -401,10 +401,13 @@ public class GridCacheTxHandler<K, V> { */ @Nullable public IgniteFuture<GridCacheTx> finish(UUID nodeId, @Nullable GridNearTxLocal<K, V> locTx, GridNearTxFinishRequest<K, V> req) { - assert locTx == null || locTx.nearLocallyMapped() || locTx.colocatedLocallyMapped(); assert nodeId != null; assert req != null; + // Transaction on local cache only. + if (locTx != null && !locTx.nearLocallyMapped() && !locTx.colocatedLocallyMapped()) + return new GridFinishedFutureEx<GridCacheTx>(locTx); + if (log.isDebugEnabled()) log.debug("Processing near tx finish request [nodeId=" + nodeId + ", req=" + req + "]"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedCacheEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedCacheEntry.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedCacheEntry.java index dade9ca..edab40b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedCacheEntry.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedCacheEntry.java @@ -445,48 +445,6 @@ public class GridDistributedCacheEntry<K, V> extends GridCacheMapEntry<K, V> { /** * - * @param cand Candidate to acquire lock for. - * @return Owner. - * @throws GridCacheEntryRemovedException If entry is removed. - */ - @Nullable public GridCacheMvccCandidate<K> readyLock( - GridCacheMvccCandidate<K> cand) throws GridCacheEntryRemovedException { - GridCacheMvccCandidate<K> prev = null; - GridCacheMvccCandidate<K> owner = null; - - V val; - - synchronized (this) { - checkObsolete(); - - GridCacheMvcc<K> mvcc = mvccExtras(); - - if (mvcc != null) { - prev = mvcc.anyOwner(); - - boolean emptyBefore = mvcc.isEmpty(); - - owner = mvcc.readyLocal(cand); - - boolean emptyAfter = mvcc.isEmpty(); - - checkCallbacks(emptyBefore, emptyAfter); - - if (emptyAfter) - mvccExtras(null); - } - - val = this.val; - } - - // This call must be made outside of synchronization. - checkOwnerChanged(prev, owner, val); - - return owner; - } - - /** - * * @param ver Version of candidate to acquire lock for. * @return Owner. * @throws GridCacheEntryRemovedException If entry is removed. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index 84c8f0f..21339b9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -324,6 +324,9 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu Collections.singletonList(tx.groupLockEntry()) : writes; for (GridCacheTxEntry<K, V> txEntry : checkEntries) { + if (txEntry.cached().isLocal()) + continue; + while (true) { GridDistributedCacheEntry<K, V> entry = (GridDistributedCacheEntry<K, V>)txEntry.cached(); @@ -757,6 +760,9 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu GridCacheTxEntry<K, V> entry, Map<UUID, GridDistributedTxMapping<K, V>> futDhtMap, Map<UUID, GridDistributedTxMapping<K, V>> futNearMap) { + if (entry.cached().isLocal()) + return false; + GridDhtCacheEntry<K, V> cached = (GridDhtCacheEntry<K, V>)entry.cached(); boolean ret; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java index 7759f49..40d20cb 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearCacheEntry.java @@ -521,17 +521,6 @@ public class GridNearCacheEntry<K, V> extends GridDistributedCacheEntry<K, V> { return cand; } - /** {@inheritDoc} */ - @Override public synchronized GridCacheMvccCandidate<K> readyLock(GridCacheMvccCandidate<K> cand) - throws GridCacheEntryRemovedException { - // Essentially no-op as locks are acquired on primary nodes. - checkObsolete(); - - GridCacheMvcc<K> mvcc = mvccExtras(); - - return mvcc == null ? null : mvcc.anyOwner(); - } - /** * Unlocks local lock. * http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxLocal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxLocal.java index df4dd58..9b0abdf 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxLocal.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxLocal.java @@ -536,13 +536,13 @@ public class GridNearTxLocal<K, V> extends GridDhtTxLocalAdapter<K, V> { for (GridCacheTxEntry<K, V> txEntry : entries) { while (true) { - GridDistributedCacheEntry<K, V> entry = (GridDistributedCacheEntry<K, V>)txEntry.cached(); - - GridCacheContext<K, V> cacheCtx = entry.context(); + GridCacheContext<K, V> cacheCtx = txEntry.cached().context(); if (!cacheCtx.isNear()) break; + GridDistributedCacheEntry<K, V> entry = (GridDistributedCacheEntry<K, V>)txEntry.cached(); + try { // Handle explicit locks. GridCacheVersion base = txEntry.explicitVersion() != null ? txEntry.explicitVersion() : xidVer; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java index 9098b73..9d07a54 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareFuture.java @@ -682,8 +682,10 @@ public final class GridNearTxPrepareFuture<K, V> extends GridCompoundIdentityFut // Must re-initialize cached entry while holding topology lock. if (cacheCtx.isNear()) entry.cached(cacheCtx.nearTx().entryExx(entry.key(), topVer), entry.keyBytes()); - else + else if (!cacheCtx.isLocal()) entry.cached(cacheCtx.colocated().entryExx(entry.key(), topVer, true), entry.keyBytes()); + else + entry.cached(cacheCtx.local().entryEx(entry.key(), topVer), entry.keyBytes()); if (cur == null || !cur.node().id().equals(primary.id()) || cur.near() != cacheCtx.isNear()) { cur = new GridDistributedTxMapping<>(primary); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77dc56cb/modules/core/src/test/java/org/gridgain/testsuites/GridCacheEvictionSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheEvictionSelfTestSuite.java b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheEvictionSelfTestSuite.java index 8b6ab21..3820919 100644 --- a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheEvictionSelfTestSuite.java +++ b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheEvictionSelfTestSuite.java @@ -43,8 +43,8 @@ public class GridCacheEvictionSelfTestSuite extends TestSuite { suite.addTest(new TestSuite(GridCacheEvictionLockUnlockSelfTest.class)); suite.addTest(new TestSuite(GridCacheBatchEvictUnswapSelfTest.class)); suite.addTest(new TestSuite(GridCachePreloadingEvictionsSelfTest.class)); -// suite.addTest(new TestSuite(GridCacheEmptyEntriesPartitionedSelfTest.class)); // TODO GG-9141 -// suite.addTest(new TestSuite(GridCacheEmptyEntriesLocalSelfTest.class)); // TODO GG-9141 + suite.addTest(new TestSuite(GridCacheEmptyEntriesPartitionedSelfTest.class)); + suite.addTest(new TestSuite(GridCacheEmptyEntriesLocalSelfTest.class)); suite.addTest(new TestSuite(GridCacheMemoryModeSelfTest.class)); // TODO: 5276. //suite.addTest(new TestSuite(GridCacheSynchronousEvictionsFailoverSelfTest.class));