Cyrill commented on code in PR #5716: URL: https://github.com/apache/ignite-3/pull/5716#discussion_r2066043128
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java: ########## @@ -309,9 +315,46 @@ private CompletableFuture<Boolean> onHaZoneTopologyReduce(HaZoneTopologyUpdateEv } } - private Set<Assignment> stableAssignmentsWithOnlyAliveNodes(TablePartitionId partitionId, long revision) { - Set<Assignment> stableAssignments = Assignments.fromBytes( - metaStorageManager.getLocally(stablePartAssignmentsKey(partitionId), revision).value()).nodes(); + private CompletableFuture<Boolean> onHaZonePartitionTopologyReduce(HaZoneTopologyUpdateEventParams params) { + int zoneId = params.zoneId(); + long revision = params.causalityToken(); + long timestamp = metaStorageManager.timestampByRevisionLocally(revision).longValue(); + + Catalog catalog = catalogManager.activeCatalog(timestamp); + CatalogZoneDescriptor zoneDescriptor = catalog.zone(zoneId); + + Set<Integer> partitionsToReset = new HashSet<>(); + + for (int partId = 0; partId < zoneDescriptor.partitions(); partId++) { + ZonePartitionId partitionId = new ZonePartitionId(zoneId, partId); + + if (stableAssignmentsWithOnlyAliveNodes(partitionId, revision, true).size() < calculateQuorum(zoneDescriptor.replicas())) { + partitionsToReset.add(partId); + } + } + + if (!partitionsToReset.isEmpty()) { + return resetPartitions(zoneDescriptor.name(), Map.of(zoneId, partitionsToReset), false, revision, true).thenApply(r -> false); + } else { + return falseCompletedFuture(); + } + } + + private Set<Assignment> stableAssignmentsWithOnlyAliveNodes(ReplicationGroupId partitionId, long revision, boolean colocationEnabled) { + Set<Assignment> stableAssignments; + + if (colocationEnabled) { + stableAssignments = Assignments.fromBytes( + metaStorageManager.getLocally( + ZoneRebalanceUtil.stablePartAssignmentsKey((ZonePartitionId) partitionId), + revision + ).value() + ).nodes(); + } else { + stableAssignments = Assignments.fromBytes( + metaStorageManager.getLocally(stablePartAssignmentsKey((TablePartitionId) partitionId), revision).value() Review Comment: There are corresponding methods in RebalanceUtil and ZoneRebalance util, you can use them here instead. -- 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. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org