ignite-5503 New compare topology versions for dhtPartMap comparison
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7603b0cd Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7603b0cd Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7603b0cd Branch: refs/heads/ignite-2.1.2-exchange Commit: 7603b0cd78b53b5c26c4e4f79eb8f0709681784d Parents: 44c723c Author: Pavel Kovalenko <[email protected]> Authored: Sat Jun 17 09:09:58 2017 +0300 Committer: sboikov <[email protected]> Committed: Sat Jun 17 09:09:58 2017 +0300 ---------------------------------------------------------------------- .../dht/GridClientPartitionTopology.java | 20 +++++++++++++++++--- .../dht/GridDhtPartitionTopologyImpl.java | 20 +++++++++++++++++--- .../dht/preloader/GridDhtPartitionMap.java | 4 ++-- .../CacheLateAffinityAssignmentTest.java | 2 -- 4 files changed, 36 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/7603b0cd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java index 7713caa..20b6296 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java @@ -688,6 +688,20 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology { } } + /** + * Method checks is new partition map more stale than current partition map + * New partition map is stale if topology version or update sequence are less than of current map + * + * @param currentMap Current partition map + * @param newMap New partition map + * @return True if new partition map is more stale than current partition map, false in other case + */ + private boolean isStaleUpdate(GridDhtPartitionMap currentMap, GridDhtPartitionMap newMap) { + return currentMap != null && + (newMap.topologyVersion().compareTo(currentMap.topologyVersion()) < 0 || + newMap.topologyVersion().compareTo(currentMap.topologyVersion()) == 0 && newMap.updateSequence() <= currentMap.updateSequence()); + } + /** {@inheritDoc} */ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) @Nullable @Override public GridDhtPartitionMap update( @@ -728,10 +742,10 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology { GridDhtPartitionMap cur = node2part.get(parts.nodeId()); - if (cur != null && cur.updateSequence() >= parts.updateSequence()) { + if (isStaleUpdate(cur, parts)) { if (log.isDebugEnabled()) - log.debug("Stale update sequence for single partition map update (will ignore) [exchId=" + exchId + - ", curSeq=" + cur.updateSequence() + ", newSeq=" + parts.updateSequence() + ']'); + log.debug("Stale update for single partition map update (will ignore) [exchId=" + exchId + + ", curMap=" + cur + ", newMap=" + parts + ']'); return null; } http://git-wip-us.apache.org/repos/asf/ignite/blob/7603b0cd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java index 3c626f0..53f7523 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java @@ -1314,6 +1314,20 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology { } } + /** + * Method checks is new partition map more stale than current partition map + * New partition map is stale if topology version or update sequence are less than of current map + * + * @param currentMap Current partition map + * @param newMap New partition map + * @return True if new partition map is more stale than current partition map, false in other case + */ + private boolean isStaleUpdate(GridDhtPartitionMap currentMap, GridDhtPartitionMap newMap) { + return currentMap != null && + (newMap.topologyVersion().compareTo(currentMap.topologyVersion()) < 0 || + newMap.topologyVersion().compareTo(currentMap.topologyVersion()) == 0 && newMap.updateSequence() <= currentMap.updateSequence()); + } + /** {@inheritDoc} */ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) @Nullable @Override public GridDhtPartitionMap update( @@ -1354,10 +1368,10 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology { GridDhtPartitionMap cur = node2part.get(parts.nodeId()); - if (cur != null && cur.updateSequence() >= parts.updateSequence()) { + if (isStaleUpdate(cur, parts)) { if (log.isDebugEnabled()) - log.debug("Stale update sequence for single partition map update (will ignore) [exchId=" + exchId + - ", curSeq=" + cur.updateSequence() + ", newSeq=" + parts.updateSequence() + ']'); + log.debug("Stale update for single partition map update (will ignore) [exchId=" + exchId + + ", curMap=" + cur + ", newMap=" + parts + ']'); return null; } http://git-wip-us.apache.org/repos/asf/ignite/blob/7603b0cd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java index fa253fc..0b44d3c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java @@ -313,11 +313,11 @@ public class GridDhtPartitionMap implements Comparable<GridDhtPartitionMap>, Ext * @return Full string representation. */ public String toFullString() { - return S.toString(GridDhtPartitionMap.class, this, "size", size(), "map", map.toString(), "top", top); + return S.toString(GridDhtPartitionMap.class, this, "top", top, "updateSeq", updateSeq, "size", size(), "map", map.toString()); } /** {@inheritDoc} */ @Override public String toString() { - return S.toString(GridDhtPartitionMap.class, this, "size", size()); + return S.toString(GridDhtPartitionMap.class, this, "top", top, "updateSeq", updateSeq, "size", size()); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7603b0cd/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 b1610d4..6fac920 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 @@ -514,8 +514,6 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { * @throws Exception If failed. */ private void cacheDestroyAndCreate(boolean cacheOnCrd) throws Exception { - fail("IGNITE-5503"); - if (!cacheOnCrd) cacheNodeFilter = new CacheNodeFilter(Collections.singletonList(getTestIgniteInstanceName(0)));
