Skip to content

Commit

Permalink
CASSANDRASC-123: Add missing method to retrieve the InetSocketAddress…
Browse files Browse the repository at this point in the history
… to DriverUtils (#114)

Patch by Francisco Guerrero; Reviewed by Yifan Cai for CASSANDRASC-123
  • Loading branch information
frankgh committed Apr 23, 2024
1 parent 4a6b8c9 commit 77c8150
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,15 @@ public Host getHost(Metadata metadata, InetSocketAddress localNativeTransportAdd
{
return com.datastax.driver.core.DriverUtils.getHost(metadata, localNativeTransportAddress);
}

/**
* Returns the address that the driver will use to connect to the node.
*
* @param host the host to which reconnect attempts will be made
* @return the address.
*/
public InetSocketAddress getSocketAddress(Host host)
{
return host.getEndPoint().resolve();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ private <T> T fromAdapter(Function<ICassandraAdapter, T> getter)

private void runIfThisHost(Host host, Runnable runnable)
{
if (this.localNativeTransportAddress.equals(host.getEndPoint().resolve()))
if (this.localNativeTransportAddress.equals(driverUtils.getSocketAddress(host)))
{
runnable.run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,6 @@ private synchronized void recalculateSelectedHosts()

private boolean isLocalHost(Host host)
{
return localHostAddresses.contains(host.getEndPoint().resolve());
return localHostAddresses.contains(driverUtils.getSocketAddress(host));
}
}

0 comments on commit 77c8150

Please sign in to comment.