Package org.apache.flink.runtime.net
Class ConnectionUtils
- java.lang.Object
-
- org.apache.flink.runtime.net.ConnectionUtils
-
public class ConnectionUtils extends Object
Utilities to determine the network interface and address that should be used to bind the TaskManager communication to.Implementation note: This class uses
System.nanoTime()
to measure elapsed time, because that is not susceptible to clock changes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectionUtils.LeaderConnectingAddressListener
ALeaderRetrievalListener
that allows retrieving anInetAddress
for the current leader.
-
Constructor Summary
Constructors Constructor Description ConnectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
findConnectingAddress
public static InetAddress findConnectingAddress(InetSocketAddress targetAddress, long maxWaitMillis, long startLoggingAfter) throws IOException
Finds the local network address from which this machine can connect to the target address. This method tries to establish a proper network connection to the given target, so it only succeeds if the target socket address actually accepts connections. The method tries various strategies multiple times and uses an exponential backoff timer between tries.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.
- Parameters:
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.- Throws:
IOException
-
-