frankgh commented on code in PR #51:
URL: https://github.com/apache/cassandra-sidecar/pull/51#discussion_r1277781607
##########
common/src/main/java/org/apache/cassandra/sidecar/cluster/InstancesConfigImpl.java:
##########
@@ -75,7 +77,18 @@ public InstanceMetadata instanceFromHost(String host) throws
NoSuchElementExcept
InstanceMetadata instanceMetadata = hostToInstanceMetadata.get(host);
if (instanceMetadata == null)
{
- throw new NoSuchElementException("Instance with host address " +
host + " not found");
+ try
+ {
+ instanceMetadata =
hostToInstanceMetadata.get(InetAddress.getByName(host).getHostAddress());
+ }
+ catch (UnknownHostException e)
+ {
+ throw new RuntimeException(e);
+ }
Review Comment:
We should use the DnsResolver here. Which means you'll need to pass it to
the constructor, or we change the signature of the `instanceFromHost` method to
take the DnsResolver. It seems like all the calling points for
`instanceFromHost` should have access to the DnsResolver, so we could change
the signature
```suggestion
try
{
instanceMetadata =
hostToInstanceMetadata.get(dnsResolver.resolve(host));
}
catch (UnknownHostException e)
{
throw new RuntimeException("Unable to resolve instance with
host address " + host, e);
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]