rpuch commented on code in PR #5519:
URL: https://github.com/apache/ignite-3/pull/5519#discussion_r2020478344
##########
modules/network/src/main/java/org/apache/ignite/internal/network/DefaultMessagingService.java:
##########
@@ -746,44 +745,27 @@ public CompletableFuture<NetworkMessage> future() {
return connectionManager.nodeId().equals(recipientNode.id()) ?
null : getFromCacheOrCreateResolved(recipientNode);
}
- InetSocketAddress localAddress = connectionManager.localAddress();
-
- NetworkAddress recipientAddress = recipientNode.address();
-
- if (localAddress.getPort() != recipientAddress.port()) {
- return createResolved(recipientAddress);
- }
-
- // For optimization, we will check the addresses without resolving the
address of the target node.
- if (Objects.equals(localAddress.getHostName(),
recipientAddress.host())) {
- return null;
- }
-
- InetSocketAddress resolvedRecipientAddress =
createResolved(recipientAddress);
- InetAddress recipientInetAddress =
resolvedRecipientAddress.getAddress();
-
- if (Objects.equals(localAddress.getAddress(), recipientInetAddress)) {
- return null;
- }
-
- return recipientInetAddress.isAnyLocalAddress() ||
recipientInetAddress.isLoopbackAddress() ? null : resolvedRecipientAddress;
+ return RecipientInetAddress.create(connectionManager.localAddress(),
recipientNode.address()).address();
}
- private static InetSocketAddress createResolved(NetworkAddress address) {
- return new InetSocketAddress(address.host(), address.port());
- }
-
- private InetSocketAddress getFromCacheOrCreateResolved(ClusterNode
recipientNode) {
+ private @Nullable InetSocketAddress
getFromCacheOrCreateResolved(ClusterNode recipientNode) {
assert recipientNode.name() != null : "Node has not been added to the
topology: " + recipientNode.id();
- InetSocketAddress address =
recipientInetAddrByNodeId.compute(recipientNode.id(), (nodeId,
inetSocketAddress) -> {
+ InetSocketAddress localAddress = connectionManager.localAddress();
+ NetworkAddress recipientAddress = recipientNode.address();
+
+ RecipientInetAddress address =
recipientInetAddrByNodeId.compute(recipientNode.id(), (nodeId, address1) -> {
Review Comment:
```suggestion
RecipientInetAddress address =
recipientInetAddrByNodeId.compute(recipientNode.id(), (nodeId, existingAddress)
-> {
```
--
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]