Apache Mesos
health_checker.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __HEALTH_CHECKER_HPP__
18 #define __HEALTH_CHECKER_HPP__
19 
20 #include <string>
21 #include <vector>
22 
23 #include <mesos/mesos.hpp>
24 
25 #include <process/http.hpp>
26 #include <process/owned.hpp>
27 
28 #include <stout/error.hpp>
29 #include <stout/lambda.hpp>
30 #include <stout/option.hpp>
31 #include <stout/variant.hpp>
32 
34 #include "checks/checks_types.hpp"
35 
36 #include "messages/messages.hpp"
37 
38 namespace mesos {
39 namespace internal {
40 namespace checks {
41 
42 class CheckerProcess;
43 
44 
46 {
47 public:
69  const HealthCheck& healthCheck,
70  const std::string& launcherDir,
71  const lambda::function<void(const TaskHealthStatus&)>& callback,
72  const TaskID& taskId,
74 
76 
77  // Idempotent helpers for pausing and resuming health checking.
78  void pause();
79  void resume();
80 
81 private:
83  const HealthCheck& _healthCheck,
84  const std::string& launcherDir,
85  const lambda::function<void(const TaskHealthStatus&)>& _callback,
86  const TaskID& _taskId,
88 
89  void processCheckResult(const Try<CheckStatusInfo>& result);
90  void failure();
91  void success();
92 
93  const HealthCheck healthCheck;
94  const lambda::function<void(const TaskHealthStatus&)> callback;
95  const TaskID taskId;
96 
97  const std::string name;
98  const process::Time startTime;
99 
100  Duration checkGracePeriod;
101  uint32_t consecutiveFailures;
102  bool initializing;
103 
105 };
106 
107 } // namespace checks {
108 } // namespace internal {
109 } // namespace mesos {
110 
111 #endif // __HEALTH_CHECKER_HPP__
Definition: check.hpp:33
Definition: duration.hpp:32
Definition: agent.hpp:25
Definition: time.hpp:23
Definition: attributes.hpp:24
Definition: executor.hpp:48
Definition: owned.hpp:36
static Try< process::Owned< HealthChecker > > create(const HealthCheck &healthCheck, const std::string &launcherDir, const lambda::function< void(const TaskHealthStatus &)> &callback, const TaskID &taskId, Variant< runtime::Plain, runtime::Docker, runtime::Nested > runtime)
Attempts to create a HealthChecker object.
Definition: health_checker.hpp:45