diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/repl/vote_requester.h | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/repl/vote_requester.h')
-rw-r--r-- | src/mongo/db/repl/vote_requester.h | 143 |
1 files changed, 71 insertions, 72 deletions
diff --git a/src/mongo/db/repl/vote_requester.h b/src/mongo/db/repl/vote_requester.h index a5102192ebd..8000d12ddb8 100644 --- a/src/mongo/db/repl/vote_requester.h +++ b/src/mongo/db/repl/vote_requester.h @@ -41,92 +41,91 @@ namespace mongo { - class Status; +class Status; namespace repl { - class ScatterGatherRunner; - class ReplSetDeclareRequestVotesArgs; +class ScatterGatherRunner; +class ReplSetDeclareRequestVotesArgs; - class VoteRequester { - MONGO_DISALLOW_COPYING(VoteRequester); - public: +class VoteRequester { + MONGO_DISALLOW_COPYING(VoteRequester); - enum VoteRequestResult { - SuccessfullyElected, - StaleTerm, - InsufficientVotes, - }; - - class Algorithm : public ScatterGatherAlgorithm { - public: - Algorithm(const ReplicaSetConfig& rsConfig, - long long candidateId, - long long term, - bool dryRun, - OpTime lastOplogEntry); - virtual ~Algorithm(); - virtual std::vector<RemoteCommandRequest> getRequests() const; - virtual void processResponse( - const RemoteCommandRequest& request, - const ResponseStatus& response); - virtual bool hasReceivedSufficientResponses() const; - - /** - * Returns a VoteRequestResult indicating the result of the election. - * - * It is invalid to call this before hasReceivedSufficientResponses returns true. - */ - VoteRequestResult getResult() const; - - private: - const ReplicaSetConfig _rsConfig; - const long long _candidateId; - const long long _term; - bool _dryRun = false; // this bool indicates this is a mock election when true - const OpTime _lastOplogEntry; - std::vector<HostAndPort> _targets; - bool _staleTerm = false; - long long _responsesProcessed = 0; - long long _votes = 1; - }; - - VoteRequester(); - virtual ~VoteRequester(); +public: + enum VoteRequestResult { + SuccessfullyElected, + StaleTerm, + InsufficientVotes, + }; - /** - * Begins the process of sending replSetRequestVotes commands to all non-DOWN nodes - * in currentConfig, in attempt to receive sufficient votes to win the election. - * - * evh can be used to schedule a callback when the process is complete. - * This function must be run in the executor, as it must be synchronous with the command - * callbacks that it schedules. - * If this function returns Status::OK(), evh is then guaranteed to be signaled. - **/ - StatusWith<ReplicationExecutor::EventHandle> start( - ReplicationExecutor* executor, - const ReplicaSetConfig& rsConfig, - long long candidateId, - long long term, - bool dryRun, - OpTime lastOplogEntry, - const stdx::function<void ()>& onCompletion = stdx::function<void ()>()); + class Algorithm : public ScatterGatherAlgorithm { + public: + Algorithm(const ReplicaSetConfig& rsConfig, + long long candidateId, + long long term, + bool dryRun, + OpTime lastOplogEntry); + virtual ~Algorithm(); + virtual std::vector<RemoteCommandRequest> getRequests() const; + virtual void processResponse(const RemoteCommandRequest& request, + const ResponseStatus& response); + virtual bool hasReceivedSufficientResponses() const; /** - * Informs the VoteRequester to cancel further processing. The "executor" - * argument must point to the same executor passed to "start()". + * Returns a VoteRequestResult indicating the result of the election. * - * Like start(), this method must run in the executor context. + * It is invalid to call this before hasReceivedSufficientResponses returns true. */ - void cancel(ReplicationExecutor* executor); - VoteRequestResult getResult() const; private: - std::unique_ptr<Algorithm> _algorithm; - std::unique_ptr<ScatterGatherRunner> _runner; - bool _isCanceled = false; + const ReplicaSetConfig _rsConfig; + const long long _candidateId; + const long long _term; + bool _dryRun = false; // this bool indicates this is a mock election when true + const OpTime _lastOplogEntry; + std::vector<HostAndPort> _targets; + bool _staleTerm = false; + long long _responsesProcessed = 0; + long long _votes = 1; }; + VoteRequester(); + virtual ~VoteRequester(); + + /** + * Begins the process of sending replSetRequestVotes commands to all non-DOWN nodes + * in currentConfig, in attempt to receive sufficient votes to win the election. + * + * evh can be used to schedule a callback when the process is complete. + * This function must be run in the executor, as it must be synchronous with the command + * callbacks that it schedules. + * If this function returns Status::OK(), evh is then guaranteed to be signaled. + **/ + StatusWith<ReplicationExecutor::EventHandle> start( + ReplicationExecutor* executor, + const ReplicaSetConfig& rsConfig, + long long candidateId, + long long term, + bool dryRun, + OpTime lastOplogEntry, + const stdx::function<void()>& onCompletion = stdx::function<void()>()); + + /** + * Informs the VoteRequester to cancel further processing. The "executor" + * argument must point to the same executor passed to "start()". + * + * Like start(), this method must run in the executor context. + */ + void cancel(ReplicationExecutor* executor); + + VoteRequestResult getResult() const; + +private: + std::unique_ptr<Algorithm> _algorithm; + std::unique_ptr<ScatterGatherRunner> _runner; + bool _isCanceled = false; +}; + } // namespace repl } // namespace mongo |