ignite-2.0 - Properly handle DhtInvalidPartitionException in GridDhtGetFuture
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/04e0822e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/04e0822e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/04e0822e Branch: refs/heads/ignite-5024 Commit: 04e0822e686734626ede2d8cf1dd33e851ad9838 Parents: d5a2ca2 Author: Alexey Goncharuk <[email protected]> Authored: Fri Apr 21 14:48:00 2017 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Fri Apr 21 14:48:25 2017 +0300 ---------------------------------------------------------------------- .../cache/distributed/dht/GridDhtGetFuture.java | 37 ++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/04e0822e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java index 5fe0ef4..7bc17a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java @@ -291,27 +291,36 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col * @return {@code True} if mapped. */ private boolean map(KeyCacheObject key) { - GridDhtLocalPartition part = topVer.topologyVersion() > 0 ? - cache().topology().localPartition(cctx.affinity().partition(key), topVer, true) : - cache().topology().localPartition(key, false); + try { + GridDhtLocalPartition part = topVer.topologyVersion() > 0 ? + cache().topology().localPartition(cctx.affinity().partition(key), topVer, true) : + cache().topology().localPartition(key, false); - if (part == null) - return false; + if (part == null) + return false; - if (parts == null || !F.contains(parts, part.id())) { - // By reserving, we make sure that partition won't be unloaded while processed. - if (part.reserve()) { - parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1); + if (parts == null || !F.contains(parts, part.id())) { + // By reserving, we make sure that partition won't be unloaded while processed. + if (part.reserve()) { + parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1); - parts[parts.length - 1] = part.id(); + parts[parts.length - 1] = part.id(); - return true; + return true; + } + else + return false; } else - return false; + return true; + } + catch (GridDhtInvalidPartitionException e) { + if (log.isDebugEnabled()) + log.debug("Attempted to create a partition which does not belong to local node, will remap " + + "[key=" + key + ", part=" + e.partition() + ']'); + + return false; } - else - return true; } /**
