Apache Mesos
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 __CHECKER_HPP__
18 #define __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/try.hpp>
32 #include <stout/variant.hpp>
33 
35 #include "checks/checks_types.hpp"
36 
37 namespace mesos {
38 namespace internal {
39 namespace checks {
40 
41 class CheckerProcess;
42 
43 
44 class Checker
45 {
46 public:
66  const CheckInfo& check,
67  const std::string& launcherDir,
68  const lambda::function<void(const CheckStatusInfo&)>& callback,
69  const TaskID& taskId,
71 
72  ~Checker();
73 
74  // Not copyable, not assignable.
75  Checker(const Checker&) = delete;
76  Checker& operator=(const Checker&) = delete;
77 
78  // Idempotent helpers for pausing and resuming checking.
79  void pause();
80  void resume();
81 
82 private:
83  Checker(
84  const CheckInfo& _check,
85  const std::string& _launcherDir,
86  const lambda::function<void(const CheckStatusInfo&)>& _callback,
87  const TaskID& _taskId,
89 
90  void processCheckResult(const Try<CheckStatusInfo>& result);
91 
92  const CheckInfo check;
93  const lambda::function<void(const CheckStatusInfo&)> callback;
94  const TaskID taskId;
95  const std::string name;
96 
97  CheckStatusInfo previousCheckStatus;
99 };
100 
101 } // namespace checks {
102 } // namespace internal {
103 } // namespace mesos {
104 
105 #endif // __CHECKER_HPP__
Definition: checker.hpp:44
Definition: check.hpp:33
Checker & operator=(const Checker &)=delete
Definition: agent.hpp:25
static Try< process::Owned< Checker > > create(const CheckInfo &check, const std::string &launcherDir, const lambda::function< void(const CheckStatusInfo &)> &callback, const TaskID &taskId, Variant< runtime::Plain, runtime::Docker, runtime::Nested > runtime)
Attempts to create a Checker object.
Checker(const Checker &)=delete
Definition: attributes.hpp:24
Definition: executor.hpp:48
Definition: checker_process.hpp:48
Definition: owned.hpp:36