JAkutenshi commented on code in PR #4707:
URL: https://github.com/apache/ignite-3/pull/4707#discussion_r1842104580


##########
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:
   So, we assumes that stables are non-empty and we're saving assert for them, 
but for pendings we're making return in the case because it's possible



-- 
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

Reply via email to