From 1987b707c1b8c30cc7e04504f48412ec214ec77f Mon Sep 17 00:00:00 2001 From: Vladimir Steshin Date: Fri, 1 Nov 2024 11:12:27 +0300 Subject: [PATCH] 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 cce4e5d3057d3..652aac3cadaf2 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.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 SnapshotPartitionsQuickVerifyHandler(GridCacheSharedContext cctx) { String name, Collection>> results ) throws IgniteCheckedException { - boolean noData = false; + Exception err = results.stream().map(SnapshotHandlerResult::error).filter(Objects::nonNull).findAny().orElse(null); - Set 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 wrnGrps = new HashSet<>(); Map total = new HashMap<>(); for (SnapshotHandlerResult> result : results) { - if (result.error() != null) - throw new IgniteCheckedException(result.error()); - - if (result.data() == null) { - noData = true; - - continue; - } - - Map 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 SnapshotPartitionsQuickVerifyHandler(GridCacheSharedContext cctx) { }); } - if (noData) - return; - if (!wrnGrps.isEmpty()) { throw new SnapshotWarningException("Cache partitions differ for cache groups " + S.toStringSortedDistinct(wrnGrps) + ". " + WRN_MSG);