diff options
Diffstat (limited to 'src/mongo/db/repl/heartbeat_response_action.h')
-rw-r--r-- | src/mongo/db/repl/heartbeat_response_action.h | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/src/mongo/db/repl/heartbeat_response_action.h b/src/mongo/db/repl/heartbeat_response_action.h index 55c2d459920..f45b3668a91 100644 --- a/src/mongo/db/repl/heartbeat_response_action.h +++ b/src/mongo/db/repl/heartbeat_response_action.h @@ -33,88 +33,88 @@ namespace mongo { namespace repl { +/** + * Description of actions taken in response to a heartbeat. + * + * This includes when to schedule the next heartbeat to a target, and any other actions to + * take, such as scheduling an election or stepping down as primary. + */ +class HeartbeatResponseAction { +public: + /** + * Actions taken based on heartbeat responses + */ + enum Action { NoAction, Reconfig, StartElection, StepDownSelf, StepDownRemotePrimary }; + + /** + * Makes a new action representing doing nothing. + */ + static HeartbeatResponseAction makeNoAction(); + + /** + * Makes a new action representing the instruction to reconfigure the current node. + */ + static HeartbeatResponseAction makeReconfigAction(); + + /** + * Makes a new action telling the current node to attempt to elect itself primary. + */ + static HeartbeatResponseAction makeElectAction(); + + /** + * Makes a new action telling the current node to step down as primary. + * + * It is an error to call this with primaryIndex != the index of the current node. + */ + static HeartbeatResponseAction makeStepDownSelfAction(int primaryIndex); + /** - * Description of actions taken in response to a heartbeat. + * Makes a new action telling the current node to ask the specified remote node to step + * down as primary. * - * This includes when to schedule the next heartbeat to a target, and any other actions to - * take, such as scheduling an election or stepping down as primary. + * It is an error to call this with primaryIndex == the index of the current node. + */ + static HeartbeatResponseAction makeStepDownRemoteAction(int primaryIndex); + + /** + * Construct an action with unspecified action and a next heartbeat start date in the + * past. + */ + HeartbeatResponseAction(); + + /** + * Sets the date at which the next heartbeat should be scheduled. + */ + void setNextHeartbeatStartDate(Date_t when); + + /** + * Gets the action type of this action. + */ + Action getAction() const { + return _action; + } + + /** + * Gets the time at which the next heartbeat should be scheduled. If the + * time is not in the future, the next heartbeat should be scheduled immediately. + */ + Date_t getNextHeartbeatStartDate() const { + return _nextHeartbeatStartDate; + } + + /** + * If getAction() returns StepDownSelf or StepDownPrimary, this is the index + * in the current replica set config of the node that ought to step down. */ - class HeartbeatResponseAction { - public: - /** - * Actions taken based on heartbeat responses - */ - enum Action { - NoAction, - Reconfig, - StartElection, - StepDownSelf, - StepDownRemotePrimary - }; - - /** - * Makes a new action representing doing nothing. - */ - static HeartbeatResponseAction makeNoAction(); - - /** - * Makes a new action representing the instruction to reconfigure the current node. - */ - static HeartbeatResponseAction makeReconfigAction(); - - /** - * Makes a new action telling the current node to attempt to elect itself primary. - */ - static HeartbeatResponseAction makeElectAction(); - - /** - * Makes a new action telling the current node to step down as primary. - * - * It is an error to call this with primaryIndex != the index of the current node. - */ - static HeartbeatResponseAction makeStepDownSelfAction(int primaryIndex); - - /** - * Makes a new action telling the current node to ask the specified remote node to step - * down as primary. - * - * It is an error to call this with primaryIndex == the index of the current node. - */ - static HeartbeatResponseAction makeStepDownRemoteAction(int primaryIndex); - - /** - * Construct an action with unspecified action and a next heartbeat start date in the - * past. - */ - HeartbeatResponseAction(); - - /** - * Sets the date at which the next heartbeat should be scheduled. - */ - void setNextHeartbeatStartDate(Date_t when); - - /** - * Gets the action type of this action. - */ - Action getAction() const { return _action; } - - /** - * Gets the time at which the next heartbeat should be scheduled. If the - * time is not in the future, the next heartbeat should be scheduled immediately. - */ - Date_t getNextHeartbeatStartDate() const { return _nextHeartbeatStartDate; } - - /** - * If getAction() returns StepDownSelf or StepDownPrimary, this is the index - * in the current replica set config of the node that ought to step down. - */ - int getPrimaryConfigIndex() const { return _primaryIndex; } - - private: - Action _action; - int _primaryIndex; - Date_t _nextHeartbeatStartDate; - }; + int getPrimaryConfigIndex() const { + return _primaryIndex; + } + +private: + Action _action; + int _primaryIndex; + Date_t _nextHeartbeatStartDate; +}; } // namespace repl } // namespace mongo |