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  virtual bool supportsNesting();
55  virtual bool supportsStandalone();
56 
58  const std::vector<mesos::slave::ContainerState>& states,
59  const hashset<ContainerID>& orphans);
60 
62  const ContainerID& containerId,
63  const mesos::slave::ContainerConfig& containerConfig);
64 
66  const ContainerID& containerId);
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<process::Future<std::string>>& futures);
86 
87  process::Future<Nothing> _cleanup(
88  const ContainerID& containerId,
89  const std::vector<process::Future<Nothing>>& futures);
90 
91  Try<Nothing> _recover(const ContainerID& containerId);
92 
94  const std::string& driver,
95  const std::string& name,
96  const hashmap<std::string, std::string>& options);
97 
99  const std::string& driver,
100  const std::string& name,
101  const hashmap<std::string, std::string>& options);
102 
103  process::Future<Nothing> unmount(
104  const std::string& driver,
105  const std::string& name);
106 
107  process::Future<Nothing> _unmount(
108  const std::string& driver,
109  const std::string& name);
110 
111  const Flags flags;
112  const std::string rootDir;
114 
116 
117  // For a given volume, the docker volume isolator might be doing
118  // mounting and unmounting simultaneously. The sequence can make
119  // sure the order we issue them is the same order they are executed.
121 };
122 
123 } // namespace slave {
124 } // namespace internal {
125 } // namespace mesos {
126 
127 #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
Definition: attributes.hpp:24
static Try< mesos::slave::Isolator * > _create(const Flags &flags, const process::Owned< docker::volume::DriverClient > &client)
virtual process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig)
virtual process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans)
virtual process::Future< Nothing > cleanup(const ContainerID &containerId)
Definition: parse.hpp:33
constexpr const char * name
Definition: shell.hpp:43