[
https://issues.apache.org/jira/browse/FLINK-5758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15894057#comment-15894057
]
ASF GitHub Bot commented on FLINK-5758:
---------------------------------------
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/3391#discussion_r103202170
--- Diff: flink-core/src/main/java/org/apache/flink/util/NetUtils.java ---
@@ -373,6 +374,46 @@ public static ServerSocket
createSocketFromPorts(Iterator<Integer> portsIterator
}
/**
+ * Tries to create a server from the given sets of ports.
+ *
+ * @param address An address to listen at.
+ * @param portRange A set of ports to choose from.
+ * @param serverFactory A factory for creating server.
+ * @return the created server.
+ * @throws BindException If port range is exhausted.
+ */
+ public static <T> T createServerFromPorts(String address,
Iterator<Integer> portRange, ServerFactory<T> serverFactory) throws Exception {
+
+ while (portRange.hasNext()) {
+ ServerSocket availableSocket =
NetUtils.createSocketFromPorts(
+ portRange,
+ new NetUtils.SocketFactory() {
+ @Override
+ public ServerSocket createSocket(int
port) throws IOException {
+ return new ServerSocket(port);
+ }
+ });
+
+ int port;
+ if (availableSocket == null) {
+ throw new BindException("Could not start server
on any port in port range: " + portRange);
--- End diff --
I guess we only should throw this one if our `iterator` is exhausted, right?
> Port-range for the web interface via YARN
> -----------------------------------------
>
> Key: FLINK-5758
> URL: https://issues.apache.org/jira/browse/FLINK-5758
> Project: Flink
> Issue Type: Sub-task
> Components: YARN
> Affects Versions: 1.2.0, 1.1.4, 1.3.0
> Reporter: Kanstantsin Kamkou
> Assignee: Yelei Feng
> Labels: network
>
> In case of YARN, the {{ConfigConstants.JOB_MANAGER_WEB_PORT_KEY}} [is
> changed to
> 0|https://github.com/apache/flink/blob/release-1.2.0/flink-yarn/src/main/java/org/apache/flink/yarn/YarnApplicationMasterRunner.java#L526].
> Please allow port ranges in this case. DevOps need that.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)