You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by ma...@apache.org on 2016/11/01 02:18:50 UTC

reef git commit: [REEF-1655] Close the driver restart manager on driver shutdown

Repository: reef
Updated Branches:
  refs/heads/master 5f4591083 -> 8ef0c4e2a


[REEF-1655] Close the driver restart manager on driver shutdown

  * Make `DriverRuntimeRestartManager` implement `AutoCloseable` to shut down the timer thread;
  * Invoke `.close()` method in `DriverRuntimeStopHandler` on driver shutdown

JIRA:
  [REEF-1655](https://issues.apache.org/jira/browse/REEF-1655)

Pull request:
  This closes #1170


Project: http://git-wip-us.apache.org/repos/asf/reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/8ef0c4e2
Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/8ef0c4e2
Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/8ef0c4e2

Branch: refs/heads/master
Commit: 8ef0c4e2a20da78d4547a9c31f6fa86c37d7678f
Parents: 5f45910
Author: Sergiy Matusevych <mo...@apache.org>
Authored: Thu Oct 27 15:38:22 2016 -0700
Committer: Mariia Mykhailova <ma...@apache.org>
Committed: Mon Oct 31 16:55:19 2016 -0700

----------------------------------------------------------------------
 .../reef/driver/restart/DriverRestartManager.java    | 15 +++++++++++++--
 .../common/driver/DriverRuntimeStopHandler.java      | 12 +++++++++---
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/reef/blob/8ef0c4e2/lang/java/reef-common/src/main/java/org/apache/reef/driver/restart/DriverRestartManager.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/restart/DriverRestartManager.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/restart/DriverRestartManager.java
index 58c809e..c8f9f24 100644
--- a/lang/java/reef-common/src/main/java/org/apache/reef/driver/restart/DriverRestartManager.java
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/restart/DriverRestartManager.java
@@ -44,15 +44,17 @@ import java.util.logging.Logger;
 @DriverSide
 @Private
 @Unstable
-public final class DriverRestartManager implements DriverIdlenessSource {
+public final class DriverRestartManager implements DriverIdlenessSource, AutoCloseable {
+
   private static final String CLASS_NAME = DriverRestartManager.class.getName();
   private static final Logger LOG = Logger.getLogger(CLASS_NAME);
 
+  private final Timer restartCompletedTimer = new Timer(this.getClass().getSimpleName() + ":Timer");
+
   private final DriverRuntimeRestartManager driverRuntimeRestartManager;
   private final Set<EventHandler<DriverRestartCompleted>> driverRestartCompletedHandlers;
   private final Set<EventHandler<DriverRestartCompleted>> serviceDriverRestartCompletedHandlers;
   private final int driverRestartEvaluatorRecoverySeconds;
-  private final Timer restartCompletedTimer = new Timer();
 
   private RestartEvaluators restartEvaluators;
   private DriverRestartState state = DriverRestartState.NOT_RESTARTED;
@@ -335,4 +337,13 @@ public final class DriverRestartManager implements DriverIdlenessSource {
         CLASS_NAME + " currently in the process of restart.";
     return new IdleMessage(CLASS_NAME, idleMessage, idleState);
   }
+
+  /**
+   * Close the restart timer.
+   */
+  @Override
+  public void close() {
+    LOG.log(Level.FINER, "Closing restart timer. Final state: {0}", this.state);
+    this.restartCompletedTimer.cancel();
+  }
 }

http://git-wip-us.apache.org/repos/asf/reef/blob/8ef0c4e2/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/DriverRuntimeStopHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/DriverRuntimeStopHandler.java b/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/DriverRuntimeStopHandler.java
index 678a596..d344cf3 100644
--- a/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/DriverRuntimeStopHandler.java
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/driver/DriverRuntimeStopHandler.java
@@ -21,6 +21,7 @@ package org.apache.reef.runtime.common.driver;
 import org.apache.reef.annotations.audience.DriverSide;
 import org.apache.reef.annotations.audience.Private;
 import org.apache.reef.driver.parameters.ResourceManagerPreserveEvaluators;
+import org.apache.reef.driver.restart.DriverRestartManager;
 import org.apache.reef.exception.DriverFatalRuntimeException;
 import org.apache.reef.runtime.common.driver.api.ResourceManagerStopHandler;
 import org.apache.reef.runtime.common.driver.evaluator.Evaluators;
@@ -44,6 +45,7 @@ final class DriverRuntimeStopHandler implements EventHandler<RuntimeStop> {
 
   private static final Logger LOG = Logger.getLogger(DriverRuntimeStopHandler.class.getName());
 
+  private final DriverRestartManager driverRestartManager;
   private final DriverStatusManager driverStatusManager;
   private final ResourceManagerStopHandler resourceManagerStopHandler;
   private final RemoteManager remoteManager;
@@ -51,13 +53,15 @@ final class DriverRuntimeStopHandler implements EventHandler<RuntimeStop> {
   private final boolean preserveEvaluatorsAcrossRestarts;
 
   @Inject
-  DriverRuntimeStopHandler(
+  private DriverRuntimeStopHandler(
+      @Parameter(ResourceManagerPreserveEvaluators.class) final boolean preserveEvaluatorsAcrossRestarts,
+      final DriverRestartManager driverRestartManager,
       final DriverStatusManager driverStatusManager,
       final ResourceManagerStopHandler resourceManagerStopHandler,
       final RemoteManager remoteManager,
-      final Evaluators evaluators,
-      @Parameter(ResourceManagerPreserveEvaluators.class) final boolean preserveEvaluatorsAcrossRestarts) {
+      final Evaluators evaluators) {
 
+    this.driverRestartManager = driverRestartManager;
     this.driverStatusManager = driverStatusManager;
     this.resourceManagerStopHandler = resourceManagerStopHandler;
     this.remoteManager = remoteManager;
@@ -93,5 +97,7 @@ final class DriverRuntimeStopHandler implements EventHandler<RuntimeStop> {
       LOG.log(Level.WARNING, "Error when closing the RemoteManager", e);
       throw new RuntimeException("Unable to close the RemoteManager.", e);
     }
+
+    this.driverRestartManager.close();
   }
 }