xintongsong commented on a change in pull request #11284: [FLINK-15911][runtime] Make Flink work with NAT. URL: https://github.com/apache/flink/pull/11284#discussion_r395425038
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java ########## @@ -82,92 +82,80 @@ .build(); /** - * Starts an ActorSystem with the given configuration listening at the address/ports. + * Starts a remote ActorSystem at given address and specific port range. * @param configuration The Flink configuration - * @param listeningAddress The address to listen at. - * @param portRangeDefinition The port range to choose a port from. + * @param externalAddress The external address to access the ActorSystem. + * @param externalPortRange The choosing range of the external port to access the ActorSystem. * @param logger The logger to output log information. * @return The ActorSystem which has been started * @throws Exception Thrown when actor system cannot be started in specified port range */ - public static ActorSystem startActorSystem( + @VisibleForTesting + public static ActorSystem startRemoteActorSystem( Configuration configuration, - String listeningAddress, - String portRangeDefinition, + String externalAddress, + String externalPortRange, Logger logger) throws Exception { - return startActorSystem( - configuration, - listeningAddress, - portRangeDefinition, - logger, - ForkJoinExecutorConfiguration.fromConfiguration(configuration)); - } - - /** - * Starts an ActorSystem with the given configuration listening at the address/ports. - * - * @param configuration The Flink configuration - * @param listeningAddress The address to listen at. - * @param portRangeDefinition The port range to choose a port from. - * @param logger The logger to output log information. - * @param actorSystemExecutorConfiguration configuration for the ActorSystem's underlying executor - * @return The ActorSystem which has been started - * @throws Exception Thrown when actor system cannot be started in specified port range - */ - public static ActorSystem startActorSystem( - Configuration configuration, - String listeningAddress, - String portRangeDefinition, - Logger logger, - @Nonnull ActorSystemExecutorConfiguration actorSystemExecutorConfiguration) throws Exception { - return startActorSystem( + return startRemoteActorSystem( configuration, AkkaUtils.getFlinkActorSystemName(), - listeningAddress, - portRangeDefinition, + externalAddress, + externalPortRange, + NetUtils.getWildcardIPAddress(), + -1, logger, - actorSystemExecutorConfiguration); + ForkJoinExecutorConfiguration.fromConfiguration(configuration), + null); } /** - * Starts an ActorSystem with the given configuration listening at the address/ports. + * Starts a remote ActorSystem at given address and specific port range. * * @param configuration The Flink configuration * @param actorSystemName Name of the started {@link ActorSystem} - * @param listeningAddress The address to listen at. - * @param portRangeDefinition The port range to choose a port from. + * @param externalAddress The external address to access the ActorSystem. + * @param externalPortRange The choosing range of the external port to access the ActorSystem. + * @param bindAddress The local address to bind to. + * @param bindPort The local port to bind to. If negative, external port will be used. * @param logger The logger to output log information. * @param actorSystemExecutorConfiguration configuration for the ActorSystem's underlying executor + * @param customConfig Custom Akka config to be combined with the config derived from Flink configuration. * @return The ActorSystem which has been started * @throws Exception Thrown when actor system cannot be started in specified port range */ - public static ActorSystem startActorSystem( + public static ActorSystem startRemoteActorSystem( Configuration configuration, String actorSystemName, - String listeningAddress, - String portRangeDefinition, + String externalAddress, + String externalPortRange, + String bindAddress, + int bindPort, Review comment: Actually, I also thought about making the bindPort Optional. However I also noticed that the code style guide suggests to use Optional only for return values of API/public methods, but not for class fields and method arguments. Not sure if it's ok to not strictly following the guide. We do have a good reason to use Optional here. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services