Skip to content

Commit

Permalink
IGNITE-23584 Refactored snapshot quick verify handler. (#11632)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladsz83 authored Nov 1, 2024
1 parent 9f4f738 commit 1987b70
Showing 1 changed file with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,25 +71,20 @@ public SnapshotPartitionsQuickVerifyHandler(GridCacheSharedContext<?, ?> cctx) {
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()))
Expand All @@ -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);
Expand Down

0 comments on commit 1987b70

Please sign in to comment.