Apache Mesos
load.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 __SLAVE_QOS_CONTROLLERS_LOAD_HPP__
18 #define __SLAVE_QOS_CONTROLLERS_LOAD_HPP__
19 
20 #include <list>
21 
23 
24 #include <stout/lambda.hpp>
25 #include <stout/os/os.hpp>
26 #include <stout/try.hpp>
27 
28 #include <process/future.hpp>
29 #include <process/owned.hpp>
30 
31 namespace mesos {
32 namespace internal {
33 namespace slave {
34 
35 // Forward declaration.
36 class LoadQoSControllerProcess;
37 
38 
39 // The `LoadQoSController` is a simple QoS Controller, which is
40 // responsible for eviction of all the revocable executors when
41 // system load (5min or 15min) is above the configured threshold.
42 // NOTE: 1 minute system load is ignored, because
43 // for most use cases it is a misleading signal.
45 {
46 public:
47  // NOTE: In constructor we can pass lambda for fetching load average as
48  // an optional argument. This was done for the test purposes.
50  const Option<double>& _loadThreshold5Min,
51  const Option<double>& _loadThreshold15Min,
52  const lambda::function<Try<os::Load>()>& _loadAverage =
53  [](){ return os::loadavg(); })
54  : loadThreshold5Min(_loadThreshold5Min),
55  loadThreshold15Min(_loadThreshold15Min),
56  loadAverage(_loadAverage) {}
57 
58  ~LoadQoSController() override;
59 
61  const lambda::function<process::Future<ResourceUsage>()>& usage) override;
62 
64  override;
65 
66 private:
67  const Option<double> loadThreshold5Min;
68  const Option<double> loadThreshold15Min;
69  const lambda::function<Try<os::Load>()> loadAverage;
71 };
72 
73 } // namespace slave {
74 } // namespace internal {
75 } // namespace mesos {
76 
77 #endif // __SLAVE_QOS_CONTROLLERS_LOAD_HPP__
process::Future< std::list< mesos::slave::QoSCorrection > > corrections() override
Definition: check.hpp:33
Try< Nothing > initialize(const lambda::function< process::Future< ResourceUsage >()> &usage) override
Try< Load > loadavg()
Definition: os.hpp:280
Try< ResourceStatistics > usage(pid_t pid, bool mem=true, bool cpus=true)
Definition: agent.hpp:25
Definition: attributes.hpp:24
LoadQoSController(const Option< double > &_loadThreshold5Min, const Option< double > &_loadThreshold15Min, const lambda::function< Try< os::Load >()> &_loadAverage=[](){return os::loadavg();})
Definition: load.hpp:49
Definition: executor.hpp:48
Definition: qos_controller.hpp:44
Definition: future.hpp:58