You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/02/17 14:27:50 UTC

[GitHub] [ignite] NSAmelchev commented on a change in pull request #7428: IGNITE-11147 Re-balance cancellation occur by non-affected event

NSAmelchev commented on a change in pull request #7428: IGNITE-11147 Re-balance cancellation occur by non-affected event
URL: https://github.com/apache/ignite/pull/7428#discussion_r380212110
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1587,6 +1627,62 @@ private void sendRebalanceFinishedEvent() {
                 rebalanceEvent(EVT_CACHE_REBALANCE_STOPPED, exchId.discoveryEvent());
         }
 
+        /**
+         * @param otherAssignments Newest assigmnets.
+         *
+         * @return {@code True} when future compared with other, {@False} otherwise.
+         */
+        public boolean compatibleWith(GridDhtPreloaderAssignments otherAssignments) {
+            if (isInitial())
+                return false;
+
+            if (topVer.equals(otherAssignments.topologyVersion())) {
+                if (log.isDebugEnabled())
+                    log.debug("Rebalancing is forced on the same topology [grp="
+                        + grp.cacheOrGroupName() + ", " + "top=" + topVer + ']');
+
+                return false;
+            }
+
+            Set<Integer> p0 = new HashSet<>();
+            Set<Integer> p1 = new HashSet<>();
+
+            // Not compatible if a supplier has left.
+            for (ClusterNode node : rebalancingParts.keySet()) {
+                if (!grp.cacheObjectContext().kernalContext().discovery().alive(node))
+                    return false;
+            }
+
+            for (Set<Integer> partitions : rebalancingParts.values())
+                p0.addAll(partitions);
+
+            for (GridDhtPartitionDemandMessage message : otherAssignments.values()) {
+                p1.addAll(message.partitions().fullSet());
+                p1.addAll(message.partitions().historicalSet());
+            }
+
+            // Not compatible if not a subset.
+            if (!p0.containsAll(p1))
+                return false;
+
+            AffinityTopologyVersion previousTopVer =
+                grp.affinity().cachedVersions().stream().skip(grp.affinity().cachedVersions().size() - 2).findFirst().get();
+
+            p0 = Stream.concat(grp.affinity().cachedAffinity(previousTopVer).primaryPartitions(ctx.localNodeId()).stream(),
+                grp.affinity().cachedAffinity(previousTopVer).backupPartitions(ctx.localNodeId()).stream())
+                .collect(Collectors.toSet());
+
+            p1 = Stream.concat(grp.affinity().cachedAffinity(otherAssignments.topologyVersion()).primaryPartitions(ctx.localNodeId()).stream(),
 
 Review comment:
   Too long line

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services