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:
  • 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 to
      dataPort - the port instance's task manager expects to receive transfer envelopes on
      hostNameSupplier - the supplier for obtaining fully-qualified domain name and pure hostname of the task manager
      nodeId - 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 to
      dataPort - 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

      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 by hostNameSupplier.
      Returns:
      The fully-qualified domain name of the TaskManager.
    • getHostname

      public String getHostname()
      Gets the hostname of the TaskManager from hostNameSupplier.
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(@Nonnull TaskManagerLocation o)
      Specified by:
      compareTo in interface Comparable<TaskManagerLocation>