sanpwc commented on code in PR #2172: URL: https://github.com/apache/ignite-3/pull/2172#discussion_r1229395040
########## modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java: ########## @@ -1027,44 +1030,52 @@ private void initDataNodesFromVaultManager() { try { long appliedRevision = metaStorageManager.appliedRevision(); - VaultEntry topologyEntry = vaultMgr.get(zonesLogicalTopologyKey()).join(); - - if (topologyEntry != null && topologyEntry.value() != null) { - assert appliedRevision > 0 : "The meta storage last applied revision is 0 but the logical topology is not null."; - - logicalTopology = fromBytes(topologyEntry.value()); - - logicalTopology.forEach(n -> nodesAttributes.put(n.nodeId(), n.nodeAttributes())); + restoreGlobalStateFromVault(); + if (!logicalTopology.isEmpty()) { // init keys and data nodes for default zone saveDataNodesAndUpdateTriggerKeysInMetaStorage( DEFAULT_ZONE_ID, appliedRevision, logicalTopology.stream().map(NodeWithAttributes::node).collect(toSet()) ); - - zonesConfiguration.distributionZones().value().forEach(zone -> { - int zoneId = zone.zoneId(); - - saveDataNodesAndUpdateTriggerKeysInMetaStorage( - zoneId, - appliedRevision, - logicalTopology.stream().map(NodeWithAttributes::node).collect(toSet()) - ); - }); } zonesState.values().forEach(zoneState -> { zoneState.nodes(logicalTopology.stream().map(NodeWithAttributes::nodeName).collect(toSet())); }); - assert topologyEntry == null || topologyEntry.value() == null || logicalTopology.equals(fromBytes(topologyEntry.value())) - : "Initial value of logical topology was changed after initialization from the vault manager."; } finally { busyLock.leaveBusy(); } } + /** + * Restores from vault logical topology and nodes' attributes fields in {@link DistributionZoneManager} after restart. + */ + private void restoreGlobalStateFromVault() { + VaultEntry topologyEntry = vaultMgr.get(zonesLogicalTopologyVault()).join(); + + VaultEntry nodeAttributesEntry = vaultMgr.get(zonesNodesAttributesVault()).join(); + + if (topologyEntry != null && topologyEntry.value() != null) { + assert nodeAttributesEntry != null : "Nodes' attributes cannot be null when logical topology is not null."; + assert nodeAttributesEntry.value() != null : "Nodes' attributes cannot be null when logical topology is not null."; + + logicalTopology = fromBytes(topologyEntry.value()); + + nodesAttributes = fromBytes(nodeAttributesEntry.value()); Review Comment: What kind of Map class will be resolved from fromBytes()? -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org