diff options
author | Benety Goh <benety@mongodb.com> | 2016-01-26 16:26:15 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-02-05 13:32:33 -0500 |
commit | 1ecf7de7e18df42c154c04b1d9310956c91a75b7 (patch) | |
tree | 737f52e7e6ef1c3ca98caba26465ff37e22237a7 /src/mongo/db/repl/replica_set_config.h | |
parent | 102e832f218ecdec47d8eebf4e827072075325d7 (diff) | |
download | mongo-1ecf7de7e18df42c154c04b1d9310956c91a75b7.tar.gz |
SERVER-22287 added replicaSetId field to replica set configuration and metadata.
This field is generated when a replica set configuration is created from the replSetInitiate command
Diffstat (limited to 'src/mongo/db/repl/replica_set_config.h')
-rw-r--r-- | src/mongo/db/repl/replica_set_config.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/mongo/db/repl/replica_set_config.h b/src/mongo/db/repl/replica_set_config.h index 651c4e904da..509a84b0b5c 100644 --- a/src/mongo/db/repl/replica_set_config.h +++ b/src/mongo/db/repl/replica_set_config.h @@ -68,8 +68,11 @@ public: * Initializes this ReplicaSetConfig from the contents of "cfg". * The default protocol version is 0 to keep backward-compatibility. * If usePV1ByDefault is true, the protocol version will be 1 when it's not specified in "cfg". + * Sets _replicaSetId to "defaultReplicaSetId" if a replica set ID is not specified in "cfg". */ - Status initialize(const BSONObj& cfg, bool usePV1ByDefault = false); + Status initialize(const BSONObj& cfg, + bool usePV1ByDefault = false, + OID defaultReplicaSetId = OID()); /** * Same as the generic initialize() above except will default "configsvr" setting to the value @@ -294,6 +297,22 @@ public: } /** + * Returns true if this configuration contains a valid replica set ID. + * This ID is set at creation and is used to disambiguate replica set configurations that may + * have the same replica set name (_id field) but meant for different replica set instances. + */ + bool hasReplicaSetId() const { + return _replicaSetId.isSet(); + } + + /** + * Returns replica set ID. + */ + OID getReplicaSetId() const { + return _replicaSetId; + } + + /** * Returns the duration to wait before running for election when this node (indicated by * "memberIdx") sees that it has higher priority than the current primary. */ @@ -320,7 +339,14 @@ private: */ void _addInternalWriteConcernModes(); - Status _initialize(const BSONObj& cfg, bool forInitiate, bool usePV1ByDefault); + /** + * Sets replica set ID to 'defaultReplicaSetId' if forInitiate is false and 'cfg' does not + * contain an ID. + */ + Status _initialize(const BSONObj& cfg, + bool forInitiate, + bool usePV1ByDefault, + OID defaultReplicaSetId); bool _isInitialized = false; long long _version = 1; @@ -339,6 +365,7 @@ private: StringMap<ReplicaSetTagPattern> _customWriteConcernModes; long long _protocolVersion = 0; bool _configServer = false; + OID _replicaSetId; }; |