alievmirza commented on code in PR #4318:
URL: https://github.com/apache/ignite-3/pull/4318#discussion_r1743391164
##########
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:
my point is that it is confusing to have some conditions in UPDATE logic.
All conditions must be presented in `Condition`, but if you have some
conditions in update methods, it could collide with the condition for MS. My
idea was to have two separate methods, one is the old
`updateLogicalTopologyAndVersion`, and the second is
`updateLogicalTopologyAndVersionAndClusterId`, where we don't have any
condition inside.
--
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]