Apache Mesos
standalone.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_DETECTOR_STANDALONE_HPP__
18 #define __MASTER_DETECTOR_STANDALONE_HPP__
19 
20 #include <string>
21 
22 #include <mesos/mesos.hpp>
23 
25 
26 #include <process/future.hpp>
27 
28 #include <stout/option.hpp>
29 
30 namespace mesos {
31 namespace master {
32 namespace detector {
33 
34 // Forward declarations.
35 class StandaloneMasterDetectorProcess;
36 
37 // A standalone implementation of the MasterDetector with no external
38 // discovery mechanism so the user has to manually appoint a leader
39 // to the detector for it to be detected.
41 {
42 public:
44  // Use this constructor if the leader is known beforehand so it is
45  // unnecessary to call 'appoint()' separately.
46  explicit StandaloneMasterDetector(const MasterInfo& leader);
47 
48  // Same as above but takes UPID as the parameter.
49  explicit StandaloneMasterDetector(const process::UPID& leader);
50 
51  virtual ~StandaloneMasterDetector();
52 
53  // Appoint the leading master so it can be *detected*.
54  void appoint(const Option<MasterInfo>& leader);
55 
56  // Same as above but takes 'UPID' as the parameter.
57  void appoint(const process::UPID& leader);
58 
60  const Option<MasterInfo>& previous = None());
61 
62 private:
63  StandaloneMasterDetectorProcess* process;
64 };
65 
66 } // namespace detector {
67 } // namespace master {
68 } // namespace mesos {
69 
70 #endif // __MASTER_DETECTOR_STANDALONE_HPP__
An &quot;untyped&quot; PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
Definition: none.hpp:27
An abstraction of a Master detector which can be used to detect the leading master from a group...
Definition: detector.hpp:38
virtual process::Future< Option< MasterInfo > > detect(const Option< MasterInfo > &previous=None())
Returns MasterInfo after an election has occurred and the elected master is different than that speci...
void appoint(const Option< MasterInfo > &leader)
Definition: future.hpp:57