summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/is_master_response.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/is_master_response.h')
-rw-r--r--src/mongo/db/repl/is_master_response.h293
1 files changed, 165 insertions, 128 deletions
diff --git a/src/mongo/db/repl/is_master_response.h b/src/mongo/db/repl/is_master_response.h
index dd0eda70e2b..7bfaf1ac0b2 100644
--- a/src/mongo/db/repl/is_master_response.h
+++ b/src/mongo/db/repl/is_master_response.h
@@ -38,179 +38,216 @@
namespace mongo {
- class BSONObj;
- class BSONObjBuilder;
- class Status;
+class BSONObj;
+class BSONObjBuilder;
+class Status;
namespace repl {
+/**
+ * Response structure for the ismaster command. Only handles responses from nodes
+ * that are in replset mode.
+ */
+class IsMasterResponse {
+public:
+ IsMasterResponse();
+
/**
- * Response structure for the ismaster command. Only handles responses from nodes
- * that are in replset mode.
+ * Initializes this IsMasterResponse from the contents of "doc".
*/
- class IsMasterResponse {
- public:
- IsMasterResponse();
-
- /**
- * Initializes this IsMasterResponse from the contents of "doc".
- */
- Status initialize(const BSONObj& doc);
-
- /**
- * Appends all non-default values to "builder".
- * There are two values that are handled specially: if _inShutdown is true or _configSet
- * is false, we will add a standard response to "builder" indicating either that we are
- * in the middle of shutting down or we do not have a valid replica set config, ignoring
- * the values of all other member variables.
- */
- void addToBSON(BSONObjBuilder* builder) const;
+ Status initialize(const BSONObj& doc);
- /**
- * Returns a BSONObj consisting the results of calling addToBSON on an otherwise empty
- * BSONObjBuilder.
- */
- BSONObj toBSON() const;
-
-
- // ===================== Accessors for member variables ================================= //
-
- bool isMaster() const { return _isMaster; }
+ /**
+ * Appends all non-default values to "builder".
+ * There are two values that are handled specially: if _inShutdown is true or _configSet
+ * is false, we will add a standard response to "builder" indicating either that we are
+ * in the middle of shutting down or we do not have a valid replica set config, ignoring
+ * the values of all other member variables.
+ */
+ void addToBSON(BSONObjBuilder* builder) const;
- bool isSecondary() const { return _secondary; }
+ /**
+ * Returns a BSONObj consisting the results of calling addToBSON on an otherwise empty
+ * BSONObjBuilder.
+ */
+ BSONObj toBSON() const;
- const std::string& getReplSetName() const { return _setName; }
- long long getReplSetVersion() const { return _setVersion; }
+ // ===================== Accessors for member variables ================================= //
- const std::vector<HostAndPort>& getHosts() const { return _hosts; }
+ bool isMaster() const {
+ return _isMaster;
+ }
- const std::vector<HostAndPort>& getPassives() const { return _passives; }
+ bool isSecondary() const {
+ return _secondary;
+ }
- const std::vector<HostAndPort>& getArbiters() const { return _arbiters; }
+ const std::string& getReplSetName() const {
+ return _setName;
+ }
- const HostAndPort& getPrimary() const { return _primary; }
+ long long getReplSetVersion() const {
+ return _setVersion;
+ }
- bool hasPrimary() const { return _primarySet; }
+ const std::vector<HostAndPort>& getHosts() const {
+ return _hosts;
+ }
- bool isArbiterOnly() const { return _arbiterOnly; }
+ const std::vector<HostAndPort>& getPassives() const {
+ return _passives;
+ }
- bool isPassive() const { return _passive; }
+ const std::vector<HostAndPort>& getArbiters() const {
+ return _arbiters;
+ }
- bool isHidden() const { return _hidden; }
+ const HostAndPort& getPrimary() const {
+ return _primary;
+ }
- bool shouldBuildIndexes() const { return _buildIndexes; }
+ bool hasPrimary() const {
+ return _primarySet;
+ }
- Seconds getSlaveDelay() const { return _slaveDelay; }
+ bool isArbiterOnly() const {
+ return _arbiterOnly;
+ }
- const unordered_map<std::string, std::string> getTags() const { return _tags; }
+ bool isPassive() const {
+ return _passive;
+ }
- const HostAndPort& getMe() const { return _me; }
+ bool isHidden() const {
+ return _hidden;
+ }
- const OID& getElectionId() const { return _electionId; }
+ bool shouldBuildIndexes() const {
+ return _buildIndexes;
+ }
- /**
- * If false, calls to toBSON/addToBSON will ignore all other fields and add a specific
- * message to indicate that we have no replica set config.
- */
- bool isConfigSet() const { return _configSet; }
+ Seconds getSlaveDelay() const {
+ return _slaveDelay;
+ }
- /**
- * If false, calls to toBSON/addToBSON will ignore all other fields and add a specific
- * message to indicate that we are in the middle of shutting down.
- */
- bool isShutdownInProgress() const { return _shutdownInProgress; }
+ const unordered_map<std::string, std::string> getTags() const {
+ return _tags;
+ }
+ const HostAndPort& getMe() const {
+ return _me;
+ }
- // ===================== Mutators for member variables ================================= //
+ const OID& getElectionId() const {
+ return _electionId;
+ }
- void setIsMaster(bool isMaster);
+ /**
+ * If false, calls to toBSON/addToBSON will ignore all other fields and add a specific
+ * message to indicate that we have no replica set config.
+ */
+ bool isConfigSet() const {
+ return _configSet;
+ }
- void setIsSecondary(bool secondary);
+ /**
+ * If false, calls to toBSON/addToBSON will ignore all other fields and add a specific
+ * message to indicate that we are in the middle of shutting down.
+ */
+ bool isShutdownInProgress() const {
+ return _shutdownInProgress;
+ }
- void setReplSetName(const std::string& setName);
- void setReplSetVersion(long long version);
+ // ===================== Mutators for member variables ================================= //
- void addHost(const HostAndPort& host);
+ void setIsMaster(bool isMaster);
- void addPassive(const HostAndPort& passive);
+ void setIsSecondary(bool secondary);
- void addArbiter(const HostAndPort& arbiter);
+ void setReplSetName(const std::string& setName);
- void setPrimary(const HostAndPort& primary);
+ void setReplSetVersion(long long version);
- void setIsArbiterOnly(bool arbiterOnly);
+ void addHost(const HostAndPort& host);
- void setIsPassive(bool passive);
+ void addPassive(const HostAndPort& passive);
- void setIsHidden(bool hidden);
+ void addArbiter(const HostAndPort& arbiter);
- void setShouldBuildIndexes(bool buildIndexes);
+ void setPrimary(const HostAndPort& primary);
- void setSlaveDelay(Seconds slaveDelay);
+ void setIsArbiterOnly(bool arbiterOnly);
- void addTag(const std::string& tagKey, const std::string& tagValue);
+ void setIsPassive(bool passive);
- void setMe(const HostAndPort& me);
+ void setIsHidden(bool hidden);
- void setElectionId(const OID& electionId);
+ void setShouldBuildIndexes(bool buildIndexes);
- /**
- * Marks _configSet as false, which will cause future calls to toBSON/addToBSON to ignore
- * all other member variables and output a hardcoded response indicating that we have no
- * valid replica set config.
- */
- void markAsNoConfig();
+ void setSlaveDelay(Seconds slaveDelay);
- /**
- * Marks _shutdownInProgress as true, which will cause future calls to toBSON/addToBSON to
- * ignore all other member variables and output a hardcoded response indicating that we are
- * in the middle of shutting down.
- */
- void markAsShutdownInProgress();
+ void addTag(const std::string& tagKey, const std::string& tagValue);
- private:
+ void setMe(const HostAndPort& me);
- bool _isMaster;
- bool _isMasterSet;
- bool _secondary;
- bool _isSecondarySet;
- std::string _setName;
- bool _setNameSet;
- long long _setVersion;
- bool _setVersionSet;
- std::vector<HostAndPort> _hosts;
- bool _hostsSet;
- std::vector<HostAndPort> _passives;
- bool _passivesSet;
- std::vector<HostAndPort> _arbiters;
- bool _arbitersSet;
- HostAndPort _primary;
- bool _primarySet;
- bool _arbiterOnly;
- bool _arbiterOnlySet;
- bool _passive;
- bool _passiveSet;
- bool _hidden;
- bool _hiddenSet;
- bool _buildIndexes;
- bool _buildIndexesSet;
- Seconds _slaveDelay;
- bool _slaveDelaySet;
- unordered_map<std::string, std::string> _tags;
- bool _tagsSet;
- HostAndPort _me;
- bool _meSet;
- OID _electionId;
+ void setElectionId(const OID& electionId);
- // If _configSet is false this means we don't have a valid repl set config, so toBSON
- // will return a set of hardcoded values that indicate this.
- bool _configSet;
- // If _shutdownInProgress is true toBSON will return a set of hardcoded values to indicate
- // that we are mid shutdown
- bool _shutdownInProgress;
- };
+ /**
+ * Marks _configSet as false, which will cause future calls to toBSON/addToBSON to ignore
+ * all other member variables and output a hardcoded response indicating that we have no
+ * valid replica set config.
+ */
+ void markAsNoConfig();
-} // namespace repl
-} // namespace mongo
+ /**
+ * Marks _shutdownInProgress as true, which will cause future calls to toBSON/addToBSON to
+ * ignore all other member variables and output a hardcoded response indicating that we are
+ * in the middle of shutting down.
+ */
+ void markAsShutdownInProgress();
+
+private:
+ bool _isMaster;
+ bool _isMasterSet;
+ bool _secondary;
+ bool _isSecondarySet;
+ std::string _setName;
+ bool _setNameSet;
+ long long _setVersion;
+ bool _setVersionSet;
+ std::vector<HostAndPort> _hosts;
+ bool _hostsSet;
+ std::vector<HostAndPort> _passives;
+ bool _passivesSet;
+ std::vector<HostAndPort> _arbiters;
+ bool _arbitersSet;
+ HostAndPort _primary;
+ bool _primarySet;
+ bool _arbiterOnly;
+ bool _arbiterOnlySet;
+ bool _passive;
+ bool _passiveSet;
+ bool _hidden;
+ bool _hiddenSet;
+ bool _buildIndexes;
+ bool _buildIndexesSet;
+ Seconds _slaveDelay;
+ bool _slaveDelaySet;
+ unordered_map<std::string, std::string> _tags;
+ bool _tagsSet;
+ HostAndPort _me;
+ bool _meSet;
+ OID _electionId;
+
+ // If _configSet is false this means we don't have a valid repl set config, so toBSON
+ // will return a set of hardcoded values that indicate this.
+ bool _configSet;
+ // If _shutdownInProgress is true toBSON will return a set of hardcoded values to indicate
+ // that we are mid shutdown
+ bool _shutdownInProgress;
+};
+
+} // namespace repl
+} // namespace mongo