Apache Mesos
registry_operations.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 __MASTER_REGISTRY_OPERATIONS_HPP__
18 #define __MASTER_REGISTRY_OPERATIONS_HPP__
19 
20 #include <mesos/mesos.hpp>
21 #include <mesos/type_utils.hpp>
22 
23 #include "master/registrar.hpp"
24 
25 
26 namespace mesos {
27 namespace internal {
28 namespace master {
29 
30 // Add a new slave to the list of admitted slaves.
32 {
33 public:
34  explicit AdmitSlave(const SlaveInfo& _info);
35 
36 protected:
37  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
38 
39 private:
40  SlaveInfo info;
41 };
42 
43 
44 // Update the SlaveInfo of an existing admitted slave.
46 {
47 public:
48  explicit UpdateSlave(const SlaveInfo& _info);
49 
50 protected:
51  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
52 
53 private:
54  SlaveInfo info;
55 };
56 
57 
58 // Move a slave from the list of admitted slaves to the list of
59 // unreachable slaves.
61 {
62 public:
64  const SlaveInfo& _info,
65  const TimeInfo& _unreachableTime);
66 
67 protected:
68  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
69 
70 private:
71  const SlaveInfo info;
72  const TimeInfo unreachableTime;
73 };
74 
75 
76 // Add a slave back to the list of admitted slaves. The slave will
77 // typically be in the "unreachable" list; if so, it is removed from
78 // that list. The slave might also be in the "admitted" list already.
79 // Finally, the slave might be in neither the "unreachable" or
80 // "admitted" lists, if its metadata has been garbage collected from
81 // the registry.
83 {
84 public:
85  explicit MarkSlaveReachable(const SlaveInfo& _info);
86 
87 protected:
88  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
89 
90 private:
91  SlaveInfo info;
92 };
93 
94 
95 class Prune : public RegistryOperation
96 {
97 public:
98  explicit Prune(
99  const hashset<SlaveID>& _toRemoveUnreachable,
100  const hashset<SlaveID>& _toRemoveGone);
101 
102 protected:
103  Try<bool> perform(Registry* registry, hashset<SlaveID>* /*slaveIDs*/)
104  override;
105 
106 private:
107  const hashset<SlaveID> toRemoveUnreachable;
108  const hashset<SlaveID> toRemoveGone;
109 };
110 
111 
113 {
114 public:
115  explicit RemoveSlave(const SlaveInfo& _info);
116 
117 protected:
118  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
119 
120 private:
121  const SlaveInfo info;
122 };
123 
124 
125 // Move a slave from the list of admitted/unreachable slaves
126 // to the list of gone slaves.
128 {
129 public:
130  MarkSlaveGone(const SlaveID& _id, const TimeInfo& _goneTime);
131 
132 protected:
133  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
134 
135 private:
136  const SlaveID id;
137  const TimeInfo goneTime;
138 };
139 
140 
141 // Marks an existing agent for draining.
142 // Also adds a minimum capability to the master for AGENT_DRAINING.
144 {
145 public:
146  DrainAgent(
147  const SlaveID& _slaveId,
148  const Option<DurationInfo>& _maxGracePeriod,
149  const bool _markGone);
150 
151 protected:
152  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
153 
154 private:
155  const SlaveID slaveId;
156  const Option<DurationInfo> maxGracePeriod;
157  const bool markGone;
158 };
159 
160 
161 // Transitions a DRAINING agent into the DRAINED state.
163 {
164 public:
165  MarkAgentDrained(const SlaveID& _slaveId);
166 
167 protected:
168  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
169 
170 private:
171  const SlaveID slaveId;
172 };
173 
174 
175 // Marks an existing agent as deactivated.
176 // Also adds a minimum capability to the master for AGENT_DRAINING.
178 {
179 public:
180  DeactivateAgent(const SlaveID& _slaveId);
181 
182 protected:
183  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
184 
185 private:
186  const SlaveID slaveId;
187 };
188 
189 
190 // Clears draining or deactivation from an existing agent.
191 // If there are no remaining draining or deactivated agents,
192 // this also clears the minimum capability for AGENT_DRAINING.
194 {
195 public:
196  ReactivateAgent(const SlaveID& _slaveId);
197 
198 protected:
199  Try<bool> perform(Registry* registry, hashset<SlaveID>* slaveIDs) override;
200 
201 private:
202  const SlaveID slaveId;
203 };
204 
205 } // namespace master {
206 } // namespace internal {
207 } // namespace mesos {
208 
209 #endif // __MASTER_REGISTRY_OPERATIONS_HPP__
AdmitSlave(const SlaveInfo &_info)
Definition: master.hpp:27
Definition: check.hpp:33
Definition: registry_operations.hpp:95
Definition: uuid.hpp:33
Definition: registry_operations.hpp:82
Definition: registry_operations.hpp:127
Definition: registry_operations.hpp:193
Definition: registry_operations.hpp:162
Definition: registry_operations.hpp:177
Definition: registry_operations.hpp:143
Definition: registry_operations.hpp:31
Definition: agent.hpp:25
Definition: registry_operations.hpp:45
Try< bool > perform(Registry *registry, hashset< SlaveID > *slaveIDs) override
Definition: attributes.hpp:24
Definition: registry_operations.hpp:112
Definition: registrar.hpp:45
Definition: registry_operations.hpp:60