diff options
author | Mathias Stearn <mathias@10gen.com> | 2017-04-28 16:45:25 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2017-05-12 12:07:30 -0400 |
commit | f9b8a9eb2d196d93a08714c9bbcecbb7fe30a5f3 (patch) | |
tree | 7b0ddca11558c0c81529e85f07e2cdb8ab1091f5 /src/mongo/db/repl | |
parent | f0e1e116322917c83e0c1d11b56afa088fe6ccd7 (diff) | |
download | mongo-f9b8a9eb2d196d93a08714c9bbcecbb7fe30a5f3.tar.gz |
SERVER-28814 Add and use ReadPreferenceSetting::secondaryPreferredMetadata()
This is prep for eliminating ServerSelectionMetadata in favor of just
ReadPreferenceSetting.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/collection_cloner.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/database_cloner.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/databases_cloner.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/initial_syncer.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.cpp | 20 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_common_point_resolver.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_source_resolver.cpp | 4 |
8 files changed, 20 insertions, 22 deletions
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp index 72fc777ff08..67ba31592fc 100644 --- a/src/mongo/db/repl/collection_cloner.cpp +++ b/src/mongo/db/repl/collection_cloner.cpp @@ -95,7 +95,7 @@ CollectionCloner::CollectionCloner(executor::TaskExecutor* executor, RemoteCommandRequest(_source, _sourceNss.db().toString(), BSON("count" << _sourceNss.coll()), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), nullptr, RemoteCommandRequest::kNoTimeout), stdx::bind(&CollectionCloner::_countCallback, this, stdx::placeholders::_1), @@ -112,7 +112,7 @@ CollectionCloner::CollectionCloner(executor::TaskExecutor* executor, stdx::placeholders::_1, stdx::placeholders::_2, stdx::placeholders::_3), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), RemoteCommandRequest::kNoTimeout, RemoteCommandRetryScheduler::makeRetryPolicy( numInitialSyncListIndexesAttempts.load(), @@ -488,7 +488,7 @@ void CollectionCloner::_beginCollectionCallback(const executor::TaskExecutor::Ca stdx::placeholders::_2, stdx::placeholders::_3, onCompletionGuard), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), RemoteCommandRequest::kNoTimeout, RemoteCommandRetryScheduler::makeRetryPolicy( numInitialSyncCollectionFindAttempts.load(), diff --git a/src/mongo/db/repl/database_cloner.cpp b/src/mongo/db/repl/database_cloner.cpp index 649d6d8efa3..9015b723dec 100644 --- a/src/mongo/db/repl/database_cloner.cpp +++ b/src/mongo/db/repl/database_cloner.cpp @@ -115,7 +115,7 @@ DatabaseCloner::DatabaseCloner(executor::TaskExecutor* executor, stdx::placeholders::_1, stdx::placeholders::_2, stdx::placeholders::_3), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), RemoteCommandRequest::kNoTimeout, RemoteCommandRetryScheduler::makeRetryPolicy( numInitialSyncListCollectionsAttempts.load(), diff --git a/src/mongo/db/repl/databases_cloner.cpp b/src/mongo/db/repl/databases_cloner.cpp index ff0c9170e15..4e423aeb77b 100644 --- a/src/mongo/db/repl/databases_cloner.cpp +++ b/src/mongo/db/repl/databases_cloner.cpp @@ -204,7 +204,7 @@ Status DatabasesCloner::startup() noexcept { Request listDBsReq(_source, "admin", BSON("listDatabases" << true), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), nullptr); _listDBsScheduler = stdx::make_unique<RemoteCommandRetryScheduler>( _exec, diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 5193be72264..b200804dda1 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -1165,7 +1165,7 @@ Status InitialSyncer::_scheduleLastOplogEntryFetcher_inlock(Fetcher::CallbackFn _opts.remoteOplogNS.db().toString(), query, callback, - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), RemoteCommandRequest::kNoTimeout, RemoteCommandRetryScheduler::makeRetryPolicy( numInitialSyncOplogFindAttempts.load(), diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index 54b572b3e68..071d401bca2 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -98,15 +98,15 @@ BSONObj makeGetMoreCommandObject(const NamespaceString& nss, /** * Returns command metadata object suitable for tailing remote oplog. */ -StatusWith<BSONObj> makeMetadataObject(bool isV1ElectionProtocol) { - return isV1ElectionProtocol - ? BSON(rpc::kReplSetMetadataFieldName - << 1 - << rpc::kOplogQueryMetadataFieldName - << 1 - << rpc::ServerSelectionMetadata::fieldName() - << BSON(rpc::ServerSelectionMetadata::kSecondaryOkFieldName << true)) - : rpc::ServerSelectionMetadata(true, boost::none).toBSON(); +BSONObj makeMetadataObject(bool isV1ElectionProtocol) { + if (!isV1ElectionProtocol) + return ReadPreferenceSetting::secondaryPreferredMetadata(); + + BSONObjBuilder metaBuilder; + metaBuilder << rpc::kReplSetMetadataFieldName << 1; + metaBuilder << rpc::kOplogQueryMetadataFieldName << 1; + metaBuilder.appendElements(ReadPreferenceSetting::secondaryPreferredMetadata()); + return metaBuilder.obj(); } /** @@ -320,7 +320,7 @@ OplogFetcher::OplogFetcher(executor::TaskExecutor* executor, maxFetcherRestarts, onShutdownCallbackFn, "oplog fetcher"), - _metadataObject(uassertStatusOK(makeMetadataObject(config.getProtocolVersion() == 1LL))), + _metadataObject(makeMetadataObject(config.getProtocolVersion() == 1LL)), _requiredRBID(requiredRBID), _requireFresherSyncSource(requireFresherSyncSource), _dataReplicatorExternalState(dataReplicatorExternalState), diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp index af4e74f99a3..ee4cf02f5fc 100644 --- a/src/mongo/db/repl/oplog_fetcher_test.cpp +++ b/src/mongo/db/repl/oplog_fetcher_test.cpp @@ -279,9 +279,7 @@ TEST_F(OplogFetcherTest, MetadataObjectIsEmptyUnderProtocolVersion0) { enqueueDocumentsFn, [](Status) {}) .getMetadataObject_forTest(); - ASSERT_BSONOBJ_EQ(BSON(rpc::ServerSelectionMetadata::fieldName() - << BSON(rpc::ServerSelectionMetadata::kSecondaryOkFieldName << 1)), - metadataObj); + ASSERT_BSONOBJ_EQ(ReadPreferenceSetting::secondaryPreferredMetadata(), metadataObj); } TEST_F(OplogFetcherTest, AwaitDataTimeoutShouldEqualHalfElectionTimeoutUnderProtocolVersion1) { diff --git a/src/mongo/db/repl/rollback_common_point_resolver.cpp b/src/mongo/db/repl/rollback_common_point_resolver.cpp index 747818e6a9a..258fe3c9a24 100644 --- a/src/mongo/db/repl/rollback_common_point_resolver.cpp +++ b/src/mongo/db/repl/rollback_common_point_resolver.cpp @@ -96,7 +96,7 @@ RollbackCommonPointResolver::RollbackCommonPointResolver(executor::TaskExecutor* maxFetcherRestarts, onShutdownCallbackFn, "rollback common point resolver"), - _metadataObject(rpc::ServerSelectionMetadata(true, boost::none).toBSON()), + _metadataObject(ReadPreferenceSetting::secondaryPreferredMetadata()), _localOplog(localOplog), _listener(listener) { diff --git a/src/mongo/db/repl/sync_source_resolver.cpp b/src/mongo/db/repl/sync_source_resolver.cpp index d14be44f6fe..6589660709e 100644 --- a/src/mongo/db/repl/sync_source_resolver.cpp +++ b/src/mongo/db/repl/sync_source_resolver.cpp @@ -174,7 +174,7 @@ std::unique_ptr<Fetcher> SyncSourceResolver::_makeFirstOplogEntryFetcher( stdx::placeholders::_1, candidate, earliestOpTimeSeen), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), kFetcherTimeout); } @@ -194,7 +194,7 @@ std::unique_ptr<Fetcher> SyncSourceResolver::_makeRequiredOpTimeFetcher(HostAndP stdx::placeholders::_1, candidate, earliestOpTimeSeen), - rpc::ServerSelectionMetadata(true, boost::none).toBSON(), + ReadPreferenceSetting::secondaryPreferredMetadata(), kFetcherTimeout); } |