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 } // namespace master {
141 } // namespace internal {
142 } // namespace mesos {
143 
144 #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:31
Definition: spec.hpp:26
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