You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2016/11/25 15:19:42 UTC

[03/11] mesos git commit: Refactored HealthChecker::reschedule to take duration as an argument.

Refactored HealthChecker::reschedule to take duration as an argument.

To facilitate code reuse, HealthChecker::reschedule() is generalized.
This will become even more valuable when we add pause/resume functions.

Review: https://reviews.apache.org/r/52866/


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

Branch: refs/heads/master
Commit: bbe3b6405c7817e3e0f8e2b5b93953325188b42a
Parents: 89e4128
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Fri Nov 25 16:13:32 2016 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Nov 25 16:13:32 2016 +0100

----------------------------------------------------------------------
 src/health-check/health_checker.cpp | 21 ++++++++-------------
 src/health-check/health_checker.hpp |  3 ++-
 2 files changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bbe3b640/src/health-check/health_checker.cpp
----------------------------------------------------------------------
diff --git a/src/health-check/health_checker.cpp b/src/health-check/health_checker.cpp
index 4a02e86..c118ca5 100644
--- a/src/health-check/health_checker.cpp
+++ b/src/health-check/health_checker.cpp
@@ -185,16 +185,14 @@ HealthCheckerProcess::HealthCheckerProcess(
 
 void HealthCheckerProcess::initialize()
 {
-  VLOG(1) << "Health check starting in "
+  VLOG(1) << "Health check starts in "
           << Seconds(static_cast<int64_t>(check.delay_seconds()))
           << ", grace period "
           << Seconds(static_cast<int64_t>(check.grace_period_seconds()));
 
   startTime = Clock::now();
 
-  delay(Seconds(static_cast<int64_t>(check.delay_seconds())),
-        self(),
-        &Self::performSingleCheck);
+  scheduleNext(Seconds(static_cast<int64_t>(check.delay_seconds())));
 }
 
 
@@ -204,7 +202,7 @@ void HealthCheckerProcess::failure(const string& message)
       check.grace_period_seconds() > 0 &&
       (Clock::now() - startTime).secs() <= check.grace_period_seconds()) {
     LOG(INFO) << "Ignoring failure as health check still in grace period";
-    reschedule();
+    scheduleNext(Seconds(static_cast<int64_t>(check.interval_seconds())));
     return;
   }
 
@@ -228,7 +226,7 @@ void HealthCheckerProcess::failure(const string& message)
   // Even if we set the `kill_task` flag, it is an executor who kills the task
   // and honors the flag (or not). We have no control over the task's lifetime,
   // hence we should continue until we are explicitly asked to stop.
-  reschedule();
+  scheduleNext(Seconds(static_cast<int64_t>(check.interval_seconds())));
 }
 
 
@@ -247,7 +245,7 @@ void HealthCheckerProcess::success()
   }
 
   consecutiveFailures = 0;
-  reschedule();
+  scheduleNext(Seconds(static_cast<int64_t>(check.interval_seconds())));
 }
 
 
@@ -610,14 +608,11 @@ Future<Nothing> HealthCheckerProcess::_tcpHealthCheck(
 }
 
 
-void HealthCheckerProcess::reschedule()
+void HealthCheckerProcess::scheduleNext(const Duration& duration)
 {
-  VLOG(1) << "Rescheduling health check in "
-          << Seconds(static_cast<int64_t>(check.interval_seconds()));
+  VLOG(1) << "Scheduling health check in " << duration;
 
-  delay(Seconds(static_cast<int64_t>(check.interval_seconds())),
-        self(),
-        &Self::performSingleCheck);
+  delay(duration, self(), &Self::performSingleCheck);
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/bbe3b640/src/health-check/health_checker.hpp
----------------------------------------------------------------------
diff --git a/src/health-check/health_checker.hpp b/src/health-check/health_checker.hpp
index ce0a232..31ed744 100644
--- a/src/health-check/health_checker.hpp
+++ b/src/health-check/health_checker.hpp
@@ -30,6 +30,7 @@
 #include <process/protobuf.hpp>
 #include <process/time.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/nothing.hpp>
 
 #include "messages/messages.hpp"
@@ -117,7 +118,7 @@ private:
           process::Future<std::string>,
           process::Future<std::string>>& t);
 
-  void reschedule();
+  void scheduleNext(const Duration& duration);
 
   HealthCheck check;
   std::string launcherDir;