Apache Mesos
disk.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 __XFS_DISK_ISOLATOR_HPP__
18 #define __XFS_DISK_ISOLATOR_HPP__
19 
20 #include <string>
21 
22 #include <process/owned.hpp>
23 
24 #include <stout/bytes.hpp>
25 #include <stout/duration.hpp>
26 #include <stout/hashmap.hpp>
27 
28 #include "slave/flags.hpp"
29 
31 
33 
34 namespace mesos {
35 namespace internal {
36 namespace slave {
37 
39 {
40 public:
42 
43  ~XfsDiskIsolatorProcess() override;
44 
46  {
48  }
49 
51  const std::vector<mesos::slave::ContainerState>& states,
52  const hashset<ContainerID>& orphans) override;
53 
55  const ContainerID& containerId,
56  const mesos::slave::ContainerConfig& containerConfig) override;
57 
59  const ContainerID& containerId) override;
60 
62  const ContainerID& containerId,
63  const Resources& resources) override;
64 
66  const ContainerID& containerId) override;
67 
69  const ContainerID& containerId) override;
70 
71 protected:
72  void initialize() override;
73 
74 private:
76  Duration watchInterval,
77  xfs::QuotaPolicy quotaPolicy,
78  const std::string& workDir,
79  const IntervalSet<prid_t>& projectIds);
80 
81  // Responsible for validating a container hasn't broken the soft limit.
82  void check();
83 
84  // Take the next project ID from the unallocated pool.
85  Option<prid_t> nextProjectId();
86 
87  // Return this project ID to the unallocated pool.
88  void returnProjectId(prid_t projectId);
89 
90  struct Info
91  {
92  explicit Info(const std::string& _directory, prid_t _projectId)
93  : directory(_directory), quota(0), projectId(_projectId) {}
94 
95  const std::string directory;
96  Bytes quota;
97  const prid_t projectId;
99  };
100 
101  const Duration watchInterval;
102  xfs::QuotaPolicy quotaPolicy;
103  const std::string workDir;
104  const IntervalSet<prid_t> totalProjectIds;
105  IntervalSet<prid_t> freeProjectIds;
107 };
108 
109 } // namespace slave {
110 } // namespace internal {
111 } // namespace mesos {
112 
113 #endif // __XFS_DISK_ISOLATOR_HPP__
process::Future< mesos::slave::ContainerLimitation > watch(const ContainerID &containerId) override
Definition: option.hpp:28
Definition: check.hpp:33
void initialize() override
Invoked when a process gets spawned.
Definition: resources.hpp:79
Definition: flags.hpp:39
Definition: duration.hpp:32
process::Future< Option< mesos::slave::ContainerLaunchInfo > > prepare(const ContainerID &containerId, const mesos::slave::ContainerConfig &containerConfig) override
Definition: hashmap.hpp:38
process::Future< Nothing > cleanup(const ContainerID &containerId) override
Definition: spec.hpp:30
static Try< mesos::slave::Isolator * > create(const Flags &flags)
process::Future< ResourceStatistics > usage(const ContainerID &containerId) override
QuotaPolicy
Definition: utils.hpp:73
A "process identifier" used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:279
Definition: attributes.hpp:24
process::Future< Nothing > update(const ContainerID &containerId, const Resources &resources) override
Definition: bytes.hpp:30
process::Future< Nothing > recover(const std::vector< mesos::slave::ContainerState > &states, const hashset< ContainerID > &orphans) override
Definition: parse.hpp:33