sanpwc commented on code in PR #1572:
URL: https://github.com/apache/ignite-3/pull/1572#discussion_r1092519867


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -425,11 +431,48 @@ public TableManager(
                 new LinkedBlockingQueue<>(),
                 NamedThreadFactory.create(nodeName, "incoming-raft-snapshot", 
LOG)
         );
+
+        zonesWatchListener = new WatchListener() {
+            @Override
+            public void onUpdate(@NotNull WatchEvent evt) {
+                NamedConfigurationTree<TableConfiguration, TableView, 
TableChange> tables = tablesCfg.tables();
+
+                int zoneId = extractZoneId(evt.entryEvent().newEntry().key());
+
+                Set<String> nodesIds = 
ByteUtils.fromBytes(evt.entryEvent().newEntry().value());
+
+                for (int i = 0; i < tables.value().size(); i++) {
+                    TableView tableView = tables.value().get(i);
+
+                    int tableZoneId = tableView.zoneId();
+
+                    if (zoneId == tableZoneId) {
+                        TableConfiguration tableCfg = 
tables.get(tableView.name());
+
+                        for (int part = 0; part < tableView.partitions(); 
part++) {
+                            UUID tableId = ((ExtendedTableConfiguration) 
tableCfg).id().value();
+
+                            TablePartitionId replicaGrpId = new 
TablePartitionId(tableId, part);
+
+                            updatePendingAssignmentsKeys(tableView.name(), 
replicaGrpId, nodesIds, tableView.replicas(),
+                                    evt.entryEvent().newEntry().revision(), 
metaStorageMgr, part);
+                        }
+                    }
+                }
+            }
+
+            @Override
+            public void onError(@NotNull Throwable e) {
+                LOG.warn("Unable to process stable assignments event", e);
+            }
+        };
     }
 
     /** {@inheritDoc} */
     @Override
     public void start() {
+        metaStorageMgr.registerPrefixWatch(zoneDataNodesPrefix(), 
zonesWatchListener);

Review Comment:
   Could you please hide this inside some private method, like we do for 
registerRebalanceListeners. Please also check further comment about 
de-registrarion.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to