Class TaskManagerLocation
java.lang.Object
org.apache.flink.runtime.taskmanager.TaskManagerLocation
- All Implemented Interfaces:
Serializable,Comparable<TaskManagerLocation>
public class TaskManagerLocation
extends Object
implements Comparable<TaskManagerLocation>, Serializable
This class encapsulates the connection information of a TaskManager. It describes the host where
the TaskManager operates and its server port for data exchange. This class also contains
utilities to work with the TaskManager's host name, which is used to localize work assignments.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis Supplier class could retrieve the FQDN host name of the given InetAddress on demand, extract the pure host name and cache the results for later use.static interfacestatic classThis Supplier class returns the IP address of the given InetAddress directly, therefore no reverse DNS lookup is required.static enumThe DNS resolution mode for TaskManager's IP address. -
Constructor Summary
ConstructorsConstructorDescriptionTaskManagerLocation(ResourceID resourceID, InetAddress inetAddress, int dataPort) Constructs a new instance connection info object.TaskManagerLocation(ResourceID resourceID, InetAddress inetAddress, int dataPort, TaskManagerLocation.HostNameSupplier hostNameSupplier, String nodeId) Constructs a new instance connection info object. -
Method Summary
Modifier and TypeMethodDescriptionaddress()Returns the network address the instance's task manager binds its sockets to.Gets the IP address where the TaskManager operates.intintdataPort()Returns the port instance's task manager expects to receive transfer envelopes on.booleanstatic TaskManagerLocationfromUnresolvedLocation(UnresolvedTaskManagerLocation unresolvedLocation, TaskManagerLocation.ResolutionMode resolutionMode) Gets the endpoint of the TaskManager in the format of "$HOST:$PORT".Returns the fully-qualified domain name of the TaskManager provided byhostNameSupplier.Gets the hostname of the TaskManager fromhostNameSupplier.static StringgetHostName(InetAddress inetAddress) Gets the hostname of the TaskManager based on the network address.Return the ID of node where the task manager is located on.Gets the ID of the resource in which the TaskManager is started.inthashCode()toString()
-
Constructor Details
-
TaskManagerLocation
@VisibleForTesting public TaskManagerLocation(ResourceID resourceID, InetAddress inetAddress, int dataPort, TaskManagerLocation.HostNameSupplier hostNameSupplier, String nodeId) Constructs a new instance connection info object. The constructor will attempt to retrieve the instance's host name and domain name through the operating system's lookup mechanisms.- Parameters:
inetAddress- the network address the instance's task manager binds its sockets todataPort- the port instance's task manager expects to receive transfer envelopes onhostNameSupplier- the supplier for obtaining fully-qualified domain name and pure hostname of the task managernodeId- the ID of node where the task manager is located on.
-
TaskManagerLocation
@VisibleForTesting public TaskManagerLocation(ResourceID resourceID, InetAddress inetAddress, int dataPort) Constructs a new instance connection info object. The constructor will attempt to retrieve the instance's host name and domain name through the operating system's lookup mechanisms.- Parameters:
inetAddress- the network address the instance's task manager binds its sockets todataPort- the port instance's task manager expects to receive transfer envelopes on
-
-
Method Details
-
fromUnresolvedLocation
public static TaskManagerLocation fromUnresolvedLocation(UnresolvedTaskManagerLocation unresolvedLocation, TaskManagerLocation.ResolutionMode resolutionMode) throws UnknownHostException - Throws:
UnknownHostException
-
getResourceID
Gets the ID of the resource in which the TaskManager is started. The format of this depends on how the TaskManager is started:- If the TaskManager is started via YARN, this is the YARN container ID.
- If the TaskManager is started in standalone mode, or via a MiniCluster, this is a random ID.
- Other deployment modes can set the resource ID in other ways.
- Returns:
- The ID of the resource in which the TaskManager is started
-
dataPort
public int dataPort()Returns the port instance's task manager expects to receive transfer envelopes on.- Returns:
- the port instance's task manager expects to receive transfer envelopes on
-
address
Returns the network address the instance's task manager binds its sockets to.- Returns:
- the network address the instance's task manager binds its sockets to
-
addressString
Gets the IP address where the TaskManager operates.- Returns:
- The IP address.
-
getFQDNHostname
Returns the fully-qualified domain name of the TaskManager provided byhostNameSupplier.- Returns:
- The fully-qualified domain name of the TaskManager.
-
getHostname
Gets the hostname of the TaskManager fromhostNameSupplier.- Returns:
- The hostname of the TaskManager.
-
getNodeId
Return the ID of node where the task manager is located on.- Returns:
- The ID of node where the task manager is located on.
-
getEndpoint
Gets the endpoint of the TaskManager in the format of "$HOST:$PORT".- Returns:
- The endpoint of the TaskManager.
-
getHostName
Gets the hostname of the TaskManager based on the network address.- Parameters:
inetAddress- the network address that the TaskManager binds its sockets to- Returns:
- hostname of the TaskManager
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<TaskManagerLocation>
-