tillrohrmann commented on a change in pull request #7745: [FLINK-11632] Add new config option for TaskManager automatic address binding URL: https://github.com/apache/flink/pull/7745#discussion_r258530764
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java ########## @@ -409,13 +409,30 @@ public static RpcService createRpcService( if (taskManagerHostname != null) { LOG.info("Using configured hostname/address for TaskManager: {}.", taskManagerHostname); } else { - Time lookupTimeout = Time.milliseconds(AkkaUtils.getLookupTimeout(configuration).toMillis()); - - InetAddress taskManagerAddress = LeaderRetrievalUtils.findConnectingAddress( - haServices.getResourceManagerLeaderRetriever(), - lookupTimeout); - - taskManagerHostname = taskManagerAddress.getHostName(); + InetAddress taskManagerAddress; + + String bindPolicy = configuration.getString(TaskManagerOptions.HOST_BIND_POLICY); + switch (bindPolicy.toLowerCase()) { + case "hostname": + taskManagerAddress = InetAddress.getLocalHost(); + taskManagerHostname = taskManagerAddress.getHostName(); + break; + case "ip": + taskManagerAddress = InetAddress.getLocalHost(); + taskManagerHostname = taskManagerAddress.getHostAddress(); + break; + case "auto-detect-hostname": + Time lookupTimeout = Time.milliseconds(AkkaUtils.getLookupTimeout(configuration).toMillis()); + + taskManagerAddress = LeaderRetrievalUtils.findConnectingAddress( + haServices.getResourceManagerLeaderRetriever(), + lookupTimeout); + + taskManagerHostname = taskManagerAddress.getHostName(); + break; + default: + throw new IllegalArgumentException("Unknown " + TaskManagerOptions.HOST_BIND_POLICY.key() + ": " + bindPolicy); + } Review comment: We should factor this method out. That way it would also be easier to test it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services