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/08/13 01:46:07 UTC

[3/6] mesos git commit: Dispatched health check by type.

Dispatched health check by type.

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


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

Branch: refs/heads/master
Commit: 72efadff0e76b55208baa4e27f5e91d248d4a63c
Parents: 1a6284b
Author: haosdent huang <ha...@gmail.com>
Authored: Sat Aug 13 02:17:03 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Sat Aug 13 03:43:18 2016 +0200

----------------------------------------------------------------------
 src/health-check/health_checker.cpp | 47 ++++++++++++++++++++++++++++++--
 src/health-check/health_checker.hpp |  5 +++-
 2 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/72efadff/src/health-check/health_checker.cpp
----------------------------------------------------------------------
diff --git a/src/health-check/health_checker.cpp b/src/health-check/health_checker.cpp
index 50d598e..becf145 100644
--- a/src/health-check/health_checker.cpp
+++ b/src/health-check/health_checker.cpp
@@ -181,10 +181,33 @@ void HealthCheckerProcess::success()
 
 void HealthCheckerProcess::_healthCheck()
 {
-  if (check.type() != HealthCheck::COMMAND) {
-    promise.fail("Only command health checks are supported");
-    return;
+  switch (check.type()) {
+    case HealthCheck::COMMAND: {
+      _commandHealthCheck();
+      return;
+    }
+
+    case HealthCheck::HTTP: {
+      _httpHealthCheck();
+      return;
+    }
+
+    case HealthCheck::TCP: {
+      _tcpHealthCheck();
+      return;
+    }
+
+    default: {
+      UNREACHABLE();
+    }
   }
+}
+
+
+void HealthCheckerProcess::_commandHealthCheck()
+{
+  CHECK_EQ(HealthCheck::COMMAND, check.type());
+  CHECK(check.has_command());
 
   const CommandInfo& command = check.command();
 
@@ -274,6 +297,24 @@ void HealthCheckerProcess::_healthCheck()
 }
 
 
+void HealthCheckerProcess::_httpHealthCheck()
+{
+  CHECK_EQ(HealthCheck::HTTP, check.type());
+  CHECK(check.has_http());
+
+  promise.fail("HTTP health check is not supported");
+}
+
+
+void HealthCheckerProcess::_tcpHealthCheck()
+{
+  CHECK_EQ(HealthCheck::TCP, check.type());
+  CHECK(check.has_tcp());
+
+  promise.fail("TCP health check is not supported");
+}
+
+
 void HealthCheckerProcess::reschedule()
 {
   VLOG(1) << "Rescheduling health check in "

http://git-wip-us.apache.org/repos/asf/mesos/blob/72efadff/src/health-check/health_checker.hpp
----------------------------------------------------------------------
diff --git a/src/health-check/health_checker.hpp b/src/health-check/health_checker.hpp
index 3b40ee6..00a14c6 100644
--- a/src/health-check/health_checker.hpp
+++ b/src/health-check/health_checker.hpp
@@ -71,11 +71,14 @@ public:
 
 private:
   void failure(const std::string& message);
-
   void success();
 
   void _healthCheck();
 
+  void _commandHealthCheck();
+  void _httpHealthCheck();
+  void _tcpHealthCheck();
+
   void reschedule();
 
   process::Promise<Nothing> promise;