JAkutenshi commented on code in PR #4707: URL: https://github.com/apache/ignite-3/pull/4707#discussion_r1840953229
########## modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/AssignmentsTracker.java: ########## @@ -147,48 +141,137 @@ public CompletableFuture<List<TokenizedAssignments>> getAssignments( } /** - * Gets assignments. + * Gets stable assignments. * - * @return Map replication group id to its assignment. + * @return Map replication group id to its stable assignments. */ - public Map<ReplicationGroupId, TokenizedAssignments> assignments() { - return groupAssignments; + Map<ReplicationGroupId, TokenizedAssignments> stableAssignments() { + return groupStableAssignments; } /** - * Meta storage assignments watch. + * Gets pending assignments. + * + * @return Map replication group id to its pending assignments. */ - private class AssignmentsListener implements WatchListener { - @Override - public CompletableFuture<Void> onUpdate(WatchEvent event) { - assert !event.entryEvents().stream().anyMatch(e -> e.newEntry().empty()) : "New assignments are empty"; - - if (LOG.isDebugEnabled()) { - LOG.debug("Assignment update [revision={}, keys={}]", event.revision(), - event.entryEvents().stream() - .map(e -> new ByteArray(e.newEntry().key()).toString()) - .collect(Collectors.joining(","))); + Map<ReplicationGroupId, TokenizedAssignments> pendingAssignments() { + return groupStableAssignments; + } + + private WatchListener createStableAssignmentsListener() { + return new WatchListener() { + @Override + public CompletableFuture<Void> onUpdate(WatchEvent event) { + assert areAssignmentsPresentedInEvent(event) : "New assignments are empty"; + + if (LOG.isDebugEnabled()) { + LOG.debug("Stable assignments update [revision={}, keys={}]", event.revision(), collectKeysFromEventAsString(event)); + } + + handleReceivedAssignments(event, STABLE_ASSIGNMENTS_PREFIX, groupStableAssignments); + + return nullCompletedFuture(); } - for (EntryEvent evt : event.entryEvents()) { - Entry entry = evt.newEntry(); + @Override + public void onError(Throwable e) { + } + }; + } - var replicationGrpId = TablePartitionId.fromString( - new String(entry.key(), StandardCharsets.UTF_8).replace(STABLE_ASSIGNMENTS_PREFIX, "")); + private WatchListener createPendingAssignmentsListener() { + return new WatchListener() { + @Override + public CompletableFuture<Void> onUpdate(WatchEvent event) { + assert areAssignmentsPresentedInEvent(event) : "New assignments are empty"; Review Comment: I don't now, to be honest, just moved the assert as it was. I'm not sure that it's a possible situation too. Let's remove it then. -- 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