Repository: ignite Updated Branches: refs/heads/ignite-2523-remap-issue [created] 2c88d7337
Fixing potential remap problem. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2c88d733 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2c88d733 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2c88d733 Branch: refs/heads/ignite-2523-remap-issue Commit: 2c88d7337367168556e69da2cd2c952b3d0f0bfa Parents: 97cf2b3 Author: vozerov-gridgain <[email protected]> Authored: Mon Apr 25 12:57:32 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Mon Apr 25 12:57:32 2016 +0300 ---------------------------------------------------------------------- .../GridNearAtomicSingleUpdateFuture.java | 27 +++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2c88d733/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java index abfc5c9..0b684b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java @@ -42,6 +42,7 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; import org.jetbrains.annotations.Nullable; import javax.cache.expiry.ExpiryPolicy; @@ -69,6 +70,9 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda /** Not null is operation is mapped to single node. */ private GridNearAtomicUpdateRequest req; + /** Keys to remap. */ + private Collection<KeyCacheObject> remapKeys; + /** * @param cctx Cache context. * @param cache Cache instance. @@ -212,9 +216,12 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda this.req = null; - boolean remapKey = !F.isEmpty(res.remapKeys()); + if (res.remapKeys() != null) { + if (remapKeys == null) + remapKeys = U.newHashSet(res.remapKeys().size()); + + remapKeys.addAll(res.remapKeys()); - if (remapKey) { if (mapErrTopVer == null || mapErrTopVer.compareTo(req.topologyVersion()) < 0) mapErrTopVer = req.topologyVersion(); } @@ -253,7 +260,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda } } - if (remapKey) { + if (remapKeys != null) { assert mapErrTopVer != null; remapTopVer = cctx.shared().exchange().topologyVersion(); @@ -277,6 +284,14 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda new AffinityTopologyVersion(cause.topologyVersion().topologyVersion() + 1); err = null; + + Collection<Object> failedKeys = cause.failedKeys(); + + remapKeys = new ArrayList<>(failedKeys.size()); + + for (Object key : failedKeys) + remapKeys.add(cctx.toCacheKeyObject(key)); + updVer = null; } } @@ -318,6 +333,8 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda } if (topLocked) { + assert !F.isEmpty(remapKeys) : remapKeys; + CachePartialUpdateCheckedException e = new CachePartialUpdateCheckedException("Failed to update keys (retry update if possible)."); @@ -326,7 +343,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda cause.retryReadyFuture(cctx.affinity().affinityReadyFuture(remapTopVer)); - e.add(Collections.singleton(cctx.toCacheKeyObject(key)), cause); + e.add(remapKeys, cause); onDone(e); @@ -527,6 +544,8 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda resCnt = 0; req = singleReq0; + + this.remapKeys = null; } } catch (Exception e) {
