rpuch commented on code in PR #4318:
URL: https://github.com/apache/ignite-3/pull/4318#discussion_r1742114655


##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZonesUtil.java:
##########
@@ -377,21 +397,25 @@ static Update deleteDataNodesAndTriggerKeys(int zoneId, 
long revision) {
     }
 
     /**
-     * Updates logical topology and logical topology version values for zones.
+     * Updates logical topology, its version and (if this is an initial 
version) cluster ID values for zones.
      *
-     * @param logicalTopology Logical topology.
-     * @param topologyVersion Logical topology version.
+     * @param logicalTopology Logical topology snapshot.
      * @return Update command for the meta storage.
      */
-    static Update updateLogicalTopologyAndVersion(Set<LogicalNode> 
logicalTopology, long topologyVersion) {
-        Set<NodeWithAttributes> topologyFromCmg = logicalTopology.stream()
+    static Update 
updateLogicalTopologyAndVersionAndClusterId(LogicalTopologySnapshot 
logicalTopology) {
+        Set<NodeWithAttributes> topologyFromCmg = 
logicalTopology.nodes().stream()
                 .map(n -> new NodeWithAttributes(n.name(), n.id(), 
n.userAttributes(), n.storageProfiles()))
                 .collect(toSet());
 
-        return ops(
-                put(zonesLogicalTopologyVersionKey(), 
longToBytesKeepingOrder(topologyVersion)),
-                put(zonesLogicalTopologyKey(), 
ByteUtils.toBytes(topologyFromCmg))
-        ).yield(true);
+        List<Operation> operations = new ArrayList<>();
+
+        operations.add(put(zonesLogicalTopologyVersionKey(), 
longToBytesKeepingOrder(logicalTopology.version())));
+        operations.add(put(zonesLogicalTopologyKey(), 
ByteUtils.toBytes(topologyFromCmg)));
+        if (logicalTopology.version() == 
LogicalTopologySnapshot.FIRST_VERSION) {

Review Comment:
   We will NOT write `zonesLogicalTopologyClusterIdKey` if 
`value(zonesLogicalTopologyVersionKey()).lt(longToBytesKeepingOrder(newTopology.version()))`.
 `zonesLogicalTopologyClusterIdKey` only gets written if the event is about 
version 1:
   
   ```
           if (logicalTopology.version() == 
LogicalTopologySnapshot.FIRST_VERSION) {
               operations.add(put(zonesLogicalTopologyClusterIdKey(), 
uuidToBytes(logicalTopology.clusterId())));
           }
   ```



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