tillrohrmann commented on a change in pull request #13706:
URL: https://github.com/apache/flink/pull/13706#discussion_r509330828



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/TaskManagerLocation.java
##########
@@ -150,28 +165,48 @@ public String addressString() {
 
        /**
         * Returns the fully-qualified domain name the TaskManager. If the name 
could not be
-        * determined, the return value will be a textual representation of the 
TaskManager's IP address.
+        * determined or {@link #retrieveHostName} is set to false,
+        * the return value will be a textual representation of the 
TaskManager's IP address.
         * 
         * @return The fully-qualified domain name of the TaskManager.
         */
        public String getFQDNHostname() {
+               // Lazily retrieve FQDN host name of this TaskManager
+               if (fqdnHostName == null) {
+                       if (!retrieveHostName) {
+                               fqdnHostName = inetAddress.getHostAddress();
+                       } else {
+                               fqdnHostName = getFqdnHostName(inetAddress);
+                       }
+               }

Review comment:
       I am wondering whether it wouldn't make sense to move the resolution 
logic out of the `TaskManagerLocation` class in order to make more like a 
simple data transfer object. For example, we could have a method 
`fromUnresolvedLocation(UnresolvedTaskManagerLocation, ResolutionMode)` which 
either resolves the hostname or not depending on `ResolutionMode`.
   
   As a second step we could think about whether we want to support laziness. 
If this is the case, then we could provide a `Supplier<String> 
fqdnHostNameSupplier` which we call to give us the fqdn hostname and then store 
it in some field.
   
   Separating the `TaskManagerLocation` from the way it is resolved might 
simplify the individual classes a bit.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to