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 
42 class Subsystem : public process::Process<Subsystem>
43 {
44 public:
55  const Flags& flags,
56  const std::string& name,
57  const std::string& hierarchy);
58 
59  virtual ~Subsystem() {}
60 
66  virtual std::string name() const = 0;
67 
76  const ContainerID& containerId,
77  const std::string& cgroup);
78 
87  const ContainerID& containerId,
88  const std::string& cgroup);
89 
99  const ContainerID& containerId,
100  const std::string& cgroup,
101  pid_t pid);
102 
112  const ContainerID& containerId,
113  const std::string& cgroup);
114 
125  const ContainerID& containerId,
126  const std::string& cgroup,
127  const Resources& resources);
128 
139  const ContainerID& containerId,
140  const std::string& cgroup);
141 
151  const ContainerID& containerId,
152  const std::string& cgroup);
153 
167  const ContainerID& containerId,
168  const std::string& cgroup);
169 
170 protected:
171  Subsystem(const Flags& _flags, const std::string& _hierarchy);
172 
176  const Flags flags;
177 
181  const std::string hierarchy;
182 };
183 
184 } // namespace slave {
185 } // namespace internal {
186 } // namespace mesos {
187 
188 #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...
virtual process::Future< Nothing > prepare(const ContainerID &containerId, const std::string &cgroup)
Prepare the cgroups subsystem for the associated container.
Definition: try.hpp:34
virtual process::Future< mesos::slave::ContainerLimitation > watch(const ContainerID &containerId, const std::string &cgroup)
Watch the container and report if any resource constraint impacts it.
Definition: resources.hpp:79
const Flags flags
Flags used to launch the agent.
Definition: subsystem.hpp:176
Definition: flags.hpp:39
DWORD pid_t
Definition: windows.hpp:187
Subsystem(const Flags &_flags, const std::string &_hierarchy)
virtual ~Subsystem()
Definition: subsystem.hpp:59
Result< std::string > cgroup(pid_t pid)
virtual 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. ...
virtual process::Future< Nothing > recover(const ContainerID &containerId, const std::string &cgroup)
Recover the cgroups subsystem for the associated container.
An abstraction for cgroups subsystem.
Definition: subsystem.hpp:42
const std::string hierarchy
The hierarchy path of cgroups subsystem.
Definition: subsystem.hpp:181
virtual 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...
virtual std::string name() const =0
The cgroups subsystem name of this Subsystem object.
virtual process::Future< ResourceStatistics > usage(const ContainerID &containerId, const std::string &cgroup)
Gather resource usage statistics of the cgroups subsystem for the associated container.
Definition: process.hpp:493
virtual process::Future< Nothing > cleanup(const ContainerID &containerId, const std::string &cgroup)
Clean up the cgroups subsystem for the associated container.
virtual process::Future< Nothing > isolate(const ContainerID &containerId, const std::string &cgroup, pid_t pid)
Isolate the associated container to cgroups subsystem.