sergeyuttsel commented on code in PR #1426:
URL: https://github.com/apache/ignite-3/pull/1426#discussion_r1049902475


##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -235,6 +257,98 @@ public CompletableFuture<Void> dropZone(String name) {
     @Override
     public void start() {
         zonesConfiguration.distributionZones().listenElements(new 
ZonesConfigurationListener());
+
+        long vaultAppliedRevision = vaultAppliedRevision();
+
+        VaultEntry vaultEntry;
+
+        try {
+            vaultEntry = vaultMgr.get(zonesLogicalTopologyKey()).get();
+        } catch (InterruptedException | ExecutionException e) {
+            throw new IgniteInternalException(e);
+        }
+
+        if (vaultEntry != null && vaultEntry.value() != null) {
+            byte[] newLogicalTopology = vaultEntry.value();
+
+            logicalTopology = ByteUtils.fromBytes(newLogicalTopology);
+
+            zonesConfiguration.distributionZones().value().namedListKeys()
+                    .forEach(zoneName -> {
+                        int zoneId = 
zonesConfiguration.distributionZones().get(zoneName).zoneId().value();
+
+                        saveDataNodesToMetastorage(zoneId, newLogicalTopology, 
vaultAppliedRevision);
+                    });
+        }
+
+        metaStorageManager.registerWatch(zonesLogicalTopologyKey(), new 
WatchListener() {
+            @Override
+            public boolean onUpdate(@NotNull WatchEvent evt) {
+                if (!busyLock.enterBusy()) {
+                    throw new IgniteInternalException(new 
NodeStoppingException());
+                }
+
+                try {
+                    assert evt.single();
+
+                    Entry newEntry = evt.entryEvent().newEntry();
+
+                    Set<String> newlogicalTopology = 
ByteUtils.fromBytes(newEntry.value());
+
+                    List<String> removedNodes =
+                            logicalTopology.stream().filter(node -> 
!newlogicalTopology.contains(node)).collect(toList());
+
+                    List<String> addedNodes =
+                            newlogicalTopology.stream().filter(node -> 
!logicalTopology.contains(node)).collect(toList());
+
+                    logicalTopology = newlogicalTopology;
+
+                    
zonesConfiguration.distributionZones().value().namedListKeys()
+                            .forEach(zoneName -> {
+                                DistributionZoneConfiguration zoneCfg = 
zonesConfiguration.distributionZones().get(zoneName);
+
+                                int autoAdjust = 
zoneCfg.dataNodesAutoAdjust().value();
+                                int autoAdjustScaleDown = 
zoneCfg.dataNodesAutoAdjustScaleDown().value();
+                                int autoAdjustScaleUp = 
zoneCfg.dataNodesAutoAdjustScaleUp().value();
+
+                                Integer zoneId = zoneCfg.zoneId().value();
+
+                                if (!removedNodes.isEmpty()) {

Review Comment:
   Thanks



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