public class ConnectionUtils extends Object
Implementation note: This class uses System.nanoTime()
to measure elapsed time,
because that is not susceptible to clock changes.
Modifier and Type | Class and Description |
---|---|
static class |
ConnectionUtils.LeaderConnectingAddressListener
A
LeaderRetrievalListener that allows retrieving an InetAddress for the
current leader. |
Constructor and Description |
---|
ConnectionUtils() |
Modifier and Type | Method and Description |
---|---|
static InetAddress |
findConnectingAddress(InetSocketAddress targetAddress,
long maxWaitMillis,
long startLoggingAfter)
Finds the local network address from which this machine can connect to the target address.
|
public static InetAddress findConnectingAddress(InetSocketAddress targetAddress, long maxWaitMillis, long startLoggingAfter) throws IOException
If no connection attempt was successful after the given maximum time, the method will choose some address based on heuristics (excluding link-local and loopback addresses.)
This method will initially not log on info level (to not flood the log while the backoff time is still very low). It will start logging after a certain time has passes.
targetAddress
- The address that the method tries to connect to.maxWaitMillis
- The maximum time that this method tries to connect, before falling back
to the heuristics.startLoggingAfter
- The time after which the method will log on INFO level.IOException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.