ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: #ignite-784: fix after review.
Date Thu, 23 Apr 2015 09:11:35 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-784 b0a32a1b6 -> 228d16d4b


#ignite-784: fix after review.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c718fad4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c718fad4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c718fad4

Branch: refs/heads/ignite-784
Commit: c718fad4bcaf49a217afb92e35ef857565422372
Parents: 933b3dc
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Thu Apr 23 12:09:08 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Thu Apr 23 12:09:08 2015 +0300

----------------------------------------------------------------------
 .../dht/GridPartitionedGetFuture.java            | 14 +++++++++-----
 .../dht/colocated/GridDhtColocatedCache.java     | 18 +++++++++---------
 .../colocated/GridDhtColocatedLockFuture.java    |  8 ++++++--
 .../distributed/near/GridNearCacheEntry.java     | 12 ++++++------
 .../distributed/near/GridNearGetFuture.java      | 19 +++++++------------
 .../distributed/near/GridNearLockFuture.java     |  8 ++++++--
 .../near/GridNearTransactionalCache.java         |  3 +--
 7 files changed, 44 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index efeaca6..d675996 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -419,6 +419,15 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M
             GridCacheEntryEx entry = null;
 
             try {
+                ClusterNode node = cctx.affinity().primary(key, topVer);
+
+                if (node == null) {
+                    onDone(new ClusterTopologyServerNotFoundException("Failed to map keys
for cache " +
+                        "(all partition nodes left the grid)."));
+
+                    return false;
+                }
+
                 if (!reload && allowLocRead) {
                     try {
                         entry = colocated.context().isSwapOrOffheapEnabled() ? colocated.entryEx(key)
:
@@ -460,11 +469,6 @@ public class GridPartitionedGetFuture<K, V> extends GridCompoundIdentityFuture<M
                     }
                 }
 
-                ClusterNode node = cctx.affinity().primary(key, topVer);
-
-                if (node == null)
-                    onDone(new ClusterTopologyCheckedException("Cannot find primary node
for key " + key + "."));
-
                 remote = !node.isLocal();
 
                 LinkedHashMap<KeyCacheObject, Boolean> keys = mapped.get(node);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 8ad6fd8..1fbdb50 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -411,6 +411,13 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
 
                     assert topVer.compareTo(AffinityTopologyVersion.ZERO) > 0;
 
+                    // Send request to remove from remote nodes.
+                    ClusterNode primary = ctx.affinity().primary(key, topVer);
+
+                    if (primary == null)
+                        new ClusterTopologyServerNotFoundException("Failed to map keys for
cache " +
+                            "(all partition nodes left the grid).");
+
                     if (map == null) {
                         Collection<ClusterNode> affNodes = CU.allNodes(ctx, topVer);
 
@@ -422,13 +429,6 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                     if (ver == null)
                         ver = lock.version();
 
-                    // Send request to remove from remote nodes.
-                    ClusterNode primary = ctx.affinity().primary(key, topVer);
-
-                    if (primary == null)
-                        throw new ClusterTopologyCheckedException("Failed to unlock key "
+ key +
-                            ". Cannot find primary node for the key.");
-
                     if (!lock.reentry()) {
                         if (!ver.equals(lock.version()))
                             throw new IgniteCheckedException("Failed to unlock (if keys were
locked separately, " +
@@ -529,8 +529,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
                     ClusterNode primary = ctx.affinity().primary(key, topVer);
 
                     if (primary == null) {
-                        log.debug("Failed to unlock key " + key +
-                            ". Cannot find primary node for the key.");
+                        if (log.isDebugEnabled())
+                            log.debug("Failed to map keys for cache (all partition nodes
left the grid).");
 
                         continue;
                     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index c75b341..66faac1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -1052,9 +1052,13 @@ public final class GridDhtColocatedLockFuture<K, V> extends GridCompoundIdentity
 
         ClusterNode primary = cctx.affinity().primary(key, topVer);
 
-        if (primary == null || cctx.discovery().node(primary.id()) == null)
+        if (primary == null)
+            new ClusterTopologyServerNotFoundException("Failed to map keys for cache " +
+                "(all partition nodes left the grid).");
+
+        if (cctx.discovery().node(primary.id()) == null)
             // If primary node left the grid before lock acquisition, fail the whole future.
-            throw newTopologyException(null, primary != null ? primary.id() : null);
+            throw newTopologyException(null, primary.id());
 
         if (inTx() && tx.groupLock() && !primary.isLocal())
             throw new IgniteCheckedException("Failed to start group lock transaction (local
node is not primary for " +

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
index 819024c..9e5cea6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
@@ -151,6 +151,11 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
 
                     try {
                         synchronized (this) {
+                            ClusterNode primaryNode = cctx.affinity().primary(key, topVer);
+
+                            if (primaryNode == null)
+                                return false;
+
                             checkObsolete();
 
                             if (isNew() || !valid(topVer)) {
@@ -168,12 +173,7 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
                                     }
                                 }
 
-                                ClusterNode primaryNode = cctx.affinity().primary(key, topVer);
-
-                                if (primaryNode == null)
-                                    return false;
-
-                                recordNodeId(cctx.affinity().primary(key, topVer).id(), topVer);
+                                recordNodeId(primaryNode.id(), topVer);
 
                                 dhtVer = e.isNew() || e.isDeleted() ? null : e.version();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 2ee7ef2..e13660f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -502,6 +502,13 @@ public final class GridNearGetFuture<K, V> extends GridCompoundIdentityFuture<Ma
                     if (primary == null)
                         primary = cctx.affinity().primary(key, topVer);
 
+                    if (primary == null) {
+                        onDone(new ClusterTopologyServerNotFoundException("Failed to map
keys for cache " +
+                            "(all partition nodes left the grid)."));
+
+                        return savedVers;
+                    }
+
                     GridNearCacheEntry nearEntry = allowLocRead ? near.peekExx(key) : null;
 
                     entry = nearEntry;
@@ -511,18 +518,6 @@ public final class GridNearGetFuture<K, V> extends GridCompoundIdentityFuture<Ma
 
                     savedVers.put(key, nearEntry == null ? null : nearEntry.dhtVersion());
 
-                    if (primary == null) {
-                        if (remapCnt.incrementAndGet() > MAX_REMAP_CNT) {
-                            onDone(new ClusterTopologyCheckedException("Failed to remap key
to a new node after " +
-                                MAX_REMAP_CNT + " attempts (key got remapped to the same
node) " +
-                                "[key=" + key + ", no primary node" + ", mappings=" + mapped
+ ']'));
-
-                            return savedVers;
-                        }
-
-                        break;
-                    }
-
                     LinkedHashMap<KeyCacheObject, Boolean> keys = mapped.get(primary);
 
                     if (keys != null && keys.containsKey(key)) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 08bc43a..baa41bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -1153,9 +1153,13 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B
 
         ClusterNode primary = cctx.affinity().primary(key, topVer);
 
-        if (primary == null || cctx.discovery().node(primary.id()) == null)
+        if (primary == null)
+            new ClusterTopologyServerNotFoundException("Failed to map keys for cache " +
+                "(all partition nodes left the grid).");
+
+        if (cctx.discovery().node(primary.id()) == null)
             // If primary node left the grid before lock acquisition, fail the whole future.
-            throw newTopologyException(null, primary != null ? primary.id() : null);
+            throw newTopologyException(null, primary.id());
 
         if (inTx() && tx.groupLock() && !primary.isLocal())
             throw new IgniteCheckedException("Failed to start group lock transaction (local
node is not primary for " +

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c718fad4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index 521c197..4d99755 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -633,8 +633,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K,
V>
 
                                 if (primary == null) {
                                     if (log.isDebugEnabled())
-                                        log.debug("Cannot remove lock for key " + key +
-                                            ". Cannot find primary node for the key " + key
+ ".");
+                                        log.debug("Failed to map keys for cache (all partition
nodes left the grid).");
 
                                     break;
                                 }


Mime
View raw message