Skip to content

Commit

Permalink
Reduce dns lookup overhead on NodeScheduler
Browse files Browse the repository at this point in the history
It does not need to dns lookup for hostname if HostAddress has port, which incurred additional overhead when dns too slow on some host environment.
  • Loading branch information
guhanjie authored and findepi committed Aug 7, 2023
1 parent 55fa990 commit 4cacdb8
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ public static List<InternalNode> selectExactNodes(NodeMap nodeMap, List<HostAddr
.filter(node -> includeCoordinator || !coordinatorIds.contains(node.getNodeIdentifier()))
.forEach(chosen::add);

InetAddress address;
try {
address = host.toInetAddress();
}
catch (UnknownHostException e) {
// skip hosts that don't resolve
continue;
}

// consider a split with a host without a port as being accessible by all nodes in that host
if (!host.hasPort()) {
InetAddress address;
try {
address = host.toInetAddress();
}
catch (UnknownHostException e) {
// skip hosts that don't resolve
continue;
}

nodeMap.getNodesByHost().get(address).stream()
.filter(node -> includeCoordinator || !coordinatorIds.contains(node.getNodeIdentifier()))
.forEach(chosen::add);
Expand All @@ -133,17 +133,17 @@ public static List<InternalNode> selectExactNodes(NodeMap nodeMap, List<HostAddr

chosen.addAll(nodeMap.getNodesByHostAndPort().get(host));

InetAddress address;
try {
address = host.toInetAddress();
}
catch (UnknownHostException e) {
// skip hosts that don't resolve
continue;
}

// consider a split with a host without a port as being accessible by all nodes in that host
if (!host.hasPort()) {
InetAddress address;
try {
address = host.toInetAddress();
}
catch (UnknownHostException e) {
// skip hosts that don't resolve
continue;
}

chosen.addAll(nodeMap.getNodesByHost().get(address));
}
}
Expand Down

0 comments on commit 4cacdb8

Please sign in to comment.