This is an automated email from the ASF dual-hosted git repository.

namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 1987b707c1b IGNITE-23584 Refactored snapshot quick verify handler. 
(#11632)
1987b707c1b is described below

commit 1987b707c1b8c30cc7e04504f48412ec214ec77f
Author: Vladimir Steshin <[email protected]>
AuthorDate: Fri Nov 1 11:12:27 2024 +0300

    IGNITE-23584 Refactored snapshot quick verify handler. (#11632)
---
 .../SnapshotPartitionsQuickVerifyHandler.java      | 27 ++++++++--------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
index cce4e5d3057..652aac3cada 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
@@ -28,6 +28,7 @@ import 
org.apache.ignite.internal.management.cache.PartitionKeyV2;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import 
org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2;
 import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
  * Quick partitions verifier. Warns if partiton counters or size are different 
among the nodes what can be caused by
@@ -70,25 +71,20 @@ public class SnapshotPartitionsQuickVerifyHandler extends 
SnapshotPartitionsVeri
         String name,
         Collection<SnapshotHandlerResult<Map<PartitionKeyV2, 
PartitionHashRecordV2>>> results
     ) throws IgniteCheckedException {
-        boolean noData = false;
+        Exception err = 
results.stream().map(SnapshotHandlerResult::error).filter(Objects::nonNull).findAny().orElse(null);
 
-        Set<Integer> wrnGrps = new HashSet<>();
+        if (err != null)
+            throw U.cast(err);
+
+        // Null means that the streamer was already detected (See #invoke).
+        if (results.stream().anyMatch(res -> res.data() == null))
+            return;
 
+        Set<Integer> wrnGrps = new HashSet<>();
         Map<PartitionKeyV2, PartitionHashRecordV2> total = new HashMap<>();
 
         for (SnapshotHandlerResult<Map<PartitionKeyV2, PartitionHashRecordV2>> 
result : results) {
-            if (result.error() != null)
-                throw new IgniteCheckedException(result.error());
-
-            if (result.data() == null) {
-                noData = true;
-
-                continue;
-            }
-
-            Map<PartitionKeyV2, PartitionHashRecordV2> partsData = 
result.data();
-
-            partsData.forEach((part, val) -> {
+            result.data().forEach((part, val) -> {
                 PartitionHashRecordV2 other = total.putIfAbsent(part, val);
 
                 if ((other != null && !wrnGrps.contains(part.groupId()))
@@ -98,9 +94,6 @@ public class SnapshotPartitionsQuickVerifyHandler extends 
SnapshotPartitionsVeri
             });
         }
 
-        if (noData)
-            return;
-
         if (!wrnGrps.isEmpty()) {
             throw new SnapshotWarningException("Cache partitions differ for 
cache groups " +
                 S.toStringSortedDistinct(wrnGrps) + ". " + WRN_MSG);

Reply via email to