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/14 12:19:16 UTC

[GitHub] [ignite] vldpyatkov opened a new pull request #7428: IGNITE-11147 Re-balance cancellation occur by non-affected event

vldpyatkov opened a new pull request #7428: IGNITE-11147 Re-balance cancellation occur by non-affected event
URL: https://github.com/apache/ignite/pull/7428
 
 
   

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
Mmuzaf 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_r380236227
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1309,9 +1335,29 @@ private void updateGroupMetrics() {
             this.rebalanceId = -1;
             this.routines = 0;
             this.cancelLock = new ReentrantReadWriteLock();
+            this.next = null;
             this.lastCancelledTime = new AtomicLong();
         }
 
+        /**
+         * Init future.
+         */
+        public void init() {
+            requestPartitions(this, assignments);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) {
+            if (super.onDone(res, err)) {
+                if (next != null)
 
 Review comment:
   Is it true that the `next` will start regardless the current RebalanceFuture finishes with an error or cancelled e.g. on stop() method called? Is it correct?

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380525017
 
 

 ##########
 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:
   Done

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
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_r380217495
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1276,6 +1295,11 @@ private void updateGroupMetrics() {
 
                 partitionsLeft.addAndGet(v.partitions().size());
 
+                rebalancingParts.put(k, new HashSet<Integer>() {{
 
 Review comment:
   Can initial capacity be set?

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380153229
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
 ##########
 @@ -3484,6 +3462,31 @@ else if (r != null) {
                 }
             }
         }
+
+        /**
+         * Rebalance is not required on client node and always required when exchange future is null.
+         * In other cases the method checks all caches and decides required rebalance or not for specific exchange.
 
 Review comment:
   I suggest to correct this description as follows:
   
   Rebalancing is not required on the client node and is always required when the exchange future is null. In other cases,
   this method checks all caches and decides whether rebalancing is required or not for a specific exchange.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380156227
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -289,16 +280,19 @@ void onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut) {
      * @param assignments Assignments to process.
      * @param force {@code True} if preload request by {@link ForceRebalanceExchangeTask}.
      * @param rebalanceId Rebalance id generated from exchange thread.
-     * @param next Runnable responsible for cache rebalancing chain.
+     * @param next That is next rebalance future wich will be executed after this rebalance.
 
 Review comment:
   wich -> which. but I suggest changing the description to something like:
   
   The subsequent rebalancing routine, which will be launched after the completion of the current rebalance.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
Mmuzaf 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_r380614536
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1309,9 +1334,29 @@ private void updateGroupMetrics() {
             this.rebalanceId = -1;
             this.routines = 0;
             this.cancelLock = new ReentrantReadWriteLock();
+            this.next = null;
             this.lastCancelledTime = new AtomicLong();
         }
 
+        /**
+         * Init future.
+         */
+        public void init() {
 
 Review comment:
   Let's rename it to `start`

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380154343
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateManager.java
 ##########
 @@ -466,78 +467,64 @@ else if (!grp.localWalEnabled())
         for (Integer grpId : grpsToEnableWal)
             cctx.cache().cacheGroup(grpId).localWalEnabled(true, true);
 
-        for (Integer grpId : grpsToDisableWal)
-            cctx.cache().cacheGroup(grpId).localWalEnabled(false, true);
+        tmpDisabledWal.disable(grpsToDisableWal);
     }
 
     /**
      * Callback when group rebalancing is finished. If there are no pending groups, it should trigger checkpoint and
      * change partition states.
      * @param grpId Group ID.
-     * @param topVer Topology version.
      */
-    public void onGroupRebalanceFinished(int grpId, AffinityTopologyVersion topVer) {
-        TemporaryDisabledWal session0 = tmpDisabledWal;
+    public void onGroupRebalanceFinished(int grpId) {
+        Set<Integer> groupsToEnable = tmpDisabledWal.enable(grpId);
 
-        if (session0 == null || session0.topVer.compareTo(topVer) > 0)
+        if (F.isEmpty(groupsToEnable))
             return;
 
-        session0.remainingGrps.remove(grpId);
-
-        if (session0.remainingGrps.isEmpty()) {
-            synchronized (mux) {
-                if (tmpDisabledWal != session0)
-                    return;
-
-                for (Integer grpId0 : session0.disabledGrps) {
-                    CacheGroupContext grp = cctx.cache().cacheGroup(grpId0);
-
-                    assert grp != null;
-
-                    if (!grp.localWalEnabled())
-                        grp.localWalEnabled(true, false);
-                }
+        grpId = groupsToEnable.stream().findFirst().get();
 
 Review comment:
   can be replaced with
   `grpId = F.first(groupsToEnable);`

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380159967
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
 ##########
 @@ -87,13 +87,15 @@
      * @param rebalanceId Rebalance id created by exchange thread.
      * @param next Runnable responsible for cache rebalancing chain.
 
 Review comment:
   old parameter description - is it ok?

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380222193
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
 ##########
 @@ -2708,23 +2690,30 @@ private void removeNode(UUID nodeId) {
     @Override public void ownMoving(AffinityTopologyVersion rebFinishedTopVer) {
         lock.writeLock().lock();
 
-        AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
+        try {
+            AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
 
-        if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0)
-            log.info("Affinity topology changed, no MOVING partitions will be owned " +
-                "[rebFinishedTopVer=" + rebFinishedTopVer +
-                ", lastAffChangeVer=" + lastAffChangeVer + "]");
+            if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0) {
+                if (log.isInfoEnabled()) {
+                    log.info("Affinity topology changed, no MOVING partitions will be owned " +
+                        "[rebFinishedTopVer=" + rebFinishedTopVer +
+                        ", lastAffChangeVer=" + lastAffChangeVer + "]");
+                }
 
-        try {
-            for (GridDhtLocalPartition locPart : grp.topology().currentLocalPartitions()) {
+                grp.preloader().forceRebalance();
 
 Review comment:
   I suggest that will be a temporary solution.
   Until we haven't implement the issue

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380525354
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheAffinityVersionTask.java
 ##########
 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Task retrieves a affinity topology version for cache.
+ */
+public class PlatformCacheAffinityVersionTask extends ComputeTaskAdapter<String, Object> {
+    /** {@inheritDoc} */
+    @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+        String arg) throws IgniteException {
+        return Collections.singletonMap(new Job(arg), subgrid.stream().filter(ClusterNode::isLocal).findFirst().get());
 
 Review comment:
   Is will look more complicated:
   F.find(subgrid, null, new IgnitePredicate<ClusterNode>() {
               @Override public boolean apply(ClusterNode node) {
                   return node.isLocal();
               }
           })

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380528905
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1309,9 +1335,29 @@ private void updateGroupMetrics() {
             this.rebalanceId = -1;
             this.routines = 0;
             this.cancelLock = new ReentrantReadWriteLock();
+            this.next = null;
             this.lastCancelledTime = new AtomicLong();
         }
 
+        /**
+         * Init future.
+         */
+        public void init() {
+            requestPartitions(this, assignments);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) {
+            if (super.onDone(res, err)) {
+                if (next != null)
 
 Review comment:
   I think yes. All rebalance's futures are executed independently of other.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380547091
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheAffinityVersionTask.java
 ##########
 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Task retrieves a affinity topology version for cache.
+ */
+public class PlatformCacheAffinityVersionTask extends ComputeTaskAdapter<String, Object> {
+    /** {@inheritDoc} */
+    @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+        String arg) throws IgniteException {
+        return Collections.singletonMap(new Job(arg), subgrid.stream().filter(ClusterNode::isLocal).findFirst().get());
 
 Review comment:
   Unfortunately not. Because we have a method with another predicate here.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380153699
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/WalStateManager.java
 ##########
 @@ -393,12 +394,19 @@ else if (!F.eq(grpDesc.deploymentId(), curGrpDesc.deploymentId())) {
      * @param topVer Topology version.
      * @param changedBaseline The exchange is caused by Baseline Topology change.
 
 Review comment:
   should be replaced with exchFut parameter

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380533127
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheAffinityVersionTask.java
 ##########
 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Task retrieves a affinity topology version for cache.
+ */
+public class PlatformCacheAffinityVersionTask extends ComputeTaskAdapter<String, Object> {
+    /** {@inheritDoc} */
+    @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+        String arg) throws IgniteException {
+        return Collections.singletonMap(new Job(arg), subgrid.stream().filter(ClusterNode::isLocal).findFirst().get());
 
 Review comment:
   I found a way to fix it
   F.find(subgrid, null, (IgnitePredicate<? super ClusterNode>)ClusterNode::isLocal)

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
ascherbakoff 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_r380180398
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
 ##########
 @@ -87,13 +87,15 @@
      * @param rebalanceId Rebalance id created by exchange thread.
      * @param next Runnable responsible for cache rebalancing chain.
      * @param forcedRebFut External future for forced rebalance.
+     * @param compatibleRebFut Future for waiting for compatible rebalances.
      * @return Rebalancing runnable.
 
 Review comment:
   Actually returns rebalance future, not runnable.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380156227
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -289,16 +280,19 @@ void onTopologyChanged(GridDhtPartitionsExchangeFuture lastFut) {
      * @param assignments Assignments to process.
      * @param force {@code True} if preload request by {@link ForceRebalanceExchangeTask}.
      * @param rebalanceId Rebalance id generated from exchange thread.
-     * @param next Runnable responsible for cache rebalancing chain.
+     * @param next That is next rebalance future wich will be executed after this rebalance.
 
 Review comment:
   I suggest changing the description to something like:
   
   The subsequent rebalancing routine, which will be launched after the completion of the current rebalance.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
ascherbakoff 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_r380184729
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
 ##########
 @@ -2708,23 +2690,30 @@ private void removeNode(UUID nodeId) {
     @Override public void ownMoving(AffinityTopologyVersion rebFinishedTopVer) {
         lock.writeLock().lock();
 
-        AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
+        try {
+            AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
 
-        if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0)
-            log.info("Affinity topology changed, no MOVING partitions will be owned " +
-                "[rebFinishedTopVer=" + rebFinishedTopVer +
-                ", lastAffChangeVer=" + lastAffChangeVer + "]");
+            if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0) {
+                if (log.isInfoEnabled()) {
+                    log.info("Affinity topology changed, no MOVING partitions will be owned " +
+                        "[rebFinishedTopVer=" + rebFinishedTopVer +
+                        ", lastAffChangeVer=" + lastAffChangeVer + "]");
+                }
 
-        try {
-            for (GridDhtLocalPartition locPart : grp.topology().currentLocalPartitions()) {
+                grp.preloader().forceRebalance();
 
 Review comment:
   This is poor solution because it breaks rebalancing compatibility optimization.
   We should always own partitions if topology changes are compatible.
   Also we need explicit test for this scenario.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
ascherbakoff 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_r380180967
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -310,21 +304,60 @@ Runnable addAssignments(
         if ((delay == 0 || force) && assignments != null) {
             final RebalanceFuture oldFut = rebalanceFut;
 
-            final RebalanceFuture fut = new RebalanceFuture(grp, assignments, log, rebalanceId, lastCancelledTime);
+            if (assignments.cancelled()) { // Pending exchange.
+                if (log.isDebugEnabled())
+                    log.debug("Rebalancing skipped due to cancelled assignments.");
 
-            if (!grp.localWalEnabled())
+                return null;
+            }
+
+            if (assignments.isEmpty()) { // Nothing to rebalance.
+                if (log.isDebugEnabled())
+                    log.debug("Rebalancing skipped due to empty assignments.");
+
+                if (oldFut.isInitial())
+                    oldFut.onDone(true);
+
+                ((GridFutureAdapter)grp.preloader().syncFuture()).onDone();
+
+                ctx.exchange().scheduleResendPartitions();
+
+                return null;
+            }
+
+            if (!force && (!oldFut.isDone() || oldFut.result()) && oldFut.compatibleWith(assignments)) {
+                if (!oldFut.isDone())
+                    compatibleRebFut.add(oldFut);
+
+                return null;
+            }
+
+            final RebalanceFuture fut = new RebalanceFuture(grp, assignments, log, rebalanceId, next, lastCancelledTime);
+
+            if (!grp.localWalEnabled()) {
                 fut.listen(new IgniteInClosureX<IgniteInternalFuture<Boolean>>() {
                     @Override public void applyx(IgniteInternalFuture<Boolean> future) throws IgniteCheckedException {
                         if (future.get())
-                            ctx.walState().onGroupRebalanceFinished(grp.groupId(), assignments.topologyVersion());
+                            ctx.walState().onGroupRebalanceFinished(grp.groupId());
                     }
                 });
+            }
 
             if (!oldFut.isInitial())
                 oldFut.cancel();
             else
                 fut.listen(f -> oldFut.onDone(f.result()));
 
+            // Make sure partitions sceduled for full rebalancing are first cleared.
 
 Review comment:
   typo - scheduled

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380152858
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1248,10 +1251,22 @@ private void updateGroupMetrics() {
         /** Rebalancing last cancelled time. */
         private final AtomicLong lastCancelledTime;
 
+        /** Next future in chain. */
+        private final RebalanceFuture next;
+
+        /** Assigment. */
+        private final GridDhtPreloaderAssignments assignments;
+
+        /** Partitions which have been scheduled for rebalance from specific supplier. */
+        private final Map<ClusterNode, Set<Integer>> rebalancingParts;
+
         /**
          * @param grp Cache group.
          * @param assignments Assignments.
          * @param log Logger.
+         * @param rebalanceId Rebalance id.
+         * @param next Next rebalance future.
+         * @param lastCancelledTime Cancelled time.
          *
             @param rebalanceId Rebalance id.
 
 Review comment:
   duplicate parameter description

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
Mmuzaf 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_r380577605
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -1309,9 +1335,29 @@ private void updateGroupMetrics() {
             this.rebalanceId = -1;
             this.routines = 0;
             this.cancelLock = new ReentrantReadWriteLock();
+            this.next = null;
             this.lastCancelledTime = new AtomicLong();
         }
 
+        /**
+         * Init future.
+         */
+        public void init() {
+            requestPartitions(this, assignments);
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) {
+            if (super.onDone(res, err)) {
+                if (next != null)
 
 Review comment:
   It is OK that rebalance futures are independent, but it's strange when the current future has cancelled, but the next cache group starts nevertheless. We should:
   1. cancel the whole chain since we are building one 
   2. use an external arbiter (an executor service) for such tasks.
   
   Please also note that parallel rebalancing of cache groups will flood the whole cluster an can lead to the cluster death.

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380222193
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
 ##########
 @@ -2708,23 +2690,30 @@ private void removeNode(UUID nodeId) {
     @Override public void ownMoving(AffinityTopologyVersion rebFinishedTopVer) {
         lock.writeLock().lock();
 
-        AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
+        try {
+            AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
 
-        if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0)
-            log.info("Affinity topology changed, no MOVING partitions will be owned " +
-                "[rebFinishedTopVer=" + rebFinishedTopVer +
-                ", lastAffChangeVer=" + lastAffChangeVer + "]");
+            if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0) {
+                if (log.isInfoEnabled()) {
+                    log.info("Affinity topology changed, no MOVING partitions will be owned " +
+                        "[rebFinishedTopVer=" + rebFinishedTopVer +
+                        ", lastAffChangeVer=" + lastAffChangeVer + "]");
+                }
 
-        try {
-            for (GridDhtLocalPartition locPart : grp.topology().currentLocalPartitions()) {
+                grp.preloader().forceRebalance();
 
 Review comment:
   I suggest that will be a temporary solution.
   Until we haven't implement the issue
   https://ggsystems.atlassian.net/browse/GG-27642

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380158241
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
 ##########
 @@ -310,21 +304,60 @@ Runnable addAssignments(
         if ((delay == 0 || force) && assignments != null) {
             final RebalanceFuture oldFut = rebalanceFut;
 
-            final RebalanceFuture fut = new RebalanceFuture(grp, assignments, log, rebalanceId, lastCancelledTime);
+            if (assignments.cancelled()) { // Pending exchange.
+                if (log.isDebugEnabled())
+                    log.debug("Rebalancing skipped due to cancelled assignments.");
 
-            if (!grp.localWalEnabled())
+                return null;
+            }
+
+            if (assignments.isEmpty()) { // Nothing to rebalance.
+                if (log.isDebugEnabled())
+                    log.debug("Rebalancing skipped due to empty assignments.");
+
+                if (oldFut.isInitial())
+                    oldFut.onDone(true);
+
+                ((GridFutureAdapter)grp.preloader().syncFuture()).onDone();
+
+                ctx.exchange().scheduleResendPartitions();
+
+                return null;
+            }
+
+            if (!force && (!oldFut.isDone() || oldFut.result()) && oldFut.compatibleWith(assignments)) {
+                if (!oldFut.isDone())
+                    compatibleRebFut.add(oldFut);
+
+                return null;
+            }
+
+            final RebalanceFuture fut = new RebalanceFuture(grp, assignments, log, rebalanceId, next, lastCancelledTime);
+
+            if (!grp.localWalEnabled()) {
                 fut.listen(new IgniteInClosureX<IgniteInternalFuture<Boolean>>() {
                     @Override public void applyx(IgniteInternalFuture<Boolean> future) throws IgniteCheckedException {
                         if (future.get())
-                            ctx.walState().onGroupRebalanceFinished(grp.groupId(), assignments.topologyVersion());
+                            ctx.walState().onGroupRebalanceFinished(grp.groupId());
                     }
                 });
+            }
 
             if (!oldFut.isInitial())
                 oldFut.cancel();
             else
                 fut.listen(f -> oldFut.onDone(f.result()));
 
+            // Make sure partitions sceduled for full rebalancing are first cleared.
+            for (Map.Entry<ClusterNode, GridDhtPartitionDemandMessage> e : assignments.entrySet()) {
+                for (Integer partId: e.getValue().partitions().fullSet()) {
 
 Review comment:
   missed space after partId

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
vldpyatkov 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_r380222193
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
 ##########
 @@ -2708,23 +2690,30 @@ private void removeNode(UUID nodeId) {
     @Override public void ownMoving(AffinityTopologyVersion rebFinishedTopVer) {
         lock.writeLock().lock();
 
-        AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
+        try {
+            AffinityTopologyVersion lastAffChangeVer = ctx.exchange().lastAffinityChangedTopologyVersion(lastTopChangeVer);
 
-        if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0)
-            log.info("Affinity topology changed, no MOVING partitions will be owned " +
-                "[rebFinishedTopVer=" + rebFinishedTopVer +
-                ", lastAffChangeVer=" + lastAffChangeVer + "]");
+            if (lastAffChangeVer.compareTo(rebFinishedTopVer) > 0) {
+                if (log.isInfoEnabled()) {
+                    log.info("Affinity topology changed, no MOVING partitions will be owned " +
+                        "[rebFinishedTopVer=" + rebFinishedTopVer +
+                        ", lastAffChangeVer=" + lastAffChangeVer + "]");
+                }
 
-        try {
-            for (GridDhtLocalPartition locPart : grp.topology().currentLocalPartitions()) {
+                grp.preloader().forceRebalance();
 
 Review comment:
   I suggest that will be a temporary solution.
   Until we haven't implement the issue
   https://issues.apache.org/jira/browse/IGNITE-12689

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
xtern 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_r380159967
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
 ##########
 @@ -87,13 +87,15 @@
      * @param rebalanceId Rebalance id created by exchange thread.
      * @param next Runnable responsible for cache rebalancing chain.
 
 Review comment:
   old description

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
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_r380540015
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheAffinityVersionTask.java
 ##########
 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Task retrieves a affinity topology version for cache.
+ */
+public class PlatformCacheAffinityVersionTask extends ComputeTaskAdapter<String, Object> {
+    /** {@inheritDoc} */
+    @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+        String arg) throws IgniteException {
+        return Collections.singletonMap(new Job(arg), subgrid.stream().filter(ClusterNode::isLocal).findFirst().get());
 
 Review comment:
   It seems there is another option without cast: `F.find(subgrid, null, ClusterNode::isLocal)` 

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
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_r380215973
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheAffinityVersionTask.java
 ##########
 @@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.resources.IgniteInstanceResource;
+
+/**
+ * Task retrieves a affinity topology version for cache.
+ */
+public class PlatformCacheAffinityVersionTask extends ComputeTaskAdapter<String, Object> {
+    /** {@inheritDoc} */
+    @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+        String arg) throws IgniteException {
+        return Collections.singletonMap(new Job(arg), subgrid.stream().filter(ClusterNode::isLocal).findFirst().get());
 
 Review comment:
   `F#find` can be used here

----------------------------------------------------------------
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