[hotfix][rest] Simplify dispatcher host retrieval Adjusted to work like the JobSubmitHandler.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/4022063a Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/4022063a Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/4022063a Branch: refs/heads/release-1.6 Commit: 4022063ae26cafb5b5d2edf03a74d26f6daff3b1 Parents: 7e2ac0a Author: zentol <ches...@apache.org> Authored: Wed Jul 11 18:37:15 2018 +0200 Committer: Till Rohrmann <trohrm...@apache.org> Committed: Wed Jul 18 09:52:19 2018 +0200 ---------------------------------------------------------------------- .../runtime/webmonitor/handlers/JarRunHandler.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/4022063a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JarRunHandler.java ---------------------------------------------------------------------- diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JarRunHandler.java b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JarRunHandler.java index 1e620d4..858a05c 100644 --- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JarRunHandler.java +++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JarRunHandler.java @@ -35,14 +35,11 @@ import org.apache.flink.runtime.rest.handler.HandlerRequest; import org.apache.flink.runtime.rest.handler.RestHandlerException; import org.apache.flink.runtime.rest.messages.EmptyRequestBody; import org.apache.flink.runtime.rest.messages.MessageHeaders; -import org.apache.flink.runtime.util.ScalaUtils; import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever; import org.apache.flink.util.FlinkException; import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus; -import akka.actor.AddressFromURIString; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -51,7 +48,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.Executor; @@ -112,7 +108,7 @@ public class JarRunHandler extends CompletableFuture<Integer> blobServerPortFuture = gateway.getBlobServerPort(timeout); CompletableFuture<JobGraph> jarUploadFuture = jobGraphFuture.thenCombine(blobServerPortFuture, (jobGraph, blobServerPort) -> { - final InetSocketAddress address = new InetSocketAddress(getDispatcherHost(gateway), blobServerPort); + final InetSocketAddress address = new InetSocketAddress(gateway.getHostname(), blobServerPort); try { ClientUtils.extractAndUploadJobGraphFiles(jobGraph, () -> new BlobClient(address, configuration)); } catch (FlinkException e) { @@ -182,15 +178,4 @@ public class JarRunHandler extends return jobGraph; }, executor); } - - private static String getDispatcherHost(DispatcherGateway gateway) { - String dispatcherAddress = gateway.getAddress(); - final Optional<String> host = ScalaUtils.toJava(AddressFromURIString.parse(dispatcherAddress).host()); - - return host.orElseGet(() -> { - // if the dispatcher address does not contain a host part, then assume it's running - // on the same machine as the handler - return "localhost"; - }); - } }