You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/05/11 01:33:32 UTC

[GitHub] [flink] shuiqiangchen opened a new pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

shuiqiangchen opened a new pull request #12061:
URL: https://github.com/apache/flink/pull/12061


   …e determined by JVM process.
   
   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Travis CI to do that following [this guide](https://flink.apache.org/contributing/contribute-code.html#open-a-pull-request).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Fixed the bug of "Address already in use" when starting the python gateway after launched the java gateway server which determines the callback server address and port before the python gateway is started. 
   When the python gateway is starting, the free port assigned by java gateway server might be occupied by other process, then cause an "Address already in use" error. Therefore, we should get the callback client port after the python gateway started and reset it back to java gateway server to avoid this potential conflict.
   
   ## Brief change log
   
   We get the callback client port after the python gateway started and reset it back to java gateway server to avoid this potential conflict.
   
   ## Verifying this change
   
   This change can be verified by all pyflink table API tests which need to start the communication between python process and java process. 
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] shuiqiangchen edited a comment on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
shuiqiangchen edited a comment on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626519077


   > Thanks for the PR @shuiqiangchen !
   > I think the failure of the test is caused by https://issues.apache.org/jira/browse/FLINK-17601
   > So, LGTM +1 to merged.
   > 
   > One suggestion is for the next PR description, fill in all the contents specified in the template, such as: `Does this pull request potentially affect one of the following parts:` section.
   > 
   > Best,
   > Jincheng
   
   Highly appreciated for your review, I'll pay more attention to the commit info template in future PRs. 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] shuiqiangchen commented on a change in pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
shuiqiangchen commented on a change in pull request #12061:
URL: https://github.com/apache/flink/pull/12061#discussion_r422764493



##########
File path: flink-python/pyflink/java_gateway.py
##########
@@ -49,15 +49,19 @@ def get_gateway():
             # if Java Gateway is already running
             if 'PYFLINK_GATEWAY_PORT' in os.environ:
                 gateway_port = int(os.environ['PYFLINK_GATEWAY_PORT'])
-                callback_port = int(os.environ['PYFLINK_CALLBACK_PORT'])
                 gateway_param = GatewayParameters(port=gateway_port, auto_convert=True)
                 _gateway = JavaGateway(
                     gateway_parameters=gateway_param,
                     callback_server_parameters=CallbackServerParameters(
-                        port=callback_port, daemonize=True, daemonize_connections=True))
+                        port=0, daemonize=True, daemonize_connections=True))
             else:
                 _gateway = launch_gateway()
 
+            callback_server = _gateway.get_callback_server()
+            listening_callback_address = callback_server.get_listening_address()

Review comment:
       Thanks, I'll rename it to be more intuitive.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626432764


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924",
       "triggerID" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "triggerType" : "PUSH"
     }, {
       "hash" : "da1bf1e181793e94b1c9147546e15101e87e066f",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=936",
       "triggerID" : "da1bf1e181793e94b1c9147546e15101e87e066f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * da1bf1e181793e94b1c9147546e15101e87e066f Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=936) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626426511


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit d07c04b5ac978764112af3bf1d35285195e3440d (Mon May 11 01:35:42 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-17454).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] shuiqiangchen commented on a change in pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
shuiqiangchen commented on a change in pull request #12061:
URL: https://github.com/apache/flink/pull/12061#discussion_r422764356



##########
File path: flink-python/src/main/java/org/apache/flink/client/python/PythonEnvUtils.java
##########
@@ -300,6 +294,48 @@ static GatewayServer startGatewayServer() throws ExecutionException, Interrupted
 		return gatewayServerFuture.get();
 	}
 
+	/**
+	 * Reset a daemon thread to the callback client thread pool so that the callback server can be terminated when gate
+	 * way server is shutting down. We need to shut down the none-daemon thread firstly, then set a new thread created
+	 * in a daemon thread to the ExecutorService.
+	 *
+	 * @param gatewayServer the gateway which creates the callback server.
+	 * */
+	private static void resetCallbackClientExecutorService(GatewayServer gatewayServer) throws NoSuchFieldException,
+		IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+		CallbackClient callbackClient = (CallbackClient) gatewayServer.getCallbackClient();
+		// The Java API of py4j does not provide approach to set "daemonize_connections" parameter.
+		// Use reflect to daemonize the connection thread.
+		Field executor = CallbackClient.class.getDeclaredField("executor");
+		executor.setAccessible(true);
+		((ScheduledExecutorService) executor.get(callbackClient)).shutdown();
+		executor.set(callbackClient, Executors.newScheduledThreadPool(1, Thread::new));
+		Method setupCleaner = CallbackClient.class.getDeclaredMethod("setupCleaner");
+		setupCleaner.setAccessible(true);
+		setupCleaner.invoke(callbackClient);
+	}
+
+	/**
+	 * Reset the callback client of gatewayServer with the given callbackListeningAddress and callbackListeningPort
+	 * after the callback server started.
+	 *
+	 * @param callbackListeningAddress the listening address of the callback server.
+	 * @param callbackListeningPort the listening port of the callback server.
+	 * */
+	public static void resetCallbackClient(String callbackListeningAddress, int callbackListeningPort) throws
+		UnknownHostException, InvocationTargetException, NoSuchMethodException, IllegalAccessException,
+		NoSuchFieldException {
+
+		gatewayServer = getGatewayServer();
+		if (gatewayServer == null){

Review comment:
       Yes, there is no need do this judgement I'll remove it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626432764


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d07c04b5ac978764112af3bf1d35285195e3440d UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] shuiqiangchen commented on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
shuiqiangchen commented on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626519077


   > Thanks for the PR @shuiqiangchen !
   > I think the failure of the test is caused by https://issues.apache.org/jira/browse/FLINK-17601
   > So, LGTM +1 to merged.
   > 
   > One suggestion is for the next PR description, fill in all the contents specified in the template, such as: `Does this pull request potentially affect one of the following parts:` section.
   > 
   > Best,
   > Jincheng
   Highly appreciated for your review, I'll pay more attention to the commit info template in future PRs. 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626432764


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924",
       "triggerID" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "triggerType" : "PUSH"
     }, {
       "hash" : "da1bf1e181793e94b1c9147546e15101e87e066f",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=936",
       "triggerID" : "da1bf1e181793e94b1c9147546e15101e87e066f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d07c04b5ac978764112af3bf1d35285195e3440d Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924) 
   * da1bf1e181793e94b1c9147546e15101e87e066f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=936) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626432764


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924",
       "triggerID" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "triggerType" : "PUSH"
     }, {
       "hash" : "da1bf1e181793e94b1c9147546e15101e87e066f",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "da1bf1e181793e94b1c9147546e15101e87e066f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d07c04b5ac978764112af3bf1d35285195e3440d Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924) 
   * da1bf1e181793e94b1c9147546e15101e87e066f UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626432764


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924",
       "triggerID" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d07c04b5ac978764112af3bf1d35285195e3440d Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12061:
URL: https://github.com/apache/flink/pull/12061#issuecomment-626432764


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924",
       "triggerID" : "d07c04b5ac978764112af3bf1d35285195e3440d",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d07c04b5ac978764112af3bf1d35285195e3440d Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=924) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] dianfu commented on a change in pull request #12061: [FLINK-17454][python]python gateway callback server port should not b…

Posted by GitBox <gi...@apache.org>.
dianfu commented on a change in pull request #12061:
URL: https://github.com/apache/flink/pull/12061#discussion_r422746320



##########
File path: flink-python/src/main/java/org/apache/flink/client/python/PythonEnvUtils.java
##########
@@ -300,6 +294,48 @@ static GatewayServer startGatewayServer() throws ExecutionException, Interrupted
 		return gatewayServerFuture.get();
 	}
 
+	/**
+	 * Reset a daemon thread to the callback client thread pool so that the callback server can be terminated when gate
+	 * way server is shutting down. We need to shut down the none-daemon thread firstly, then set a new thread created
+	 * in a daemon thread to the ExecutorService.
+	 *
+	 * @param gatewayServer the gateway which creates the callback server.
+	 * */
+	private static void resetCallbackClientExecutorService(GatewayServer gatewayServer) throws NoSuchFieldException,
+		IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+		CallbackClient callbackClient = (CallbackClient) gatewayServer.getCallbackClient();
+		// The Java API of py4j does not provide approach to set "daemonize_connections" parameter.
+		// Use reflect to daemonize the connection thread.
+		Field executor = CallbackClient.class.getDeclaredField("executor");
+		executor.setAccessible(true);
+		((ScheduledExecutorService) executor.get(callbackClient)).shutdown();
+		executor.set(callbackClient, Executors.newScheduledThreadPool(1, Thread::new));
+		Method setupCleaner = CallbackClient.class.getDeclaredMethod("setupCleaner");
+		setupCleaner.setAccessible(true);
+		setupCleaner.invoke(callbackClient);
+	}
+
+	/**
+	 * Reset the callback client of gatewayServer with the given callbackListeningAddress and callbackListeningPort
+	 * after the callback server started.
+	 *
+	 * @param callbackListeningAddress the listening address of the callback server.
+	 * @param callbackListeningPort the listening port of the callback server.
+	 * */
+	public static void resetCallbackClient(String callbackListeningAddress, int callbackListeningPort) throws
+		UnknownHostException, InvocationTargetException, NoSuchMethodException, IllegalAccessException,
+		NoSuchFieldException {
+
+		gatewayServer = getGatewayServer();
+		if (gatewayServer == null){

Review comment:
       It seems that it is never `null`.

##########
File path: flink-python/pyflink/java_gateway.py
##########
@@ -49,15 +49,19 @@ def get_gateway():
             # if Java Gateway is already running
             if 'PYFLINK_GATEWAY_PORT' in os.environ:
                 gateway_port = int(os.environ['PYFLINK_GATEWAY_PORT'])
-                callback_port = int(os.environ['PYFLINK_CALLBACK_PORT'])
                 gateway_param = GatewayParameters(port=gateway_port, auto_convert=True)
                 _gateway = JavaGateway(
                     gateway_parameters=gateway_param,
                     callback_server_parameters=CallbackServerParameters(
-                        port=callback_port, daemonize=True, daemonize_connections=True))
+                        port=0, daemonize=True, daemonize_connections=True))
             else:
                 _gateway = launch_gateway()
 
+            callback_server = _gateway.get_callback_server()
+            listening_callback_address = callback_server.get_listening_address()

Review comment:
       rename to `callback_server_listening_address` and `callback_server_listening_port `




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org