diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-06-15 14:37:03 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-06-16 16:25:39 -0400 |
commit | be88e42ef819aeb76b8625e646adf67626844c25 (patch) | |
tree | 5e6d5a9d71551160a7a421efe2fb26e28e22dce4 | |
parent | d124312c4c7d34678565a2607d13a016279b9893 (diff) | |
download | mongo-be88e42ef819aeb76b8625e646adf67626844c25.tar.gz |
SERVER-18236 cleanup ServerSelectionMetadata
-rw-r--r-- | src/mongo/rpc/metadata.cpp | 6 | ||||
-rw-r--r-- | src/mongo/rpc/metadata/server_selection_metadata.cpp | 9 | ||||
-rw-r--r-- | src/mongo/rpc/metadata/server_selection_metadata.h | 13 | ||||
-rw-r--r-- | src/mongo/rpc/metadata/server_selection_metadata_test.cpp | 2 |
4 files changed, 12 insertions, 18 deletions
diff --git a/src/mongo/rpc/metadata.cpp b/src/mongo/rpc/metadata.cpp index e7725dd4a74..c65953790ec 100644 --- a/src/mongo/rpc/metadata.cpp +++ b/src/mongo/rpc/metadata.cpp @@ -55,14 +55,12 @@ namespace rpc { return swAuditMetadata.getStatus(); } AuditMetadata::get(txn) = std::move(swAuditMetadata.getValue()); + return Status::OK(); } Status writeRequestMetadata(OperationContext* txn, BSONObjBuilder* metadataBob) { - auto ssStatus = ServerSelectionMetadata::writeToMetadata( - ServerSelectionMetadata::get(txn), - metadataBob - ); + auto ssStatus = ServerSelectionMetadata::get(txn).writeToMetadata(metadataBob); if (!ssStatus.isOK()) { return ssStatus; } diff --git a/src/mongo/rpc/metadata/server_selection_metadata.cpp b/src/mongo/rpc/metadata/server_selection_metadata.cpp index ffa576e5de6..4222c88e895 100644 --- a/src/mongo/rpc/metadata/server_selection_metadata.cpp +++ b/src/mongo/rpc/metadata/server_selection_metadata.cpp @@ -177,14 +177,13 @@ namespace { return ServerSelectionMetadata(secondaryOk, std::move(readPreference)); } - Status ServerSelectionMetadata::writeToMetadata(const ServerSelectionMetadata& ss, - BSONObjBuilder* metadataBob) { - if (ss.isSecondaryOk()) { + Status ServerSelectionMetadata::writeToMetadata(BSONObjBuilder* metadataBob) const { + if (isSecondaryOk()) { metadataBob->append(kSecondaryOkFieldName, 1); } - if (ss.getReadPreference()) { - metadataBob->append(kReadPreferenceFieldName, ss.getReadPreference()->toBSON()); + if (getReadPreference()) { + metadataBob->append(kReadPreferenceFieldName, getReadPreference()->toBSON()); } return Status::OK(); diff --git a/src/mongo/rpc/metadata/server_selection_metadata.h b/src/mongo/rpc/metadata/server_selection_metadata.h index 93ba352f317..4bdc700f20b 100644 --- a/src/mongo/rpc/metadata/server_selection_metadata.h +++ b/src/mongo/rpc/metadata/server_selection_metadata.h @@ -65,20 +65,18 @@ namespace rpc { #endif /** - * Loads ServerSelectionMetadata from a metadata object and stores it on this - * OperationContext. + * Loads ServerSelectionMetadata from a metadata object. */ static StatusWith<ServerSelectionMetadata> readFromMetadata(const BSONObj& metadataObj); /** * Writes this operation's ServerSelectionMetadata to a metadata object. */ - static Status writeToMetadata(const ServerSelectionMetadata& ss, - BSONObjBuilder* metadataBob); + Status writeToMetadata(BSONObjBuilder* metadataBob) const; /** - * Rewrites the ServerSelectionMetadata from the legacy OP_QUERY format to the metadata - * object format. In particular, if secondaryOk is set, this will set QueryOption_SlaveOk + * Rewrites the ServerSelectionMetadata from the metadata object format to the legacy OP_QUERY + * format. In particular, if secondaryOk is set, this will set QueryOption_SlaveOk * on the legacyQueryFlags. If a readPreference is set, the legacy command will be wrapped * in a 'query' element and a top-level $readPreference field will be set on the command. */ @@ -107,10 +105,9 @@ namespace rpc { */ const boost::optional<ReadPreferenceSetting>& getReadPreference() const; - private: ServerSelectionMetadata(bool secondaryOk, boost::optional<ReadPreferenceSetting> readPreference); - + private: bool _secondaryOk{false}; boost::optional<ReadPreferenceSetting> _readPreference{}; }; diff --git a/src/mongo/rpc/metadata/server_selection_metadata_test.cpp b/src/mongo/rpc/metadata/server_selection_metadata_test.cpp index a87b246359a..fe6de217b46 100644 --- a/src/mongo/rpc/metadata/server_selection_metadata_test.cpp +++ b/src/mongo/rpc/metadata/server_selection_metadata_test.cpp @@ -172,4 +172,4 @@ namespace { ErrorCodes::NoSuchKey); } -} +} // namespace |