Repository: flink Updated Branches: refs/heads/master 1809e9ff3 -> 9b7e42924
http://git-wip-us.apache.org/repos/asf/flink/blob/00284fb8/flink-libraries/flink-streaming-python/src/test/python/org/apache/flink/streaming/python/api/utils/utils.py ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-streaming-python/src/test/python/org/apache/flink/streaming/python/api/utils/utils.py b/flink-libraries/flink-streaming-python/src/test/python/org/apache/flink/streaming/python/api/utils/utils.py new file mode 100644 index 0000000..7629765 --- /dev/null +++ b/flink-libraries/flink-streaming-python/src/test/python/org/apache/flink/streaming/python/api/utils/utils.py @@ -0,0 +1,47 @@ +################################################################################ +# 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. +################################################################################ +import socket + + +def gen_free_port(port=5000, granularity=1): + if port not in range(1024, 65535): + raise Exception("input port is should be in range of 1024..65535.") + try: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + while port <= 65535: + try: + s.bind(('', port)) + addr = s.getsockname() + return addr[1] + except IOError: + port += granularity + if port > 65535: + raise Exception("free port not found.") + finally: + s.close() + + +def is_reachable(host, port): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + s.connect((host, port)) + return True + except socket.error as e: + return False + finally: + s.close() http://git-wip-us.apache.org/repos/asf/flink/blob/00284fb8/flink-libraries/pom.xml ---------------------------------------------------------------------- diff --git a/flink-libraries/pom.xml b/flink-libraries/pom.xml index 4b94375..c8bfa93 100644 --- a/flink-libraries/pom.xml +++ b/flink-libraries/pom.xml @@ -43,6 +43,7 @@ under the License. <module>flink-ml</module> <module>flink-cep</module> <module>flink-cep-scala</module> + <module>flink-streaming-python</module> </modules> <!-- override these root dependencies as 'provided', so they don't end up
