Repository: incubator-ignite Updated Branches: refs/heads/ignite-784 a92ee30fa -> 933b3dca6
# ignite-784 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/933b3dca Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/933b3dca Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/933b3dca Branch: refs/heads/ignite-784 Commit: 933b3dca63ff3f8f0be5e1ec9d68eeccbd7cde17 Parents: a92ee30 Author: sboikov <sboi...@gridgain.com> Authored: Thu Apr 23 11:34:19 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Thu Apr 23 11:34:19 2015 +0300 ---------------------------------------------------------------------- .../cache/CacheServerNotFoundException.java | 12 ++++----- .../ClusterTopologyServerNotFoundException.java | 12 ++++----- .../processors/cache/GridCacheUtils.java | 6 ++--- .../dht/atomic/GridNearAtomicUpdateFuture.java | 28 +++++++++++++------- .../cache/query/GridCacheQueryManager.java | 7 ++--- 5 files changed, 37 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/933b3dca/modules/core/src/main/java/org/apache/ignite/cache/CacheServerNotFoundException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheServerNotFoundException.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheServerNotFoundException.java index 3c035d3..f5ccac7 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheServerNotFoundException.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheServerNotFoundException.java @@ -26,18 +26,18 @@ public class CacheServerNotFoundException extends CacheException { private static final long serialVersionUID = 0L; /** - * @param message Error message. + * @param msg Error message. */ - public CacheServerNotFoundException(String message) { - super(message); + public CacheServerNotFoundException(String msg) { + super(msg); } /** - * @param message Error message. + * @param msg Error message. * @param cause Error cause. */ - public CacheServerNotFoundException(String message, Throwable cause) { - super(message, cause); + public CacheServerNotFoundException(String msg, Throwable cause) { + super(msg, cause); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/933b3dca/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyServerNotFoundException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyServerNotFoundException.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyServerNotFoundException.java index 22bcad0..1812112 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyServerNotFoundException.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyServerNotFoundException.java @@ -24,17 +24,17 @@ public class ClusterTopologyServerNotFoundException extends ClusterTopologyCheck private static final long serialVersionUID = 0L; /** - * @param message Error message. + * @param msg Error message. */ - public ClusterTopologyServerNotFoundException(String message) { - super(message); + public ClusterTopologyServerNotFoundException(String msg) { + super(msg); } /** - * @param message Error message. + * @param msg Error message. * @param cause Exception cause. */ - public ClusterTopologyServerNotFoundException(String message, Throwable cause) { - super(message, cause); + public ClusterTopologyServerNotFoundException(String msg, Throwable cause) { + super(msg, cause); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/933b3dca/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java index 848cf17..f3556d8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java @@ -1178,7 +1178,7 @@ public class GridCacheUtils { * @return Primary node for the key. */ @SuppressWarnings( {"unchecked"}) - public static ClusterNode primaryNode(GridCacheContext ctx, Object key) { + @Nullable public static ClusterNode primaryNode(GridCacheContext ctx, Object key) { assert ctx != null; assert key != null; @@ -1187,9 +1187,7 @@ public class GridCacheUtils { if (cfg.getCacheMode() != PARTITIONED) return ctx.localNode(); - ClusterNode primary = ctx.affinity().primary(key, ctx.affinity().affinityTopologyVersion()); - - return primary; + return ctx.affinity().primary(key, ctx.affinity().affinityTopologyVersion()); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/933b3dca/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index f890a15..569fb73 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@ -550,15 +550,14 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object> if (op != TRANSFORM) val = cctx.toCacheObject(val); - Collection<ClusterNode> primaryNodes = mapKey(cacheKey, topVer, fastMap); + ClusterNode primary = cctx.affinity().primary(cacheKey, topVer); - // One key and no backups. - assert primaryNodes.size() == 1 : "Should be mapped to single node: " + primaryNodes; + if (primary == null) { + onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all partition nodes " + + "left the grid).")); - ClusterNode primary = F.first(primaryNodes); - - if (primary == null) - onDone(new ClusterTopologyCheckedException("Cannot find primary node for the key " + key + ".")); + return; + } GridNearAtomicUpdateRequest req = new GridNearAtomicUpdateRequest( cctx.cacheId(), @@ -674,11 +673,22 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object> Collection<ClusterNode> affNodes = mapKey(cacheKey, topVer, fastMap); + if (affNodes.isEmpty()) { + onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + + "(all partition nodes left the grid).")); + + return; + } + int i = 0; for (ClusterNode affNode : affNodes) { - if (affNode == null) - onDone(new ClusterTopologyCheckedException("Cannot find primary node for the key " + key + ".")); + if (affNode == null) { + onDone(new ClusterTopologyServerNotFoundException("Failed to map keys for cache " + + "(all partition nodes left the grid).")); + + return; + } UUID nodeId = affNode.id(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/933b3dca/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java index 2d422a1..3d7d9a0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java @@ -1300,9 +1300,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte if (log.isDebugEnabled()) { ClusterNode primaryNode = CU.primaryNode(cctx, key); - log.debug("Record [key=" + key + ", val=" + val + ", incBackups=" + - incBackups + - primaryNode != null ? "priNode=" + U.id8(primaryNode.id()) : "no primary node" + + log.debug("Record [key=" + key + + ", val=" + val + + ", incBackups=" + incBackups + + ", priNode=" + (primaryNode != null ? U.id8(primaryNode.id()) : null) + ", node=" + U.id8(cctx.localNode().id()) + ']'); }