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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TaskManagerLocation.DefaultHostNameSupplier
This 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 interface
TaskManagerLocation.HostNameSupplier
static class
TaskManagerLocation.IpOnlyHostNameSupplier
This Supplier class returns the IP address of the given InetAddress directly, therefore no reverse DNS lookup is required.static class
TaskManagerLocation.ResolutionMode
The DNS resolution mode for TaskManager's IP address.
-
Constructor Summary
Constructors Constructor Description TaskManagerLocation(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InetAddress
address()
Returns the network address the instance's task manager binds its sockets to.String
addressString()
Gets the IP address where the TaskManager operates.int
compareTo(TaskManagerLocation o)
int
dataPort()
Returns the port instance's task manager expects to receive transfer envelopes on.boolean
equals(Object obj)
static TaskManagerLocation
fromUnresolvedLocation(UnresolvedTaskManagerLocation unresolvedLocation, TaskManagerLocation.ResolutionMode resolutionMode)
String
getEndpoint()
Gets the endpoint of the TaskManager in the format of "$HOST:$PORT".String
getFQDNHostname()
Returns the fully-qualified domain name of the TaskManager provided byhostNameSupplier
.String
getHostname()
Gets the hostname of the TaskManager fromhostNameSupplier
.static String
getHostName(InetAddress inetAddress)
Gets the hostname of the TaskManager based on the network address.String
getNodeId()
Return the ID of node where the task manager is located on.ResourceID
getResourceID()
Gets the ID of the resource in which the TaskManager is started.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
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 Detail
-
fromUnresolvedLocation
public static TaskManagerLocation fromUnresolvedLocation(UnresolvedTaskManagerLocation unresolvedLocation, TaskManagerLocation.ResolutionMode resolutionMode) throws UnknownHostException
- Throws:
UnknownHostException
-
getResourceID
public ResourceID 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
public InetAddress 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
public String addressString()
Gets the IP address where the TaskManager operates.- Returns:
- The IP address.
-
getFQDNHostname
public String getFQDNHostname()
Returns the fully-qualified domain name of the TaskManager provided byhostNameSupplier
.- Returns:
- The fully-qualified domain name of the TaskManager.
-
getHostname
public String getHostname()
Gets the hostname of the TaskManager fromhostNameSupplier
.- Returns:
- The hostname of the TaskManager.
-
getNodeId
public String 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
public String getEndpoint()
Gets the endpoint of the TaskManager in the format of "$HOST:$PORT".- Returns:
- The endpoint of the TaskManager.
-
getHostName
public static String getHostName(InetAddress inetAddress)
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
-
compareTo
public int compareTo(@Nonnull TaskManagerLocation o)
- Specified by:
compareTo
in interfaceComparable<TaskManagerLocation>
-
-