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  virtual ~LoadQoSController();
59 
60  virtual Try<Nothing> initialize(
61  const lambda::function<process::Future<ResourceUsage>()>& usage);
62 
64 
65 private:
66  const Option<double> loadThreshold5Min;
67  const Option<double> loadThreshold15Min;
68  const lambda::function<Try<os::Load>()> loadAverage;
70 };
71 
72 } // namespace slave {
73 } // namespace internal {
74 } // namespace mesos {
75 
76 #endif // __SLAVE_QOS_CONTROLLERS_LOAD_HPP__
Definition: try.hpp:34
virtual Try< Nothing > initialize(const lambda::function< process::Future< ResourceUsage >()> &usage)
Try< Load > loadavg()
Definition: os.hpp:279
Try< ResourceStatistics > usage(pid_t pid, bool mem=true, bool cpus=true)
LoadQoSController(const Option< double > &_loadThreshold5Min, const Option< double > &_loadThreshold15Min, const lambda::function< Try< os::Load >()> &_loadAverage=[](){return os::loadavg();})
Definition: load.hpp:49
virtual process::Future< std::list< mesos::slave::QoSCorrection > > corrections()
Definition: qos_controller.hpp:44
Definition: future.hpp:57