ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [26/28] ignite git commit: IGNITE-2508: Further fixes.
Date Wed, 03 Feb 2016 12:28:21 GMT
IGNITE-2508: Further fixes.


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

Branch: refs/heads/ignite-2508
Commit: cf6974063abb7f602ae24258f7fea69be92a28a0
Parents: 04e705f
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Feb 3 15:23:07 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Feb 3 15:23:07 2016 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignment.java        | 23 +++++++++++---------
 .../affinity/GridAffinityAssignmentCache.java   |  3 +--
 .../cache/GridCacheAffinityManager.java         | 11 ++++++++++
 .../dht/GridDhtPartitionTopologyImpl.java       |  8 +++++--
 4 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
index ad37ad8..7b2bea3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
@@ -32,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
 /**
  * Cached affinity calculations.
  */
-class GridAffinityAssignment implements Serializable {
+public class GridAffinityAssignment implements Serializable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -122,24 +122,27 @@ class GridAffinityAssignment implements Serializable {
      * @return Affinity nodes IDs.
      */
     public HashSet<UUID> getIds(int part) {
-        List<HashSet<UUID>> ids = assignmentIds;
+        assert part >= 0 && part < assignment.size() : "Affinity partition
is out of range" +
+            " [part=" + part + ", partitions=" + assignment.size() + ']';
+
+        List<HashSet<UUID>> assignmentIds0 = assignmentIds;
 
-        if (ids == null) {
-            ids = new ArrayList<>();
+        if (assignmentIds0 == null) {
+            assignmentIds0 = new ArrayList<>();
 
-            for (List<ClusterNode> a : assignment) {
+            for (List<ClusterNode> assignmentPart : assignment) {
                 HashSet<UUID> partIds = new HashSet<>();
 
-                for (ClusterNode n : a)
-                    partIds.add(n.id());
+                for (ClusterNode node : assignmentPart)
+                    partIds.add(node.id());
 
-                ids.add(partIds);
+                assignmentIds0.add(partIds);
             }
 
-            assignmentIds = ids;
+            assignmentIds = assignmentIds0;
         }
 
-        return ids.get(part);
+        return assignmentIds0.get(part);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 0b09eea..836183d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -397,7 +397,6 @@ public class GridAffinityAssignmentCache {
      * @return Affinity nodes.
      */
     public HashSet<UUID> nodesIds(int part, AffinityTopologyVersion topVer) {
-        // Resolve cached affinity nodes.
         return cachedAffinity(topVer).getIds(part);
     }
 
@@ -441,7 +440,7 @@ public class GridAffinityAssignmentCache {
      * @param topVer Topology version.
      * @return Cached affinity.
      */
-    private GridAffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) {
+    public GridAffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) {
         if (topVer.equals(AffinityTopologyVersion.NONE))
             topVer = lastVersion();
         else

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index de0fa2d..54600ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -30,6 +30,7 @@ import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignment;
 import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
 import org.apache.ignite.internal.util.GridLeanSet;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -155,6 +156,16 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter
{
     }
 
     /**
+     * Get affinity assignment for the given topology version.
+     *
+     * @param topVer Toplogy version.
+     * @return Affinity affignment.
+     */
+    public GridAffinityAssignment assignment(AffinityTopologyVersion topVer) {
+        return aff.cachedAffinity(topVer);
+    }
+
+    /**
      * @param topVer Topology version.
      * @return Affinity assignments.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/cf697406/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 6e5e47f..d6fc8f1 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
@@ -36,6 +36,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignment;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
@@ -693,8 +694,9 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
 
     /** {@inheritDoc} */
     @Override public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer)
{
-        Collection<ClusterNode> affNodes = cctx.affinity().nodes(p, topVer);
-        HashSet<UUID> affIds = cctx.affinity().nodesIds(p, topVer);
+        GridAffinityAssignment affAssignment = cctx.affinity().assignment(topVer);
+
+        Collection<ClusterNode> affNodes = affAssignment.get(p);
 
         lock.readLock().lock();
 
@@ -710,6 +712,8 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
 
             if (!F.isEmpty(nodeIds)) {
                 for (UUID nodeId : nodeIds) {
+                    HashSet<UUID> affIds = affAssignment.getIds(p);
+
                     if (!affIds.contains(nodeId) && hasState(p, nodeId, OWNING, MOVING,
RENTING)) {
                         ClusterNode n = cctx.discovery().node(nodeId);
 


Mime
View raw message