valepakh commented on code in PR #5255: URL: https://github.com/apache/ignite-3/pull/5255#discussion_r2002762256
########## modules/network/src/main/java/org/apache/ignite/internal/network/scalecube/ScaleCubeTopologyService.java: ########## @@ -140,6 +156,12 @@ void updateLocalMetadata(@Nullable NodeMetadata metadata) { ClusterNode node = fromMember(cluster.member(), metadata); members.put(node.address(), node); membersByConsistentId.computeIfAbsent(node.name(), k -> new ConcurrentHashMap<>()).put(node.id(), node); + membersByConsistentIdInLogicalTopology.compute(node.name(), (consId, clusterNode) -> { Review Comment: Done ########## modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java: ########## @@ -1250,6 +1252,20 @@ private GroupStoragesContextResolver createGroupStoragesContextResolver() { ); } + private static LogicalTopologyEventListener joinedNodesListener(JoinedNodes joinedNodes) { Review Comment: Renamed ########## modules/network/src/main/java/org/apache/ignite/internal/network/scalecube/ScaleCubeTopologyService.java: ########## @@ -191,8 +213,26 @@ public ClusterNode getByAddress(NetworkAddress addr) { /** {@inheritDoc} */ @Override public @Nullable ClusterNode getByConsistentId(String consistentId) { + ClusterNode nodeInLogicalTopology = membersByConsistentIdInLogicalTopology.get(consistentId); + if (nodeInLogicalTopology != null) { + // Node is in the logical topology, check if it's in the physical topology. This could happen when topology is restored on Review Comment: Rephrased ########## modules/network/src/main/java/org/apache/ignite/internal/network/scalecube/ScaleCubeTopologyService.java: ########## @@ -61,6 +62,9 @@ final class ScaleCubeTopologyService extends AbstractTopologyService { /** Topology members map from the consistent id to the map from the id to the cluster node. */ private final ConcurrentMap<String, Map<UUID, ClusterNode>> membersByConsistentId = new ConcurrentHashMap<>(); + /** Topology members map from the consistent id to the cluster node. Only contains nodes that are joined logical topology. */ Review Comment: Done ########## modules/network/src/main/java/org/apache/ignite/internal/network/scalecube/ScaleCubeTopologyService.java: ########## @@ -191,8 +213,26 @@ public ClusterNode getByAddress(NetworkAddress addr) { /** {@inheritDoc} */ @Override public @Nullable ClusterNode getByConsistentId(String consistentId) { + ClusterNode nodeInLogicalTopology = membersByConsistentIdInLogicalTopology.get(consistentId); + if (nodeInLogicalTopology != null) { + // Node is in the logical topology, check if it's in the physical topology. This could happen when topology is restored on + // node start, but the node is not present anymore + ClusterNode node = idToMemberMap.get(nodeInLogicalTopology.id()); + if (node != null) { + return node; + } + } + + // Node is not in the logical topology, check if it's the only node in the physical topology Map<UUID, ClusterNode> nodes = membersByConsistentId.get(consistentId); - return nodes != null ? nodes.values().iterator().next() : null; + if (nodes == null) { + return null; + } + if (nodes.size() > 1) { + LOG.error("Node \"{}\" has duplicate in the physical topology", consistentId); Review Comment: Logged ########## modules/network/src/main/java/org/apache/ignite/internal/network/scalecube/ScaleCubeTopologyService.java: ########## @@ -232,4 +272,16 @@ private static NodeMetadata deserializeMetadata(@Nullable ByteBuffer buffer) { return null; } } + + @Override + public void onJoined(ClusterNode node) { + LOG.info("Node joined logical topology [node={}]", node); Review Comment: Made it DEBUG level -- 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