[
https://issues.apache.org/jira/browse/FLINK-11081?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16717610#comment-16717610
]
ASF GitHub Bot commented on FLINK-11081:
----------------------------------------
walterddr commented on a change in pull request #7263: [FLINK-11081] Support
binding port range for REST server
URL: https://github.com/apache/flink/pull/7263#discussion_r240711143
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointConfigurationTest.java
##########
@@ -49,17 +77,154 @@ public void testBasicMapping() throws
ConfigurationException {
Configuration originalConfig = new Configuration();
originalConfig.setString(RestOptions.ADDRESS, ADDRESS);
originalConfig.setString(RestOptions.BIND_ADDRESS,
BIND_ADDRESS);
- originalConfig.setInteger(RestOptions.PORT, PORT);
+ originalConfig.setString(RestOptions.BIND_PORT, BIND_PORT);
originalConfig.setInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH,
CONTENT_LENGTH);
originalConfig.setString(WebOptions.TMP_DIR,
temporaryFolder.getRoot().getAbsolutePath());
final RestServerEndpointConfiguration result =
RestServerEndpointConfiguration.fromConfiguration(originalConfig);
Assert.assertEquals(ADDRESS, result.getRestAddress());
Assert.assertEquals(BIND_ADDRESS, result.getRestBindAddress());
- Assert.assertEquals(PORT, result.getRestBindPort());
+ Assert.assertEquals(BIND_PORT, result.getRestBindPort());
Assert.assertEquals(CONTENT_LENGTH,
result.getMaxContentLength());
Assert.assertThat(
result.getUploadDir().toAbsolutePath().toString(),
containsString(temporaryFolder.getRoot().getAbsolutePath()));
}
+
+ @Test
+ public void testDefaultRestServerBindPort() throws Exception {
+ testRestServerBindPort(null, "8081");
+ }
+
+ @Test
+ public void testRestServerSpecificBindPort() throws Exception {
+ testRestServerBindPort("12345", "12345");
+ }
+
+ @Test
+ public void testRestServerSpecificBindPortRange() throws Exception {
+ testRestServerBindPort("12345,12346", "12345");
+ }
+
+ @Test
+ public void testRestServerBindPortRange() throws Exception {
+ testRestServerBindPort("12345-12350", "12345");
+ }
+
+ @Test
+ public void testRestServerBindPortAndConnectionPortSuccess() throws
Exception {
+ testRestServerBindPortAndConnectionPort("12345,12346", 12345);
+ }
+
+ @Test
+ public void testRestServerBindPortAndConnectionPortFailed() throws
Exception {
+ try {
+ testRestServerBindPortAndConnectionPort("12345-12346",
12347);
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Connection refused")
+ && e.getMessage().contains("12347"));
+ }
+ }
+
+ private void testRestServerBindPortAndConnectionPort(String bindPort,
int connectPort) throws Exception {
+ RestServerEndpoint serverEndpoint = null;
+ RestClient restClient = null;
+
+ try {
+ final Configuration config = new Configuration();
+ config.setString(RestOptions.ADDRESS, "localhost");
+ config.setString(RestOptions.BIND_PORT, bindPort);
+ config.setInteger(RestOptions.PORT, connectPort);
Review comment:
This is a bit confusing since this config should never be used in
RestServerEndpoint initialization (replaced by `BIND_PORT`, this should be
removed.
----------------------------------------------------------------
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:
[email protected]
> Support binding port range for REST server
> ------------------------------------------
>
> Key: FLINK-11081
> URL: https://issues.apache.org/jira/browse/FLINK-11081
> Project: Flink
> Issue Type: Improvement
> Components: REST
> Affects Versions: 1.7.0, 1.8.0
> Reporter: Till Rohrmann
> Assignee: vinoyang
> Priority: Major
> Labels: pull-request-available
>
> Currently the {{RestServerEndpoint}} binds to the port specified by
> {{RestOptions#PORT}}. {{PORT}} is of type integer. Sometimes, it would be
> useful to being able to specify not only a single port but a port range to
> pick a port from. Therefore, I propose to add similar to
> {{RestOptions#BIND_ADDRESS}} another option {{RestOptions#BIND_PORT}} which
> allows to specify a port range for the {{RestServerEndpoint}} to pick a port
> from. {{RestOptions#PORT}} would then only be used by the client to connect
> to the started {{RestServerEndpoint}}.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)