Apache Mesos
recover.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 __LOG_RECOVER_HPP__
18 #define __LOG_RECOVER_HPP__
19 
20 #include <stdint.h>
21 
22 #include <process/future.hpp>
23 #include <process/owned.hpp>
24 #include <process/shared.hpp>
25 
26 #include <stout/nothing.hpp>
27 
28 #include "log/network.hpp"
29 #include "log/replica.hpp"
30 
31 namespace mesos {
32 namespace internal {
33 namespace log {
34 
35 // Runs the recover protocol. We will re-run the recover protocol if
36 // it cannot be finished within 'timeout'.
38  size_t quorum,
39  const process::Shared<Network>& network,
40  const Metadata::Status& status,
41  bool autoInitialize,
42  const Duration& timeout = Seconds(10));
43 
44 
45 // Recovers a replica by catching up enough missing positions. A
46 // replica starts with an empty log (e.g., in the case of a disk
47 // failure) should not be allowed to vote. Otherwise, the new votes it
48 // makes may contradict its lost votes, leading to potential
49 // inconsistency in the log. Instead, the replica should be put in
50 // non-voting status and catch up missing positions (and associated
51 // Paxos states). The replica can be re-allowed to vote if the
52 // following two conditions are met: 1) a sufficient amount of missing
53 // positions are recovered such that if other replicas fail, the
54 // remaining replicas can restore all the successfully written log
55 // entries; 2) its future votes cannot not contradict its lost votes.
56 //
57 // This function returns an owned pointer to the recovered replica if
58 // the recovery is successful. If the auto-initialization flag is set,
59 // an empty replica will be allowed to vote if ALL replicas (i.e.,
60 // quorum * 2 - 1) are empty. This allows us to bootstrap the
61 // replicated log without explicitly using an initialization tool.
63  size_t quorum,
64  const process::Owned<Replica>& replica,
65  const process::Shared<Network>& network,
66  bool autoInitialize = false);
67 
68 } // namespace log {
69 } // namespace internal {
70 } // namespace mesos {
71 
72 #endif // __LOG_RECOVER_HPP__
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
Definition: duration.hpp:32
Definition: duration.hpp:207
Definition: agent.hpp:25
Definition: attributes.hpp:24
process::Future< process::Owned< Replica > > recover(size_t quorum, const process::Owned< Replica > &replica, const process::Shared< Network > &network, bool autoInitialize=false)
process::Future< Option< RecoverResponse > > runRecoverProtocol(size_t quorum, const process::Shared< Network > &network, const Metadata::Status &status, bool autoInitialize, const Duration &timeout=Seconds(10))
Definition: owned.hpp:36
Definition: future.hpp:58