Apache Mesos
zookeeper.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_ZOOKEEPER_HPP__
18 #define __MASTER_DETECTOR_ZOOKEEPER_HPP__
19 
20 #include <string>
21 
22 #include <mesos/mesos.hpp>
23 
25 
27 #include <mesos/zookeeper/url.hpp>
28 
29 #include <process/future.hpp>
30 #include <process/owned.hpp>
31 
32 #include <stout/option.hpp>
33 
34 namespace mesos {
35 namespace master {
36 namespace detector {
37 
39 
40 // Forward declarations.
41 class ZooKeeperMasterDetectorProcess;
42 
43 
45 {
46 public:
47  // Creates a detector which uses ZooKeeper to determine (i.e.,
48  // elect) a leading master.
49  explicit ZooKeeperMasterDetector(
50  const zookeeper::URL& url,
51  const Duration& sessionTimeout = MASTER_DETECTOR_ZK_SESSION_TIMEOUT);
52 
53  // Used for testing purposes.
55  ~ZooKeeperMasterDetector() override;
56 
57  // MasterDetector implementation.
58  // The detector transparently tries to recover from retryable
59  // errors until the group session expires, in which case the Future
60  // returns None.
62  const Option<MasterInfo>& previous = None()) override;
63 
64 private:
65  ZooKeeperMasterDetectorProcess* process;
66 };
67 
68 } // namespace detector {
69 } // namespace master {
70 } // namespace mesos {
71 
72 #endif // __MASTER_DETECTOR_ZOOKEEPER_HPP__
Definition: master.hpp:27
Definition: duration.hpp:32
const Duration MASTER_DETECTOR_ZK_SESSION_TIMEOUT
Definition: spec.hpp:26
Definition: grp.hpp:26
Definition: none.hpp:27
Definition: executor.hpp:48
Definition: url.hpp:46
An abstraction of a Master detector which can be used to detect the leading master from a group...
Definition: detector.hpp:38
ZooKeeperMasterDetector(const zookeeper::URL &url, const Duration &sessionTimeout=MASTER_DETECTOR_ZK_SESSION_TIMEOUT)
Definition: owned.hpp:36
process::Future< Option< MasterInfo > > detect(const Option< MasterInfo > &previous=None()) override
Returns MasterInfo after an election has occurred and the elected master is different than that speci...
Definition: future.hpp:58