Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4289#discussion_r130078259
  
    --- Diff: 
flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/MesosResourceManager.java
 ---
    @@ -312,6 +318,114 @@ private void recoverWorkers() throws Exception {
        }
     
        @Override
    +   public void shutDown() throws Exception {
    +           // shut down all components
    +           Future<Boolean> stopTaskMonitorFuture = null;
    +           Future<Boolean> stopConnectionMonitorFuture = null;
    +           Future<Boolean> stopLaunchCoordinatorFuture = null;
    +           Future<Boolean> stopReconciliationCoordinatorFuture = null;
    +
    +           FiniteDuration stopTimeout = null;
    +
    +           Exception exception = null;
    +
    +           if (taskMonitor != null) {
    +                   stopTimeout = new FiniteDuration(1L, TimeUnit.SECONDS);
    +                   stopTaskMonitorFuture = 
Patterns.gracefulStop(taskMonitor, stopTimeout);
    +           }
    +
    +           if (stopTaskMonitorFuture != null) {
    +                   boolean stopped = false;
    +
    +                   try {
    +                           stopped = Await.result(stopTaskMonitorFuture, 
stopTimeout);
    +                   } catch (Exception ex) {
    +                           exception = new Exception("TaskMonitor actor 
did not properly stop.", ex);
    +                   }
    +
    +                   if (!stopped) {
    +                           // the taskMonitor actor did not stop in time, 
let's kill him
    +                           taskMonitor.tell(Kill.getInstance(), 
ActorRef.noSender());
    +                   }
    +           }
    +
    +           if (connectionMonitor != null) {
    +                   stopTimeout = new FiniteDuration(1L, TimeUnit.SECONDS);
    +                   stopConnectionMonitorFuture = 
Patterns.gracefulStop(connectionMonitor, stopTimeout);
    +           }
    +
    +           if (stopConnectionMonitorFuture != null) {
    +                   boolean stopped = false;
    +
    +                   try {
    +                           stopped = 
Await.result(stopConnectionMonitorFuture, stopTimeout);
    +                   } catch (Exception ex) {
    +                           exception = ExceptionUtils.firstOrSuppressed(
    +                                   new Exception("ConnectionMonitor actor 
did not properly stop.", ex),
    +                                   exception
    +                           );
    +                   }
    +
    +                   if (!stopped) {
    +                           // the connectionMonitor actor did not stop in 
time, let's kill him
    +                           connectionMonitor.tell(Kill.getInstance(), 
ActorRef.noSender());
    +                   }
    +           }
    +
    +           if (launchCoordinator != null) {
    +                   stopTimeout = new FiniteDuration(1L, TimeUnit.SECONDS);
    +                   stopLaunchCoordinatorFuture = 
Patterns.gracefulStop(launchCoordinator, stopTimeout);
    +           }
    +
    +           if (stopLaunchCoordinatorFuture != null) {
    +                   boolean stopped = false;
    +
    +                   try {
    +                           stopped = 
Await.result(stopLaunchCoordinatorFuture, stopTimeout);
    +                   } catch (Exception ex) {
    +                           exception = ExceptionUtils.firstOrSuppressed(
    +                                   new Exception("LaunchCoordinator actor 
did not properly stop.", ex),
    +                                   exception
    +                           );
    +                   }
    +
    +                   if (!stopped) {
    +                           // the launchCoordinator actor did not stop in 
time, let's kill him
    +                           launchCoordinator.tell(Kill.getInstance(), 
ActorRef.noSender());
    +                   }
    +           }
    +
    +           if (reconciliationCoordinator != null) {
    +                   stopTimeout = new FiniteDuration(1L, TimeUnit.SECONDS);
    +                   stopReconciliationCoordinatorFuture = 
Patterns.gracefulStop(reconciliationCoordinator, stopTimeout);
    +           }
    +
    +           if (stopReconciliationCoordinatorFuture != null) {
    +                   boolean stopped = false;
    +
    +                   try {
    +                           stopped = 
Await.result(stopReconciliationCoordinatorFuture, stopTimeout);
    +                   } catch (Exception ex) {
    +                           exception = ExceptionUtils.firstOrSuppressed(
    +                                   new 
Exception("ReconciliationCoordinator actor did not properly stop.", ex),
    +                                   exception
    +                           );
    +                   }
    +
    +                   if (!stopped) {
    +                           // the reconciliationCoordinator actor did not 
stop in time, let's kill him
    +                           
reconciliationCoordinator.tell(Kill.getInstance(), ActorRef.noSender());
    +                   }
    --- End diff --
    
    I think we can combine the different futures into a single future to wait 
on the shut down concurrently.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to