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 <string>
21 #include <vector>
22 
23 #include <process/owned.hpp>
24 #include <process/sequence.hpp>
25 
26 #include <stout/hashmap.hpp>
27 #include <stout/none.hpp>
28 #include <stout/option.hpp>
29 
31 
35 
36 namespace mesos {
37 namespace internal {
38 namespace slave {
39 
40 // The isolator is responsible for preparing volumes using docker
41 // volume driver APIs,
43 {
44 public:
46 
47  // This allows the driver client to be mock for testing.
49  const Flags& flags,
51 
53 
54  bool supportsNesting() override;
55  bool supportsStandalone() override;
56 
58  const std::vector<mesos::slave::ContainerState>& states,
59  const hashset<ContainerID>& orphans) override;
60 
62  const ContainerID& containerId,
63  const mesos::slave::ContainerConfig& containerConfig) override;
64 
66  const ContainerID& containerId) override;
67 
68 private:
69  struct Info
70  {
71  Info (const hashset<DockerVolume>& _volumes)
72  : volumes(_volumes) {}
73 
74  hashset<DockerVolume> volumes;
75  };
76 
78  const Flags& flags,
79  const std::string& rootDir,
81 
83  const ContainerID& containerId,
84  const std::vector<std::string>& targets,
85  const std::vector<Volume::Mode>& volumeModes,
87  const std::vector<process::Future<std::string>>& futures);
88 
89  process::Future<Nothing> _cleanup(
90  const ContainerID& containerId,
91  const std::vector<process::Future<Nothing>>& futures);
92 
93  Try<Nothing> _recover(const ContainerID& containerId);
94 
96  const std::string& driver,
97  const std::string& name,
98  const hashmap<std::string, std::string>& options);
99 
101  const std::string& driver,
102  const std::string& name,
103  const hashmap<std::string, std::string>& options);
104 
105  process::Future<Nothing> unmount(
106  const std::string& driver,
107  const std::string& name);
108 
109  process::Future<Nothing> _unmount(
110  const std::string& driver,
111  const std::string& name);
112 
113  const Flags flags;
114  const std::string rootDir;
116 
118 
119  // For a given volume, the docker volume isolator might be doing
120  // mounting and unmounting simultaneously. The sequence can make
121  // sure the order we issue them is the same order they are executed.
123 };
124 
125 } // namespace slave {
126 } // namespace internal {
127 } // namespace mesos {
128 
129 #endif // __DOCKER_VOLUME_ISOLATOR_HPP__
Definition: check.hpp:33
Result< std::string > user(Option< uid_t > uid=None())
Definition: su.hpp:284
static Try< mesos::slave::Isolator * > create(const Flags &flags)
process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig) override
Definition: flags.hpp:39
Definition: agent.hpp:25
Definition: attributes.hpp:24
static Try< mesos::slave::Isolator * > _create(const Flags &flags, const process::Owned< docker::volume::DriverClient > &client)
process::Future< Nothing > cleanup(const ContainerID &containerId) override
process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans) override
Definition: parse.hpp:33
constexpr const char * name
Definition: shell.hpp:41