Apache Mesos
subsystem.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 __CGROUPS_ISOLATOR_SUBSYSTEM_HPP__
18 #define __CGROUPS_ISOLATOR_SUBSYSTEM_HPP__
19 
20 #include <string>
21 
22 #include <mesos/resources.hpp>
23 
24 #include <mesos/slave/isolator.hpp>
25 
26 #include <process/future.hpp>
27 #include <process/owned.hpp>
28 #include <process/process.hpp>
29 
30 #include <stout/nothing.hpp>
31 #include <stout/try.hpp>
32 
33 #include "slave/flags.hpp"
34 
35 namespace mesos {
36 namespace internal {
37 namespace slave {
38 
39 class SubsystemProcess;
40 
44 class Subsystem
45 {
46 public:
57  const Flags& flags,
58  const std::string& name,
59  const std::string& hierarchy);
60 
61  // We have unique ownership of the wrapped process and
62  // enforce that objects of this class cannot be copied.
63  //
64  // TODO(bbannier): Remove this once MESOS-5122 is resolved.
65  Subsystem(const Subsystem&) = delete;
66  Subsystem& operator=(const Subsystem&) = delete;
67 
68  ~Subsystem();
69 
75  std::string name() const;
76 
85  const ContainerID& containerId,
86  const std::string& cgroup);
87 
96  const ContainerID& containerId,
97  const std::string& cgroup);
98 
108  const ContainerID& containerId,
109  const std::string& cgroup,
110  pid_t pid);
111 
121  const ContainerID& containerId,
122  const std::string& cgroup);
123 
134  const ContainerID& containerId,
135  const std::string& cgroup,
136  const Resources& resources);
137 
148  const ContainerID& containerId,
149  const std::string& cgroup);
150 
160  const ContainerID& containerId,
161  const std::string& cgroup);
162 
176  const ContainerID& containerId,
177  const std::string& cgroup);
178 
179 private:
181 
183 };
184 
185 
186 class SubsystemProcess : public process::Process<SubsystemProcess>
187 {
188 public:
189  ~SubsystemProcess() override {}
190 
191  virtual std::string name() const = 0;
192 
194  const ContainerID& containerId,
195  const std::string& cgroup);
196 
198  const ContainerID& containerId,
199  const std::string& cgroup);
200 
202  const ContainerID& containerId,
203  const std::string& cgroup,
204  pid_t pid);
205 
207  const ContainerID& containerId,
208  const std::string& cgroup);
209 
211  const ContainerID& containerId,
212  const std::string& cgroup,
213  const Resources& resources);
214 
216  const ContainerID& containerId,
217  const std::string& cgroup);
218 
220  const ContainerID& containerId,
221  const std::string& cgroup);
222 
224  const ContainerID& containerId,
225  const std::string& cgroup);
226 
227 protected:
228  SubsystemProcess(const Flags& _flags, const std::string& _hierarchy);
229 
233  const Flags flags;
234 
238  const std::string hierarchy;
239 };
240 
241 } // namespace slave {
242 } // namespace internal {
243 } // namespace mesos {
244 
245 #endif // __CGROUPS_ISOLATOR_SUBSYSTEM_HPP__
static Try< process::Owned< Subsystem > > create(const Flags &flags, const std::string &name, const std::string &hierarchy)
Attempts to create a specific Subsystem object that will contain specific information associated with...
Definition: check.hpp:33
process::Future< mesos::slave::ContainerLimitation > watch(const ContainerID &containerId, const std::string &cgroup)
Watch the container and report if any resource constraint impacts it.
const Flags flags
Flags used to launch the agent.
Definition: subsystem.hpp:233
Definition: resources.hpp:81
process::Future< Nothing > isolate(const ContainerID &containerId, const std::string &cgroup, pid_t pid)
Isolate the associated container to cgroups subsystem.
Definition: flags.hpp:39
process::Future< Nothing > cleanup(const ContainerID &containerId, const std::string &cgroup)
Clean up the cgroups subsystem for the associated container.
std::string name() const
The cgroups subsystem name of this Subsystem object.
DWORD pid_t
Definition: windows.hpp:181
process::Future< Nothing > recover(const ContainerID &containerId, const std::string &cgroup)
Recover the cgroups subsystem for the associated container.
process::Future< ContainerStatus > status(const ContainerID &containerId, const std::string &cgroup)
Get the run-time status of cgroups subsystem specific properties associated with the container...
Definition: spec.hpp:26
Subsystem(const Subsystem &)=delete
Result< std::string > cgroup(pid_t pid)
Definition: subsystem.hpp:186
process::Future< Nothing > prepare(const ContainerID &containerId, const std::string &cgroup)
Prepare the cgroups subsystem for the associated container.
Subsystem & operator=(const Subsystem &)=delete
Definition: attributes.hpp:24
An abstraction for cgroups subsystem.
Definition: subsystem.hpp:44
Definition: executor.hpp:48
const std::string hierarchy
The hierarchy path of cgroups subsystem.
Definition: subsystem.hpp:238
process::Future< ResourceStatistics > usage(const ContainerID &containerId, const std::string &cgroup)
Gather resource usage statistics of the cgroups subsystem for the associated container.
Result< std::string > hierarchy(const std::string &subsystems)
Definition: owned.hpp:36
Definition: process.hpp:501
Definition: parse.hpp:33
~SubsystemProcess() override
Definition: subsystem.hpp:189
process::Future< Nothing > update(const ContainerID &containerId, const std::string &cgroup, const Resources &resources)
Update resources allocated to the associated container in this cgroups subsystem. ...