Apache Mesos
paths.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 __PROVISIONER_PATHS_HPP__
18 #define __PROVISIONER_PATHS_HPP__
19 
20 #include <string>
21 
22 #include <mesos/mesos.hpp>
23 
24 #include <stout/hashmap.hpp>
25 #include <stout/hashset.hpp>
26 #include <stout/try.hpp>
27 
28 namespace mesos {
29 namespace internal {
30 namespace slave {
31 namespace provisioner {
32 namespace paths {
33 
34 // The provisioner rootfs directory is as follows:
35 // <work_dir> ('--work_dir' flag)
36 // |-- provisioner
37 // |-- containers
38 // |-- <container_id>
39 // |-- layers (paths to all layers to provision)
40 // |-- backends
41 // |-- <backend> (copy, bind, etc.)
42 // |-- rootfses
43 // |-- <rootfs_id> (the rootfs)
44 // |-- containers (nested containers)
45 // |-- <container_id>
46 // |-- layers (paths to all layers to provision)
47 // |-- backends
48 // |-- <backend> (copy, bind, etc.)
49 // |-- rootfses
50 // |-- <rootfs_id> (the rootfs)
51 //
52 // There can be multiple backends due to the change of backend flags.
53 // Under each backend a rootfs is identified by the 'rootfs_id' which
54 // is a UUID.
55 
56 
57 constexpr char LAYERS_FILE[] = "layers";
58 
59 
60 // TODO(gilbert): rename this to `getContainerPath` for consistency.
61 std::string getContainerDir(
62  const std::string& provisionerDir,
63  const ContainerID& containerId);
64 
65 
66 std::string getLayersFilePath(
67  const std::string& provisionerDir,
68  const ContainerID& containerId);
69 
70 
71 std::string getContainerRootfsDir(
72  const std::string& provisionerDir,
73  const ContainerID& containerId,
74  const std::string& backend,
75  const std::string& rootfsId);
76 
77 
78 // Recursively "ls" the container directory and return a map of
79 // backend -> {rootfsId, ...}
82  const std::string& provisionerDir,
83  const ContainerID& containerId);
84 
85 
86 // Return a set of container IDs.
88  const std::string& provisionerDir);
89 
90 
91 std::string getBackendDir(
92  const std::string& provisionerDir,
93  const ContainerID& containerId,
94  const std::string& backend);
95 
96 } // namespace paths {
97 } // namespace provisioner {
98 } // namespace slave {
99 } // namespace internal {
100 } // namespace mesos {
101 
102 #endif // __PROVISIONER_PATHS_HPP__
Definition: check.hpp:33
std::string paths()
Definition: os.hpp:138
constexpr char LAYERS_FILE[]
Definition: paths.hpp:57
std::string getContainerRootfsDir(const std::string &provisionerDir, const ContainerID &containerId, const std::string &backend, const std::string &rootfsId)
Try< hashset< ContainerID > > listContainers(const std::string &provisionerDir)
Definition: agent.hpp:25
std::string getLayersFilePath(const std::string &provisionerDir, const ContainerID &containerId)
Try< hashmap< std::string, hashset< std::string > > > listContainerRootfses(const std::string &provisionerDir, const ContainerID &containerId)
Definition: attributes.hpp:24
std::string getBackendDir(const std::string &provisionerDir, const ContainerID &containerId, const std::string &backend)
std::string getContainerDir(const std::string &provisionerDir, const ContainerID &containerId)