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 __DOCKER_VOLUME_ISOLATOR_HPP__
18 #define __DOCKER_VOLUME_ISOLATOR_HPP__
19 
20 #include <list>
21 #include <string>
22 #include <vector>
23 
24 #include <process/owned.hpp>
25 #include <process/sequence.hpp>
26 
27 #include <stout/hashmap.hpp>
28 #include <stout/none.hpp>
29 #include <stout/option.hpp>
30 
32 
36 
37 namespace mesos {
38 namespace internal {
39 namespace slave {
40 
41 // The isolator is responsible for preparing volumes using docker
42 // volume driver APIs,
44 {
45 public:
47 
48  // This allows the driver client to be mock for testing.
50  const Flags& flags,
52 
54 
55  virtual bool supportsNesting();
56  virtual bool supportsStandalone();
57 
59  const std::list<mesos::slave::ContainerState>& states,
60  const hashset<ContainerID>& orphans);
61 
63  const ContainerID& containerId,
64  const mesos::slave::ContainerConfig& containerConfig);
65 
67  const ContainerID& containerId);
68 
69 private:
70  struct Info
71  {
72  Info (const hashset<DockerVolume>& _volumes)
73  : volumes(_volumes) {}
74 
75  hashset<DockerVolume> volumes;
76  };
77 
79  const Flags& flags,
80  const std::string& rootDir,
82 
84  const ContainerID& containerId,
85  const std::vector<std::string>& targets,
86  const std::list<process::Future<std::string>>& futures);
87 
88  process::Future<Nothing> _cleanup(
89  const ContainerID& containerId,
90  const std::list<process::Future<Nothing>>& futures);
91 
92  Try<Nothing> _recover(const ContainerID& containerId);
93 
95  const std::string& driver,
96  const std::string& name,
97  const hashmap<std::string, std::string>& options);
98 
100  const std::string& driver,
101  const std::string& name,
102  const hashmap<std::string, std::string>& options);
103 
104  process::Future<Nothing> unmount(
105  const std::string& driver,
106  const std::string& name);
107 
108  process::Future<Nothing> _unmount(
109  const std::string& driver,
110  const std::string& name);
111 
112  const Flags flags;
113  const std::string rootDir;
115 
117 
118  // For a given volume, the docker volume isolator might be doing
119  // mounting and unmounting simultaneously. The sequence can make
120  // sure the order we issue them is the same order they are executed.
122 };
123 
124 } // namespace slave {
125 } // namespace internal {
126 } // namespace mesos {
127 
128 #endif // __DOCKER_VOLUME_ISOLATOR_HPP__
Definition: check.hpp:33
static Try< mesos::slave::Isolator * > create(const Flags &flags)
Definition: flags.hpp:39
Definition: spec.hpp:30
Try< std::vector< Entry > > list(const std::string &hierarchy, const std::string &cgroup)
Definition: attributes.hpp:24
static Try< mesos::slave::Isolator * > _create(const Flags &flags, const process::Owned< docker::volume::DriverClient > &client)
virtual process::Future< Nothing > recover(const std::list< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans)
virtual process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig)
virtual process::Future< Nothing > cleanup(const ContainerID &containerId)
Definition: parse.hpp:33
constexpr const char * name
Definition: shell.hpp:43