Apache Mesos
isolator.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 __ISOLATOR_HPP__
18 #define __ISOLATOR_HPP__
19 
20 #include <mesos/slave/isolator.hpp>
21 
22 #include <process/owned.hpp>
23 #include <process/process.hpp>
24 
25 #include <stout/none.hpp>
26 
27 namespace mesos {
28 namespace internal {
29 namespace slave {
30 
31 // Forward declaration.
32 class MesosIsolatorProcess;
33 
34 
35 // A wrapper class that implements the 'Isolator' interface which is
36 // backed by an 'MesosIsolatorProcess'. This helper class is useful
37 // for programmers to write asynchronous isolators.
39 {
40 public:
42  ~MesosIsolator() override;
43 
44  bool supportsNesting() override;
45  bool supportsStandalone() override;
46 
48  const std::vector<mesos::slave::ContainerState>& states,
49  const hashset<ContainerID>& orphans) override;
50 
52  const ContainerID& containerId,
53  const mesos::slave::ContainerConfig& containerConfig) override;
54 
56  const ContainerID& containerId,
57  pid_t pid) override;
58 
60  const ContainerID& containerId) override;
61 
63  const ContainerID& containerId,
64  const Resources& resourceRequests,
65  const google::protobuf::Map<
66  std::string, Value::Scalar>& resourceLimits = {}) override;
67 
69  const ContainerID& containerId) override;
70 
72  const ContainerID& containerId) override;
73 
75  const ContainerID& containerId) override;
76 
77 private:
79 };
80 
81 
82 class MesosIsolatorProcess : public process::Process<MesosIsolatorProcess>
83 {
84 public:
85  ~MesosIsolatorProcess() override {}
86 
87  virtual bool supportsNesting()
88  {
89  return false;
90  }
91 
92  virtual bool supportsStandalone()
93  {
94  return false;
95  }
96 
98  const std::vector<mesos::slave::ContainerState>& states,
99  const hashset<ContainerID>& orphans)
100  {
101  return Nothing();
102  }
103 
105  const ContainerID& containerId,
106  const mesos::slave::ContainerConfig& containerConfig)
107  {
108  return None();
109  }
110 
112  const ContainerID& containerId,
113  pid_t pid)
114  {
115  return Nothing();
116  }
117 
119  const ContainerID& containerId)
120  {
122  }
123 
125  const ContainerID& containerId,
126  const Resources& resourceRequests,
127  const google::protobuf::Map<
128  std::string, Value::Scalar>& resourceLimits = {})
129  {
130  return Nothing();
131  }
132 
134  const ContainerID& containerId)
135  {
136  return ResourceStatistics();
137  }
138 
140  const ContainerID& containerId)
141  {
142  return ContainerStatus();
143  };
144 
146  const ContainerID& containerId)
147  {
148  return Nothing();
149  }
150 };
151 
152 } // namespace slave {
153 } // namespace internal {
154 } // namespace mesos {
155 
156 #endif // __ISOLATOR_HPP__
virtual process::Future< ResourceStatistics > usage(const ContainerID &containerId)
Definition: isolator.hpp:133
Definition: isolator.hpp:38
Definition: nothing.hpp:16
virtual process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig)
Definition: isolator.hpp:104
Definition: resources.hpp:83
process::Future< ResourceStatistics > usage(const ContainerID &containerId) override
virtual process::Future< ContainerStatus > status(const ContainerID &containerId)
Definition: isolator.hpp:139
virtual process::Future< Nothing > update(const ContainerID &containerId, const Resources &resourceRequests, const google::protobuf::Map< std::string, Value::Scalar > &resourceLimits={})
Definition: isolator.hpp:124
MesosIsolator(process::Owned< MesosIsolatorProcess > process)
DWORD pid_t
Definition: windows.hpp:181
process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans) override
virtual bool supportsNesting()
Definition: isolator.hpp:87
virtual process::Future< Nothing > cleanup(const ContainerID &containerId)
Definition: isolator.hpp:145
process::Future< Nothing > update(const ContainerID &containerId, const Resources &resourceRequests, const google::protobuf::Map< std::string, Value::Scalar > &resourceLimits={}) override
Definition: agent.hpp:25
process::Future< mesos::slave::ContainerLimitation > watch(const ContainerID &containerId) override
~MesosIsolatorProcess() override
Definition: isolator.hpp:85
process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig) override
virtual bool supportsStandalone()
Definition: isolator.hpp:92
virtual process::Future< mesos::slave::ContainerLimitation > watch(const ContainerID &containerId)
Definition: isolator.hpp:118
Definition: none.hpp:27
Definition: attributes.hpp:24
process::Future< Nothing > cleanup(const ContainerID &containerId) override
Definition: executor.hpp:48
virtual process::Future< Nothing > isolate(const ContainerID &containerId, pid_t pid)
Definition: isolator.hpp:111
process::Future< ContainerStatus > status(const ContainerID &containerId) override
Definition: owned.hpp:36
Definition: process.hpp:505
Definition: isolator.hpp:39
virtual process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans)
Definition: isolator.hpp:97
process::Future< Nothing > isolate(const ContainerID &containerId, pid_t pid) override