Apache Mesos
linux.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 __LINUX_FILESYSTEM_ISOLATOR_HPP__
18 #define __LINUX_FILESYSTEM_ISOLATOR_HPP__
19 
20 #include <mesos/mesos.hpp>
21 #include <mesos/resources.hpp>
22 
23 #include <process/owned.hpp>
24 #include <process/pid.hpp>
25 
27 
28 #include <stout/hashmap.hpp>
29 
30 #include "slave/flags.hpp"
31 
33 
34 namespace mesos {
35 namespace internal {
36 namespace slave {
37 
38 // The filesystem isolator on Linux that is responsible for preparing
39 // the root filesystems and volumes (e.g., persistent volumes) for
40 // containers. It relies on Linux mount namespace to prevent mounts of
41 // a container from being propagated to the host mount table.
43 {
44 public:
45  static Try<mesos::slave::Isolator*> create(const Flags& flags);
46 
48 
49  virtual bool supportsNesting();
50  virtual bool supportsStandalone();
51 
53  const std::list<mesos::slave::ContainerState>& states,
54  const hashset<ContainerID>& orphans);
55 
57  const ContainerID& containerId,
58  const mesos::slave::ContainerConfig& containerConfig);
59 
61  const ContainerID& containerId,
62  const Resources& resources);
63 
65  const ContainerID& containerId);
66 
67 private:
69 
70  const Flags flags;
71 
72  struct Info
73  {
74  Info(const std::string& _directory) : directory(_directory) {}
75 
76  Info(const std::string& _directory,
77  const Option<ExecutorInfo>& _executor)
78  : directory(_directory),
79  executor(_executor) {}
80 
81  const std::string directory;
82 
83  // Track resources so we can unmount unneeded persistent volumes.
84  Resources resources;
85 
86  Option<ExecutorInfo> executor;
87  };
88 
90 
91  struct Metrics
92  {
93  explicit Metrics(
95  ~Metrics();
96 
97  process::metrics::Gauge containers_new_rootfs;
98  } metrics;
99 
100  double _containers_new_rootfs();
101 };
102 
103 } // namespace slave {
104 } // namespace internal {
105 } // namespace mesos {
106 
107 #endif // __LINUX_FILESYSTEM_ISOLATOR_HPP__
static Try< mesos::slave::Isolator * > create(const Flags &flags)
virtual process::Future< Nothing > recover(const std::list< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans)
Definition: try.hpp:34
virtual process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig)
Definition: resources.hpp:79
Definition: flags.hpp:39
Definition: hashmap.hpp:38
virtual process::Future< Nothing > cleanup(const ContainerID &containerId)
Definition: gauge.hpp:27
A &quot;process identifier&quot; used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:279
JSON::Object Metrics()
virtual process::Future< Nothing > update(const ContainerID &containerId, const Resources &resources)