tillrohrmann commented on a change in pull request #11313: [FLINK-16373] Make 
JobManagerLeaderListener thread safe
URL: https://github.com/apache/flink/pull/11313#discussion_r393702121
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/JobLeaderService.java
 ##########
 @@ -251,90 +254,83 @@ private JobManagerLeaderListener(JobID jobId) {
                }
 
                public void stop() {
-                       stopped = true;
+                       synchronized (lock) {
+                               stopped = true;
 
-                       if (rpcConnection != null) {
-                               rpcConnection.close();
+                               if (rpcConnection != null) {
+                                       rpcConnection.close();
+                               }
                        }
                }
 
                public void reconnect() {
-                       if (stopped) {
-                               LOG.debug("Cannot reconnect because the 
JobManagerLeaderListener has already been stopped.");
-                       } else {
-                               final RegisteredRpcConnection<JobMasterId, 
JobMasterGateway, JMTMRegistrationSuccess> currentRpcConnection = rpcConnection;
-
-                               if (currentRpcConnection != null) {
-                                       if (currentRpcConnection.isConnected()) 
{
-
-                                               if 
(currentRpcConnection.tryReconnect()) {
-                                                       // double check for 
concurrent stop operation
-                                                       if (stopped) {
-                                                               
currentRpcConnection.close();
-                                                       }
-                                               } else {
-                                                       LOG.debug("Could not 
reconnect to the JobMaster {}.", currentRpcConnection.getTargetAddress());
-                                               }
+                       synchronized (lock) {
+                               if (stopped) {
+                                       LOG.debug("Cannot reconnect because the 
JobManagerLeaderListener has already been stopped.");
+                               } else {
+                                       if (rpcConnection != null) {
+                                               Preconditions.checkState(
+                                                       
rpcConnection.tryReconnect(),
 
 Review comment:
   Yes, good idea. I'll add 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:
[email protected]


With regards,
Apache Git Services

Reply via email to