You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by nw...@apache.org on 2019/01/18 00:25:42 UTC
[incubator-heron] branch master updated: Support instance
healthcheck api (#3157)
This is an automated email from the ASF dual-hosted git repository.
nwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/master by this push:
new 1c0f161 Support instance healthcheck api (#3157)
1c0f161 is described below
commit 1c0f1612e3b565f3c099611980cac7f45ccdb791
Author: se choi <th...@gmail.com>
AuthorDate: Fri Jan 18 09:25:37 2019 +0900
Support instance healthcheck api (#3157)
* Support health check API of Mesos/Aurora/Marathon.
* http://aurora.apache.org/documentation/latest/reference/configuration/#healthcheckconfig-objects
* https://mesos.readthedocs.io/en/latest/health-checks/
* https://mesosphere.github.io/marathon/docs/health-checks.html
* Add example of Aurora
* Smooth setting.
---
heron/config/src/yaml/conf/aurora/heron.aurora | 11 +++++++-
heron/shell/src/python/handlers/__init__.py | 1 +
heron/shell/src/python/handlers/healthhandler.py | 32 ++++++++++++++++++++++++
heron/shell/src/python/main.py | 1 +
4 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/heron/config/src/yaml/conf/aurora/heron.aurora b/heron/config/src/yaml/conf/aurora/heron.aurora
index 5f6facc..d32c83b 100644
--- a/heron/config/src/yaml/conf/aurora/heron.aurora
+++ b/heron/config/src/yaml/conf/aurora/heron.aurora
@@ -79,6 +79,15 @@ jobs = [
service = True,
task = heron_task,
instances = '{{NUM_CONTAINERS}}',
- announce = Announcer(primary_port = 'http')
+ announce = Announcer(primary_port = 'http', portmap = {'health': 'http'}),
+ health_check_config = HealthCheckConfig(
+ health_checker = HealthCheckerConfig(
+ http = HttpHealthChecker(endpoint='/health', expected_response='ok', expected_response_code=200)
+ ),
+ initial_interval_secs=30,
+ interval_secs=10,
+ max_consecutive_failures=2,
+ timeout_secs=5
+ )
)
]
diff --git a/heron/shell/src/python/handlers/__init__.py b/heron/shell/src/python/handlers/__init__.py
index 2e285ce..264022b 100644
--- a/heron/shell/src/python/handlers/__init__.py
+++ b/heron/shell/src/python/handlers/__init__.py
@@ -26,3 +26,4 @@ from memoryhistogramhandler import MemoryHistogramHandler
from pmaphandler import PmapHandler
from pidhandler import PidHandler
from killexecutorhandler import KillExecutorHandler
+from healthhandler import HealthHandler
diff --git a/heron/shell/src/python/handlers/healthhandler.py b/heron/shell/src/python/handlers/healthhandler.py
new file mode 100644
index 0000000..26bd667
--- /dev/null
+++ b/heron/shell/src/python/handlers/healthhandler.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+# Copyright 2016 Twitter. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+""" healthhandler.py """
+import tornado.web
+
+class HealthHandler(tornado.web.RequestHandler):
+ """
+ Responsible for health check an instance.
+ """
+
+ # pylint: disable=attribute-defined-outside-init
+ @tornado.web.asynchronous
+ def get(self):
+ """ get method """
+ self.content_type = 'plain/text'
+ self.write('ok')
+ self.finish()
diff --git a/heron/shell/src/python/main.py b/heron/shell/src/python/main.py
index 34986f6..0f375c8 100644
--- a/heron/shell/src/python/main.py
+++ b/heron/shell/src/python/main.py
@@ -41,6 +41,7 @@ default_handlers = [
(r"^/filestats/(.*)", handlers.FileStatsHandler),
(r"^/download/(.*)", handlers.DownloadHandler),
(r"^/killexecutor", handlers.KillExecutorHandler),
+ (r"^/health", handlers.HealthHandler),
]
# pylint: disable=dangerous-default-value