[ https://issues.apache.org/jira/browse/FLINK-10293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16607046#comment-16607046 ]
ASF GitHub Bot commented on FLINK-10293: ---------------------------------------- zentol closed pull request #6665: [FLINK-10293][streaming] Properly forward REST port for remote environments URL: https://github.com/apache/flink/pull/6665 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/RemoteStreamEnvironment.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/RemoteStreamEnvironment.java index 480f981bc75..9c36dab75fd 100644 --- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/RemoteStreamEnvironment.java +++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/RemoteStreamEnvironment.java @@ -29,6 +29,7 @@ import org.apache.flink.configuration.Configuration; import org.apache.flink.configuration.CoreOptions; import org.apache.flink.configuration.JobManagerOptions; +import org.apache.flink.configuration.RestOptions; import org.apache.flink.streaming.api.graph.StreamGraph; import org.slf4j.Logger; @@ -201,6 +202,8 @@ protected JobExecutionResult executeRemotely(StreamGraph streamGraph, List<URL> configuration.setString(JobManagerOptions.ADDRESS, host); configuration.setInteger(JobManagerOptions.PORT, port); + configuration.setInteger(RestOptions.PORT, port); + final ClusterClient<?> client; try { if (CoreOptions.LEGACY_MODE.equals(configuration.getString(CoreOptions.MODE))) { diff --git a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/environment/RemoteStreamExecutionEnvironmentTest.java b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/environment/RemoteStreamExecutionEnvironmentTest.java new file mode 100644 index 00000000000..60ee66f4246 --- /dev/null +++ b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/environment/RemoteStreamExecutionEnvironmentTest.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.streaming.api.environment; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.RestOptions; +import org.apache.flink.runtime.minicluster.MiniCluster; +import org.apache.flink.runtime.minicluster.MiniClusterConfiguration; +import org.apache.flink.streaming.api.datastream.DataStream; +import org.apache.flink.streaming.api.datastream.DataStreamUtils; +import org.apache.flink.util.TestLogger; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.Iterator; + +/** + * Tests for the {@link RemoteStreamEnvironment}. + */ +public class RemoteStreamExecutionEnvironmentTest extends TestLogger { + + private static MiniCluster flink; + + @BeforeClass + public static void setUp() throws Exception { + final Configuration config = new Configuration(); + config.setInteger(RestOptions.PORT, 0); + + final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() + .setConfiguration(config) + .setNumTaskManagers(1) + .setNumSlotsPerTaskManager(1) + .build(); + + flink = new MiniCluster(miniClusterConfiguration); + + flink.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + if (flink != null) { + flink.close(); + } + } + + /** + * Verifies that the port passed to the RemoteStreamEnvironment is used for connecting to the cluster. + */ + @Test + public void testPortForwarding() throws Exception { + final Configuration clientConfiguration = new Configuration(); + clientConfiguration.setInteger(RestOptions.RETRY_MAX_ATTEMPTS, 0); + + final StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment( + flink.getRestAddress().getHost(), + flink.getRestAddress().getPort(), + clientConfiguration); + + final DataStream<Integer> resultStream = env.fromElements(1) + .map(x -> x * 2); + + final Iterator<Integer> result = DataStreamUtils.collect(resultStream); + Assert.assertTrue(result.hasNext()); + Assert.assertEquals(2, result.next().intValue()); + Assert.assertFalse(result.hasNext()); + } +} ---------------------------------------------------------------- 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 > RemoteStreamEnvironment does not forward port to RestClusterClient > ------------------------------------------------------------------ > > Key: FLINK-10293 > URL: https://issues.apache.org/jira/browse/FLINK-10293 > Project: Flink > Issue Type: Bug > Components: Client, Streaming > Affects Versions: 1.5.1, 1.6.0, 1.7.0 > Reporter: Chesnay Schepler > Assignee: Chesnay Schepler > Priority: Major > Labels: pull-request-available > Fix For: 1.6.1, 1.7.0, 1.5.4 > > > A user reported on the ML that the port given to the RemoteStreamEnvironment > is not forwarded to the RestClusterClient. -- This message was sent by Atlassian JIRA (v7.6.3#76005)