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


##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -954,6 +1288,92 @@ public void onError(Throwable e) {
         };
     }
 
+    private WatchListener createMetastorageDataNodesListener() {
+        return new WatchListener() {
+            @Override
+            public void onUpdate(WatchEvent evt) {
+                if (!busyLock.enterBusy()) {
+                    throw new IgniteInternalException(NODE_STOPPING_ERR, new 
NodeStoppingException());
+                }
+
+                try {
+                    int zoneId = 0;
+
+                    Set<String> newDataNodes = null;
+
+                    long scaleUpRevision = 0;
+
+                    long scaleDownRevision = 0;
+
+                    for (EntryEvent event : evt.entryEvents()) {
+                        Entry e = event.newEntry();
+
+                        if (startsWith(e.key(), zoneDataNodesKey().bytes())) {
+                            zoneId = extractZoneId(e.key());
+
+                            byte[] dataNodesBytes = e.value();
+
+                            if (dataNodesBytes != null) {
+                                newDataNodes = 
DistributionZonesUtil.dataNodes(fromBytes(dataNodesBytes));
+                            } else {
+                                newDataNodes = emptySet();
+                            }
+                        } else if (startsWith(e.key(), 
zoneScaleUpChangeTriggerKey().bytes())) {
+                            if (e.value() != null) {
+                                scaleUpRevision = bytesToLong(e.value());
+                            }
+                        } else if (startsWith(e.key(), 
zoneScaleDownChangeTriggerKey().bytes())) {
+                            if (e.value() != null) {
+                                scaleDownRevision = bytesToLong(e.value());
+                            }
+                        }
+                    }
+
+                    synchronized (dataNodesMutex) {
+                        DataNodes dataNodesMeta = dataNodes.get(zoneId);
+
+                        if (dataNodesMeta != null) {
+                            dataNodesMeta.nodes(newDataNodes);
+
+                            if (scaleUpRevision > 0) {

Review Comment:
   This code was reworked but I think it will not be more clear if make util 
method for this.



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