diff options
author | Qingyang Chen <qingyang.chen@10gen.com> | 2015-07-01 16:34:41 -0400 |
---|---|---|
committer | Qingyang Chen <qingyang.chen@10gen.com> | 2015-07-06 10:51:24 -0400 |
commit | 875b1b06e49f12c4e55200d441bcdeefc07d8310 (patch) | |
tree | c2fff98611d57d4aec85ec9036aa9ffd21e87cea /src | |
parent | 2f6e7ad9733e4b0532038f193f071a37c321c26d (diff) | |
download | mongo-875b1b06e49f12c4e55200d441bcdeefc07d8310.tar.gz |
SERVER-19247 remove implicit conversion from NamespaceString to std::string
Diffstat (limited to 'src')
35 files changed, 174 insertions, 176 deletions
diff --git a/src/mongo/client/parallel.cpp b/src/mongo/client/parallel.cpp index 02af92a8812..86e6e40af0d 100644 --- a/src/mongo/client/parallel.cpp +++ b/src/mongo/client/parallel.cpp @@ -508,13 +508,13 @@ void ParallelSortClusteredCursor::_markStaleNS(const NamespaceString& staleNS, bool& fullReload) { fullReload = e.requiresFullReload(); - if (_staleNSMap.find(staleNS) == _staleNSMap.end()) - _staleNSMap[staleNS] = 1; + if (_staleNSMap.find(staleNS.ns()) == _staleNSMap.end()) + _staleNSMap[staleNS.ns()] = 1; - int tries = ++_staleNSMap[staleNS]; + int tries = ++_staleNSMap[staleNS.ns()]; if (tries >= 5) { - throw SendStaleConfigException(staleNS, + throw SendStaleConfigException(staleNS.ns(), str::stream() << "too many retries of stale version info", e.getVersionReceived(), e.getVersionWanted()); @@ -528,7 +528,7 @@ void ParallelSortClusteredCursor::_handleStaleNS(const NamespaceString& staleNS, bool fullReload) { auto status = grid.catalogCache()->getDatabase(staleNS.db().toString()); if (!status.isOK()) { - warning() << "cannot reload database info for stale namespace " << staleNS; + warning() << "cannot reload database info for stale namespace " << staleNS.ns(); return; } @@ -541,10 +541,10 @@ void ParallelSortClusteredCursor::_handleStaleNS(const NamespaceString& staleNS, } if (!config) { - warning() << "cannot reload database info for stale namespace " << staleNS; + warning() << "cannot reload database info for stale namespace " << staleNS.ns(); } else { // Reload chunk manager, potentially forcing the namespace - config->getChunkManagerIfExists(staleNS, true, forceReload); + config->getChunkManagerIfExists(staleNS.ns(), true, forceReload); } } @@ -565,7 +565,7 @@ void ParallelSortClusteredCursor::setupVersionAndHandleSlaveOk(PCStatePtr state, // Setup conn if (!state->conn) { const auto shard = grid.shardRegistry()->getShard(shardId); - state->conn.reset(new ShardConnection(shard->getConnString(), ns, manager)); + state->conn.reset(new ShardConnection(shard->getConnString(), ns.ns(), manager)); } const DBClientBase* rawConn = state->conn->getRawConn(); @@ -631,7 +631,7 @@ void ParallelSortClusteredCursor::setupVersionAndHandleSlaveOk(PCStatePtr state, void ParallelSortClusteredCursor::startInit() { const bool returnPartial = (_qSpec.options() & QueryOption_PartialResults); - const NamespaceString ns(!_cInfo.isEmpty() ? _cInfo.versionedNS : _qSpec.ns()); + const NamespaceString nss(!_cInfo.isEmpty() ? _cInfo.versionedNS : _qSpec.ns()); shared_ptr<ChunkManager> manager; shared_ptr<Shard> primary; @@ -652,10 +652,10 @@ void ParallelSortClusteredCursor::startInit() { { shared_ptr<DBConfig> config; - auto status = grid.catalogCache()->getDatabase(ns.db().toString()); + auto status = grid.catalogCache()->getDatabase(nss.db().toString()); if (status.isOK()) { config = status.getValue(); - config->getChunkManagerOrPrimary(ns, manager, primary); + config->getChunkManagerOrPrimary(nss.ns(), manager, primary); } } @@ -737,7 +737,7 @@ void ParallelSortClusteredCursor::startInit() { mdata.pcState.reset(new PCState()); PCStatePtr state = mdata.pcState; - setupVersionAndHandleSlaveOk(state, shardId, primary, ns, vinfo, manager); + setupVersionAndHandleSlaveOk(state, shardId, primary, nss, vinfo, manager); const string& ns = _qSpec.ns(); @@ -837,7 +837,7 @@ void ParallelSortClusteredCursor::startInit() { // For legacy reasons, this may not be set in the exception :-( if (staleNS.size() == 0) - staleNS = ns; // ns is the *versioned* namespace, be careful of this + staleNS = nss; // ns is the *versioned* namespace, be careful of this // Probably need to retry fully bool forceReload, fullReload; @@ -849,8 +849,8 @@ void ParallelSortClusteredCursor::startInit() { << ", full : " << fullReload << causedBy(e) << endl; // This is somewhat strange - if (staleNS != ns) - warning() << "versioned ns " << ns << " doesn't match stale config namespace " + if (staleNS != nss) + warning() << "versioned ns " << nss.ns() << " doesn't match stale config namespace " << staleNS << endl; _handleStaleNS(staleNS, forceReload, fullReload); diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 00a3a643a5b..920f9623cb2 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -41,29 +41,29 @@ namespace mongo { Status collMod(OperationContext* txn, - const NamespaceString& ns, + const NamespaceString& nss, const BSONObj& cmdObj, BSONObjBuilder* result) { - StringData dbName = ns.db(); + StringData dbName = nss.db(); ScopedTransaction transaction(txn, MODE_IX); AutoGetDb autoDb(txn, dbName, MODE_X); Database* const db = autoDb.getDb(); - Collection* coll = db ? db->getCollection(ns) : NULL; + Collection* coll = db ? db->getCollection(nss) : NULL; // If db/collection does not exist, short circuit and return. if (!db || !coll) { return Status(ErrorCodes::NamespaceNotFound, "ns does not exist"); } - OldClientContext ctx(txn, ns); + OldClientContext ctx(txn, nss.ns()); bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() && - !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(ns); + !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss); if (userInitiatedWritesAndNotPrimary) { return Status(ErrorCodes::NotMaster, str::stream() << "Not primary while setting collection options on " - << ns.toString()); + << nss.ns()); } WriteUnitOfWork wunit(txn); @@ -102,7 +102,7 @@ Status collMod(OperationContext* txn, if (idx == NULL) { errorStatus = Status(ErrorCodes::InvalidOptions, str::stream() << "cannot find index " << keyPattern - << " for ns " << ns.toString()); + << " for ns " << nss.ns()); continue; } BSONElement oldExpireSecs = idx->infoObj().getField("expireAfterSeconds"); diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp index 67bfb70ae45..fde665b76a8 100644 --- a/src/mongo/db/catalog/drop_collection.cpp +++ b/src/mongo/db/catalog/drop_collection.cpp @@ -68,7 +68,7 @@ Status dropCollection(OperationContext* txn, if (!db || !coll) { return Status(ErrorCodes::NamespaceNotFound, "ns not found"); } - OldClientContext context(txn, collectionName); + OldClientContext context(txn, collectionName.ns()); bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() && !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(collectionName); @@ -86,7 +86,7 @@ Status dropCollection(OperationContext* txn, WriteUnitOfWork wunit(txn); Status s = db->dropCollection(txn, collectionName.ns()); - result.append("ns", collectionName); + result.append("ns", collectionName.ns()); if (!s.isOK()) { return s; diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp index 1f338303b69..1518ea58815 100644 --- a/src/mongo/db/catalog/drop_indexes.cpp +++ b/src/mongo/db/catalog/drop_indexes.cpp @@ -128,25 +128,24 @@ Status wrappedRun(OperationContext* txn, } // namespace Status dropIndexes(OperationContext* txn, - const NamespaceString& ns, + const NamespaceString& nss, const BSONObj& idxDescriptor, BSONObjBuilder* result) { - StringData dbName = ns.db(); + StringData dbName = nss.db(); MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { ScopedTransaction transaction(txn, MODE_IX); AutoGetDb autoDb(txn, dbName, MODE_X); bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() && - !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(ns); + !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss); if (userInitiatedWritesAndNotPrimary) { return Status(ErrorCodes::NotMaster, - str::stream() << "Not primary while dropping indexes in " - << ns.toString()); + str::stream() << "Not primary while dropping indexes in " << nss.ns()); } WriteUnitOfWork wunit(txn); - Status status = wrappedRun(txn, dbName, ns, autoDb.getDb(), idxDescriptor, result); + Status status = wrappedRun(txn, dbName, nss.ns(), autoDb.getDb(), idxDescriptor, result); if (!status.isOK()) { return status; } diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index a077a452fb8..f618b5e915a 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -70,7 +70,7 @@ Status renameCollection(OperationContext* txn, ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite globalWriteLock(txn->lockState()); // We stay in source context the whole time. This is mostly to set the CurOp namespace. - OldClientContext ctx(txn, source); + OldClientContext ctx(txn, source.ns()); bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() && !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(source); @@ -192,7 +192,7 @@ Status renameCollection(OperationContext* txn, // Process the source index. BSONObjBuilder newIndex; - newIndex.append("ns", target); + newIndex.append("ns", target.ns()); newIndex.appendElementsUnique(currIndex); indexesToCopy.push_back(newIndex.obj()); } diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index 4ce9a81eef1..2df427c14c9 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -269,7 +269,7 @@ void Cloner::copy(OperationContext* txn, { Lock::TempRelease tempRelease(txn->lockState()); _conn->query(stdx::function<void(DBClientCursorBatchIterator&)>(f), - from_collection, + from_collection.ns(), query, 0, options); @@ -298,7 +298,7 @@ void Cloner::copyIndexes(OperationContext* txn, { Lock::TempRelease tempRelease(txn->lockState()); list<BSONObj> sourceIndexes = - _conn->getIndexSpecs(from_collection, slaveOk ? QueryOption_SlaveOk : 0); + _conn->getIndexSpecs(from_collection.ns(), slaveOk ? QueryOption_SlaveOk : 0); for (list<BSONObj>::const_iterator it = sourceIndexes.begin(); it != sourceIndexes.end(); ++it) { indexesToBuild.push_back(fixindex(to_collection.db().toString(), *it)); diff --git a/src/mongo/db/commands/cleanup_orphaned_cmd.cpp b/src/mongo/db/commands/cleanup_orphaned_cmd.cpp index 50666033aa6..a58b8cd4932 100644 --- a/src/mongo/db/commands/cleanup_orphaned_cmd.cpp +++ b/src/mongo/db/commands/cleanup_orphaned_cmd.cpp @@ -113,7 +113,7 @@ CleanupResult cleanupOrphanedData(OperationContext* txn, return CleanupResult_Done; } - orphanRange.ns = ns; + orphanRange.ns = ns.ns(); *stoppedAtKey = orphanRange.maxKey; // We're done with this metadata now, no matter what happens diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp index a71357cb53a..df298009476 100644 --- a/src/mongo/db/commands/compact.cpp +++ b/src/mongo/db/commands/compact.cpp @@ -103,13 +103,13 @@ public: return false; } - NamespaceString ns(nsToCompact); - if (!ns.isNormal()) { + NamespaceString nss(nsToCompact); + if (!nss.isNormal()) { errmsg = "bad namespace name"; return false; } - if (ns.isSystem()) { + if (nss.isSystem()) { // items in system.* cannot be moved as there might be pointers to them // i.e. system.indexes entries are pointed to from NamespaceDetails errmsg = "can't compact a system namespace"; @@ -150,7 +150,7 @@ public: ScopedTransaction transaction(txn, MODE_IX); AutoGetDb autoDb(txn, db, MODE_X); Database* const collDB = autoDb.getDb(); - Collection* collection = collDB ? collDB->getCollection(ns) : NULL; + Collection* collection = collDB ? collDB->getCollection(nss) : NULL; // If db/collection does not exist, short circuit and return. if (!collDB || !collection) { @@ -158,15 +158,15 @@ public: return false; } - OldClientContext ctx(txn, ns); - BackgroundOperation::assertNoBgOpInProgForNs(ns.ns()); + OldClientContext ctx(txn, nss.ns()); + BackgroundOperation::assertNoBgOpInProgForNs(nss.ns()); if (collection->isCapped()) { errmsg = "cannot compact a capped collection"; return false; } - log() << "compact " << ns << " begin, options: " << compactOptions.toString(); + log() << "compact " << nss.ns() << " begin, options: " << compactOptions.toString(); StatusWith<CompactStats> status = collection->compact(txn, &compactOptions); if (!status.isOK()) @@ -175,7 +175,7 @@ public: if (status.getValue().corruptDocuments > 0) result.append("invalidObjects", status.getValue().corruptDocuments); - log() << "compact " << ns << " end"; + log() << "compact " << nss.ns() << " end"; return true; } diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index c18c33b7ce4..d941c3fa58e 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -82,7 +82,7 @@ public: BSONObj _addNsToSpec(const NamespaceString& ns, const BSONObj& obj) { BSONObjBuilder b; - b.append("ns", ns); + b.append("ns", ns.ns()); b.appendElements(obj); return b.obj(); } diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp index 8ab54774686..ec8bf54513d 100644 --- a/src/mongo/db/commands/geo_near_cmd.cpp +++ b/src/mongo/db/commands/geo_near_cmd.cpp @@ -186,7 +186,7 @@ public: const WhereCallbackReal whereCallback(txn, nss.db()); auto statusWithCQ = CanonicalQuery::canonicalize( - nss, rewritten, BSONObj(), projObj, 0, numWanted, BSONObj(), whereCallback); + nss.ns(), rewritten, BSONObj(), projObj, 0, numWanted, BSONObj(), whereCallback); if (!statusWithCQ.isOK()) { errmsg = "Can't parse filter / create query"; return false; diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index efdf7929bdb..1645692daf4 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -262,7 +262,7 @@ Status insertAuthzDocument(OperationContext* txn, const BSONObj& writeConcern) { try { DBDirectClient client(txn); - client.insert(collectionName, document); + client.insert(collectionName.ns(), document); // Handle write concern BSONObjBuilder gleBuilder; @@ -299,7 +299,7 @@ Status updateAuthzDocuments(OperationContext* txn, int* nMatched) { try { DBDirectClient client(txn); - client.update(collectionName, query, updatePattern, upsert, multi); + client.update(collectionName.ns(), query, updatePattern, upsert, multi); // Handle write concern BSONObjBuilder gleBuilder; @@ -362,7 +362,7 @@ Status removeAuthzDocuments(OperationContext* txn, int* numRemoved) { try { DBDirectClient client(txn); - client.remove(collectionName, query); + client.remove(collectionName.ns(), query); // Handle write concern BSONObjBuilder gleBuilder; diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 30a3e55926f..5e49cd26b37 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -888,7 +888,7 @@ public: return false; } - result.append("ns", nss); + result.append("ns", nss.ns()); long long size = collection->dataSize(txn) / scale; long long numRecords = collection->numRecords(txn); diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp index b4e76483a1f..0fe1949c452 100644 --- a/src/mongo/db/dbhelpers.cpp +++ b/src/mongo/db/dbhelpers.cpp @@ -85,7 +85,7 @@ void Helpers::ensureIndex(OperationContext* txn, const char* name) { BSONObjBuilder b; b.append("name", name); - b.append("ns", collection->ns()); + b.append("ns", collection->ns().ns()); b.append("key", keyPattern); b.appendBool("unique", unique); BSONObj o = b.done(); @@ -131,7 +131,7 @@ RecordId Helpers::findOne(OperationContext* txn, const WhereCallbackReal whereCallback(txn, collection->ns().db()); - auto statusWithCQ = CanonicalQuery::canonicalize(collection->ns(), query, whereCallback); + auto statusWithCQ = CanonicalQuery::canonicalize(collection->ns().ns(), query, whereCallback); massert(17244, "Could not canonicalize " + query.toString(), statusWithCQ.isOK()); unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index c34daf48d6b..b4831e0a6cb 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -685,7 +685,7 @@ void receivedUpdate(OperationContext* txn, const NamespaceString& nsString, Mess } Lock::CollectionLock collLock( txn->lockState(), nsString.ns(), parsedUpdate.isIsolated() ? MODE_X : MODE_IX); - OldClientContext ctx(txn, nsString); + OldClientContext ctx(txn, nsString.ns()); // The common case: no implicit collection creation if (!upsert || ctx.db()->getCollection(nsString) != NULL) { @@ -720,7 +720,7 @@ void receivedUpdate(OperationContext* txn, const NamespaceString& nsString, Mess ScopedTransaction transaction(txn, MODE_IX); Lock::DBLock dbLock(txn->lockState(), nsString.db(), MODE_X); - OldClientContext ctx(txn, nsString); + OldClientContext ctx(txn, nsString.ns()); uassert(ErrorCodes::NotMaster, str::stream() << "Not primary while performing update on " << nsString.ns(), repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nsString)); @@ -789,7 +789,7 @@ void receivedDelete(OperationContext* txn, const NamespaceString& nsString, Mess Lock::CollectionLock collLock( txn->lockState(), nsString.ns(), parsedDelete.isIsolated() ? MODE_X : MODE_IX); - OldClientContext ctx(txn, nsString); + OldClientContext ctx(txn, nsString.ns()); unique_ptr<PlanExecutor> exec = uassertStatusOK( getExecutorDelete(txn, ctx.db()->getCollection(nsString), &parsedDelete)); diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index 9a7e54500cf..f616631750b 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -94,9 +94,6 @@ public: return _ns; } - operator const std::string&() const { - return ns(); - } const std::string& toString() const { return ns(); } diff --git a/src/mongo/db/op_observer.cpp b/src/mongo/db/op_observer.cpp index f152de49dad..2d1ce157b43 100644 --- a/src/mongo/db/op_observer.cpp +++ b/src/mongo/db/op_observer.cpp @@ -167,8 +167,9 @@ void OpObserver::onRenameCollection(OperationContext* txn, bool dropTarget, bool stayTemp) { std::string dbName = fromCollection.db().toString() + ".$cmd"; - BSONObj cmdObj = BSON("renameCollection" << fromCollection << "to" << toCollection << "stayTemp" - << stayTemp << "dropTarget" << dropTarget); + BSONObj cmdObj = + BSON("renameCollection" << fromCollection.ns() << "to" << toCollection.ns() << "stayTemp" + << stayTemp << "dropTarget" << dropTarget); repl::_logOp(txn, "c", dbName.c_str(), cmdObj, nullptr, false); diff --git a/src/mongo/db/pipeline/document_source_merge_cursors.cpp b/src/mongo/db/pipeline/document_source_merge_cursors.cpp index 81df6ceb2bb..1d1c9a58a00 100644 --- a/src/mongo/db/pipeline/document_source_merge_cursors.cpp +++ b/src/mongo/db/pipeline/document_source_merge_cursors.cpp @@ -88,9 +88,9 @@ Value DocumentSourceMergeCursors::serialize(bool explain) const { } DocumentSourceMergeCursors::CursorAndConnection::CursorAndConnection(ConnectionString host, - NamespaceString ns, + NamespaceString nss, CursorId id) - : connection(host), cursor(connection.get(), ns, id, 0, 0) {} + : connection(host), cursor(connection.get(), nss.ns(), id, 0, 0) {} vector<DBClientCursor*> DocumentSourceMergeCursors::getCursors() { verify(_unstarted); diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp index cb702ef9cf7..8a8863486a0 100644 --- a/src/mongo/db/pipeline/document_source_out.cpp +++ b/src/mongo/db/pipeline/document_source_out.cpp @@ -91,7 +91,7 @@ void DocumentSourceOut::prepTempCollection() { } // copy indexes on _outputNs to _tempNs - const std::list<BSONObj> indexes = conn->getIndexSpecs(_outputNs); + const std::list<BSONObj> indexes = conn->getIndexSpecs(_outputNs.ns()); for (std::list<BSONObj>::const_iterator it = indexes.begin(); it != indexes.end(); ++it) { MutableDocument index((Document(*it))); index.remove("_id"); // indexes shouldn't have _ids but some existing ones do diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index 6281b84bdf4..136d1ca7f29 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -182,7 +182,7 @@ shared_ptr<PlanExecutor> PipelineD::prepareCursorSource( if (sortStage) { auto statusWithCQ = CanonicalQuery::canonicalize( - pExpCtx->ns, queryObj, sortObj, projectionForQuery, whereCallback); + pExpCtx->ns.ns(), queryObj, sortObj, projectionForQuery, whereCallback); if (statusWithCQ.isOK()) { auto statusWithPlanExecutor = getExecutor(txn, @@ -207,7 +207,7 @@ shared_ptr<PlanExecutor> PipelineD::prepareCursorSource( if (!exec.get()) { const BSONObj noSort; auto statusWithCQ = CanonicalQuery::canonicalize( - pExpCtx->ns, queryObj, noSort, projectionForQuery, whereCallback); + pExpCtx->ns.ns(), queryObj, noSort, projectionForQuery, whereCallback); uassertStatusOK(statusWithCQ.getStatus()); exec = uassertStatusOK(getExecutor(txn, diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp index 38f1e3144d4..e88a7442b3e 100644 --- a/src/mongo/db/query/canonical_query_test.cpp +++ b/src/mongo/db/query/canonical_query_test.cpp @@ -463,7 +463,7 @@ TEST(CanonicalQueryTest, SortTreeNumChildrenComparison) { */ unique_ptr<CanonicalQuery> canonicalize(const char* queryStr) { BSONObj queryObj = fromjson(queryStr); - auto statusWithCQ = CanonicalQuery::canonicalize(nss, queryObj); + auto statusWithCQ = CanonicalQuery::canonicalize(nss.ns(), queryObj); ASSERT_OK(statusWithCQ.getStatus()); return std::move(statusWithCQ.getValue()); } @@ -474,7 +474,7 @@ std::unique_ptr<CanonicalQuery> canonicalize(const char* queryStr, BSONObj queryObj = fromjson(queryStr); BSONObj sortObj = fromjson(sortStr); BSONObj projObj = fromjson(projStr); - auto statusWithCQ = CanonicalQuery::canonicalize(nss, queryObj, sortObj, projObj); + auto statusWithCQ = CanonicalQuery::canonicalize(nss.ns(), queryObj, sortObj, projObj); ASSERT_OK(statusWithCQ.getStatus()); return std::move(statusWithCQ.getValue()); } diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index c87b17859e9..aaccdd66d90 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -246,7 +246,7 @@ Status prepareExecution(OperationContext* opCtx, // Might have to filter out orphaned docs. if (plannerParams.options & QueryPlannerParams::INCLUDE_SHARD_FILTER) { *rootOut = new ShardFilterStage( - shardingState.getCollectionMetadata(collection->ns()), ws, *rootOut); + shardingState.getCollectionMetadata(collection->ns().ns()), ws, *rootOut); } // There might be a projection. The idhack stage will always fetch the full @@ -452,7 +452,7 @@ StatusWith<unique_ptr<PlanExecutor>> getExecutor(OperationContext* txn, !collection->getIndexCatalog()->findIdIndex(txn)) { const WhereCallbackReal whereCallback(txn, collection->ns().db()); auto statusWithCQ = - CanonicalQuery::canonicalize(collection->ns(), unparsedQuery, whereCallback); + CanonicalQuery::canonicalize(collection->ns().ns(), unparsedQuery, whereCallback); if (!statusWithCQ.isOK()) { return statusWithCQ.getStatus(); } @@ -471,7 +471,7 @@ StatusWith<unique_ptr<PlanExecutor>> getExecutor(OperationContext* txn, // Might have to filter out orphaned docs. if (plannerOptions & QueryPlannerParams::INCLUDE_SHARD_FILTER) { root = make_unique<ShardFilterStage>( - shardingState.getCollectionMetadata(collection->ns()), ws.get(), root.release()); + shardingState.getCollectionMetadata(collection->ns().ns()), ws.get(), root.release()); } return PlanExecutor::make(txn, std::move(ws), std::move(root), collection, yieldPolicy); diff --git a/src/mongo/db/query/stage_builder.cpp b/src/mongo/db/query/stage_builder.cpp index c5a922a6aaf..15bb04c1305 100644 --- a/src/mongo/db/query/stage_builder.cpp +++ b/src/mongo/db/query/stage_builder.cpp @@ -281,7 +281,7 @@ PlanStage* buildStages(OperationContext* txn, return NULL; } return new ShardFilterStage( - shardingState.getCollectionMetadata(collection->ns()), ws, childStage); + shardingState.getCollectionMetadata(collection->ns().ns()), ws, childStage); } else if (STAGE_KEEP_MUTATIONS == root->getType()) { const KeepMutationsNode* km = static_cast<const KeepMutationsNode*>(root); PlanStage* childStage = buildStages(txn, collection, qsol, km->children[0], ws); diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index d7a4c151910..9da43b387eb 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -234,7 +234,7 @@ Status refetch(FixUpInfo& fixUpInfo, const BSONObj& ourObj) { if (modification == "validator" || modification == "usePowerOf2Sizes" || modification == "noPadding") { - fixUpInfo.collectionsToResyncMetadata.insert(ns); + fixUpInfo.collectionsToResyncMetadata.insert(ns.ns()); continue; } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp index dae37303017..ccdf679f26f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp @@ -97,7 +97,7 @@ public: return 0; } - OldClientContext ctx(&txn, _ns, false); + OldClientContext ctx(&txn, _ns.ns(), false); WiredTigerRecordStore* rs = checked_cast<WiredTigerRecordStore*>(collection->getRecordStore()); WriteUnitOfWork wuow(&txn); diff --git a/src/mongo/dbtests/merge_chunk_tests.cpp b/src/mongo/dbtests/merge_chunk_tests.cpp index 7c2d0f72496..9d9a0397d6e 100644 --- a/src/mongo/dbtests/merge_chunk_tests.cpp +++ b/src/mongo/dbtests/merge_chunk_tests.cpp @@ -69,7 +69,7 @@ public: DBDirectClient client(&_txn); client.update(CollectionType::ConfigNS, - BSON(CollectionType::fullNs(coll.getNs())), + BSON(CollectionType::fullNs(coll.getNs().ns())), coll.toBSON(), true, false); @@ -79,7 +79,7 @@ public: ChunkType chunk; // TODO: We should not rely on the serialized ns, minkey being unique in the future, // causes problems since it links string serialization to correctness. - chunk.setName(Chunk::genID(nss, it->minKey)); + chunk.setName(Chunk::genID(nss.ns(), it->minKey)); chunk.setShard(shardName); chunk.setNS(nss.ns()); chunk.setVersion(nextVersion); @@ -141,8 +141,8 @@ TEST_F(MergeChunkTests, FailedMerge) { vector<KeyRange> ranges; // Setup chunk metadata - ranges.push_back(KeyRange(nss, BSON("x" << 0), BSON("x" << 10), kp)); - ranges.push_back(KeyRange(nss, BSON("x" << 10), BSON("x" << 20), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 0), BSON("x" << 10), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 10), BSON("x" << 20), kp)); storeCollectionRanges(nss, shardName(), ranges, ChunkVersion(1, 0, epoch)); // Do bad merges @@ -182,8 +182,8 @@ TEST_F(MergeChunkTests, FailedMergeHole) { vector<KeyRange> ranges; // Setup chunk metadata - ranges.push_back(KeyRange(nss, BSON("x" << 0), BSON("x" << 10), kp)); - ranges.push_back(KeyRange(nss, BSON("x" << 11), BSON("x" << 20), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 0), BSON("x" << 10), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 11), BSON("x" << 20), kp)); storeCollectionRanges(nss, shardName(), ranges, ChunkVersion(1, 0, epoch)); // Do bad merge with hole @@ -201,8 +201,8 @@ TEST_F(MergeChunkTests, FailedMergeMinMax) { vector<KeyRange> ranges; // Setup chunk metadata - ranges.push_back(KeyRange(nss, BSON("x" << MINKEY), BSON("x" << 0), kp)); - ranges.push_back(KeyRange(nss, BSON("x" << 0), BSON("x" << MAXKEY), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << MINKEY), BSON("x" << 0), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 0), BSON("x" << MAXKEY), kp)); storeCollectionRanges(nss, shardName(), ranges, ChunkVersion(1, 0, epoch)); // Do bad merge with hole @@ -224,14 +224,14 @@ TEST_F(MergeChunkTests, BasicMerge) { vector<KeyRange> ranges; // Setup chunk metadata - ranges.push_back(KeyRange(nss, BSON("x" << 0), BSON("x" << 1), kp)); - ranges.push_back(KeyRange(nss, BSON("x" << 1), BSON("x" << 2), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 0), BSON("x" << 1), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 1), BSON("x" << 2), kp)); storeCollectionRanges(nss, shardName(), ranges, ChunkVersion(1, 0, epoch)); // Get latest version ChunkVersion latestVersion; - shardingState.refreshMetadataNow(&_txn, nss, &latestVersion); - shardingState.resetMetadata(nss); + shardingState.refreshMetadataNow(&_txn, nss.ns(), &latestVersion); + shardingState.resetMetadata(nss.ns()); // Do merge string errMsg; @@ -240,7 +240,7 @@ TEST_F(MergeChunkTests, BasicMerge) { ASSERT(result); // Verify result - CollectionMetadataPtr metadata = shardingState.getCollectionMetadata(nss); + CollectionMetadataPtr metadata = shardingState.getCollectionMetadata(nss.ns()); ChunkType chunk; ASSERT(metadata->getNextChunk(BSON("x" << 0), &chunk)); @@ -261,14 +261,14 @@ TEST_F(MergeChunkTests, BasicMergeMinMax) { vector<KeyRange> ranges; // Setup chunk metadata - ranges.push_back(KeyRange(nss, BSON("x" << MINKEY), BSON("x" << 0), kp)); - ranges.push_back(KeyRange(nss, BSON("x" << 0), BSON("x" << MAXKEY), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << MINKEY), BSON("x" << 0), kp)); + ranges.push_back(KeyRange(nss.ns(), BSON("x" << 0), BSON("x" << MAXKEY), kp)); storeCollectionRanges(nss, shardName(), ranges, ChunkVersion(1, 0, epoch)); // Get latest version ChunkVersion latestVersion; - shardingState.refreshMetadataNow(&_txn, nss, &latestVersion); - shardingState.resetMetadata(nss); + shardingState.refreshMetadataNow(&_txn, nss.ns(), &latestVersion); + shardingState.resetMetadata(nss.ns()); // Do merge string errMsg; @@ -277,7 +277,7 @@ TEST_F(MergeChunkTests, BasicMergeMinMax) { ASSERT(result); // Verify result - CollectionMetadataPtr metadata = shardingState.getCollectionMetadata(nss); + CollectionMetadataPtr metadata = shardingState.getCollectionMetadata(nss.ns()); ChunkType chunk; ASSERT(metadata->getNextChunk(BSON("x" << MINKEY), &chunk)); @@ -298,14 +298,16 @@ TEST_F(MergeChunkTests, CompoundMerge) { vector<KeyRange> ranges; // Setup chunk metadata - ranges.push_back(KeyRange(nss, BSON("x" << 0 << "y" << 1), BSON("x" << 1 << "y" << 0), kp)); - ranges.push_back(KeyRange(nss, BSON("x" << 1 << "y" << 0), BSON("x" << 2 << "y" << 1), kp)); + ranges.push_back( + KeyRange(nss.ns(), BSON("x" << 0 << "y" << 1), BSON("x" << 1 << "y" << 0), kp)); + ranges.push_back( + KeyRange(nss.ns(), BSON("x" << 1 << "y" << 0), BSON("x" << 2 << "y" << 1), kp)); storeCollectionRanges(nss, shardName(), ranges, ChunkVersion(1, 0, epoch)); // Get latest version ChunkVersion latestVersion; - shardingState.refreshMetadataNow(&_txn, nss, &latestVersion); - shardingState.resetMetadata(nss); + shardingState.refreshMetadataNow(&_txn, nss.ns(), &latestVersion); + shardingState.resetMetadata(nss.ns()); // Do merge string errMsg; @@ -315,7 +317,7 @@ TEST_F(MergeChunkTests, CompoundMerge) { ASSERT(result); // Verify result - CollectionMetadataPtr metadata = shardingState.getCollectionMetadata(nss); + CollectionMetadataPtr metadata = shardingState.getCollectionMetadata(nss.ns()); ChunkType chunk; ASSERT(metadata->getNextChunk(BSON("x" << 0 << "y" << 1), &chunk)); diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index 03c615d1a45..52d9e0fc67f 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -223,35 +223,35 @@ public: ScopedTransaction transaction(&txn, MODE_X); Lock::GlobalWrite globalWriteLock(txn.lockState()); - OldClientContext ctx(&txn, source); + OldClientContext ctx(&txn, source.ns()); { WriteUnitOfWork uow(&txn); - ASSERT(!collectionExists(&ctx, source)); - ASSERT(!collectionExists(&ctx, target)); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); ASSERT_OK(userCreateNS(&txn, ctx.db(), source.ns(), BSONObj(), defaultIndexes)); uow.commit(); } - ASSERT(collectionExists(&ctx, source)); - ASSERT(!collectionExists(&ctx, target)); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); // END OF SETUP / START OF TEST { WriteUnitOfWork uow(&txn); ASSERT_OK(renameCollection(&txn, source, target)); - ASSERT(!collectionExists(&ctx, source)); - ASSERT(collectionExists(&ctx, target)); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); if (!rollback) { uow.commit(); } } if (rollback) { - ASSERT(collectionExists(&ctx, source)); - ASSERT(!collectionExists(&ctx, target)); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); } else { - ASSERT(!collectionExists(&ctx, source)); - ASSERT(collectionExists(&ctx, target)); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); } } }; @@ -269,7 +269,7 @@ public: ScopedTransaction transaction(&txn, MODE_X); Lock::GlobalWrite globalWriteLock(txn.lockState()); - OldClientContext ctx(&txn, source); + OldClientContext ctx(&txn, source.ns()); BSONObj sourceDoc = BSON("_id" << "source"); @@ -278,8 +278,8 @@ public: { WriteUnitOfWork uow(&txn); - ASSERT(!collectionExists(&ctx, source)); - ASSERT(!collectionExists(&ctx, target)); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(!collectionExists(&ctx, target.ns())); ASSERT_OK(userCreateNS(&txn, ctx.db(), source.ns(), BSONObj(), defaultIndexes)); ASSERT_OK(userCreateNS(&txn, ctx.db(), target.ns(), BSONObj(), defaultIndexes)); @@ -288,8 +288,8 @@ public: uow.commit(); } - ASSERT(collectionExists(&ctx, source)); - ASSERT(collectionExists(&ctx, target)); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&txn, source, sourceDoc); assertOnlyRecord(&txn, target, targetDoc); @@ -299,21 +299,21 @@ public: WriteUnitOfWork uow(&txn); ASSERT_OK(ctx.db()->dropCollection(&txn, target.ns())); ASSERT_OK(renameCollection(&txn, source, target)); - ASSERT(!collectionExists(&ctx, source)); - ASSERT(collectionExists(&ctx, target)); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&txn, target, sourceDoc); if (!rollback) { uow.commit(); } } if (rollback) { - ASSERT(collectionExists(&ctx, source)); - ASSERT(collectionExists(&ctx, target)); + ASSERT(collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&txn, source, sourceDoc); assertOnlyRecord(&txn, target, targetDoc); } else { - ASSERT(!collectionExists(&ctx, source)); - ASSERT(collectionExists(&ctx, target)); + ASSERT(!collectionExists(&ctx, source.ns())); + ASSERT(collectionExists(&ctx, target.ns())); assertOnlyRecord(&txn, target, sourceDoc); } } @@ -329,7 +329,7 @@ public: ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock dbXLock(txn.lockState(), nss.db(), MODE_X); - OldClientContext ctx(&txn, nss); + OldClientContext ctx(&txn, nss.ns()); BSONObj oldDoc = BSON("_id" << "old"); @@ -338,12 +338,12 @@ public: { WriteUnitOfWork uow(&txn); - ASSERT(!collectionExists(&ctx, nss)); + ASSERT(!collectionExists(&ctx, nss.ns())); ASSERT_OK(userCreateNS(&txn, ctx.db(), nss.ns(), BSONObj(), defaultIndexes)); insertRecord(&txn, nss, oldDoc); uow.commit(); } - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); assertOnlyRecord(&txn, nss, oldDoc); // END OF SETUP / START OF TEST @@ -351,16 +351,16 @@ public: { WriteUnitOfWork uow(&txn); ASSERT_OK(ctx.db()->dropCollection(&txn, nss.ns())); - ASSERT(!collectionExists(&ctx, nss)); + ASSERT(!collectionExists(&ctx, nss.ns())); ASSERT_OK(userCreateNS(&txn, ctx.db(), nss.ns(), BSONObj(), defaultIndexes)); - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&txn, nss, newDoc); assertOnlyRecord(&txn, nss, newDoc); if (!rollback) { uow.commit(); } } - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); if (rollback) { assertOnlyRecord(&txn, nss, oldDoc); } else { @@ -379,28 +379,28 @@ public: ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock dbXLock(txn.lockState(), nss.db(), MODE_X); - OldClientContext ctx(&txn, nss); + OldClientContext ctx(&txn, nss.ns()); BSONObj doc = BSON("_id" << "example string"); - ASSERT(!collectionExists(&ctx, nss)); + ASSERT(!collectionExists(&ctx, nss.ns())); { WriteUnitOfWork uow(&txn); ASSERT_OK(userCreateNS(&txn, ctx.db(), nss.ns(), BSONObj(), defaultIndexes)); - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&txn, nss, doc); assertOnlyRecord(&txn, nss, doc); ASSERT_OK(ctx.db()->dropCollection(&txn, nss.ns())); - ASSERT(!collectionExists(&ctx, nss)); + ASSERT(!collectionExists(&ctx, nss.ns())); if (!rollback) { uow.commit(); } } - ASSERT(!collectionExists(&ctx, nss)); + ASSERT(!collectionExists(&ctx, nss.ns())); } }; @@ -414,17 +414,17 @@ public: ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock dbXLock(txn.lockState(), nss.db(), MODE_X); - OldClientContext ctx(&txn, nss); + OldClientContext ctx(&txn, nss.ns()); BSONObj doc = BSON("_id" << "foo"); - ASSERT(!collectionExists(&ctx, nss)); + ASSERT(!collectionExists(&ctx, nss.ns())); { WriteUnitOfWork uow(&txn); ASSERT_OK(userCreateNS(&txn, ctx.db(), nss.ns(), BSONObj(), defaultIndexes)); - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); insertRecord(&txn, nss, doc); assertOnlyRecord(&txn, nss, doc); uow.commit(); @@ -437,14 +437,14 @@ public: WriteUnitOfWork uow(&txn); ASSERT_OK(truncateCollection(&txn, nss)); - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); assertEmpty(&txn, nss); if (!rollback) { uow.commit(); } } - ASSERT(collectionExists(&ctx, nss)); + ASSERT(collectionExists(&ctx, nss.ns())); if (rollback) { assertOnlyRecord(&txn, nss, doc); } else { diff --git a/src/mongo/s/balance.cpp b/src/mongo/s/balance.cpp index b3afa0d48ae..e172b588afc 100644 --- a/src/mongo/s/balance.cpp +++ b/src/mongo/s/balance.cpp @@ -357,15 +357,15 @@ void Balancer::_doBalanceRound(vector<shared_ptr<MigrateInfo>>* candidateChunks) // For each collection, check if the balancing policy recommends moving anything around. for (const auto& coll : collections) { // Skip collections for which balancing is disabled - const NamespaceString& ns = coll.getNs(); + const NamespaceString& nss = coll.getNs(); if (!coll.getAllowBalance()) { - LOG(1) << "Not balancing collection " << ns << "; explicitly disabled."; + LOG(1) << "Not balancing collection " << nss << "; explicitly disabled."; continue; } std::vector<ChunkType> allNsChunks; - grid.catalogManager()->getChunks(BSON(ChunkType::ns(ns)), + grid.catalogManager()->getChunks(BSON(ChunkType::ns(nss.ns())), BSON(ChunkType::min() << 1), boost::none, // all chunks &allNsChunks); @@ -381,7 +381,7 @@ void Balancer::_doBalanceRound(vector<shared_ptr<MigrateInfo>>* candidateChunks) } if (shardToChunksMap.empty()) { - LOG(1) << "skipping empty collection (" << ns << ")"; + LOG(1) << "skipping empty collection (" << nss.ns() << ")"; continue; } @@ -399,20 +399,19 @@ void Balancer::_doBalanceRound(vector<shared_ptr<MigrateInfo>>* candidateChunks) { vector<TagsType> collectionTags; - uassertStatusOK( - grid.catalogManager()->getTagsForCollection(ns.toString(), &collectionTags)); + uassertStatusOK(grid.catalogManager()->getTagsForCollection(nss.ns(), &collectionTags)); for (const auto& tt : collectionTags) { ranges.push_back( TagRange(tt.getMinKey().getOwned(), tt.getMaxKey().getOwned(), tt.getTag())); uassert(16356, - str::stream() << "tag ranges not valid for: " << ns.toString(), + str::stream() << "tag ranges not valid for: " << nss.ns(), status.addTagRange(ranges.back())); } } - auto statusGetDb = grid.catalogCache()->getDatabase(ns.db().toString()); + auto statusGetDb = grid.catalogCache()->getDatabase(nss.db().toString()); if (!statusGetDb.isOK()) { - warning() << "could not load db config to balance collection [" << ns + warning() << "could not load db config to balance collection [" << nss.ns() << "]: " << statusGetDb.getStatus(); continue; } @@ -421,9 +420,9 @@ void Balancer::_doBalanceRound(vector<shared_ptr<MigrateInfo>>* candidateChunks) // This line reloads the chunk manager once if this process doesn't know the collection // is sharded yet. - shared_ptr<ChunkManager> cm = cfg->getChunkManagerIfExists(ns, true); + shared_ptr<ChunkManager> cm = cfg->getChunkManagerIfExists(nss.ns(), true); if (!cm) { - warning() << "could not load chunks to balance " << ns << " collection"; + warning() << "could not load chunks to balance " << nss.ns() << " collection"; continue; } @@ -440,7 +439,7 @@ void Balancer::_doBalanceRound(vector<shared_ptr<MigrateInfo>>* candidateChunks) didAnySplits = true; - log() << "ns: " << ns << " need to split on " << min + log() << "nss: " << nss.ns() << " need to split on " << min << " because there is a range there"; ChunkPtr c = cm->findIntersectingChunk(min); @@ -463,7 +462,7 @@ void Balancer::_doBalanceRound(vector<shared_ptr<MigrateInfo>>* candidateChunks) continue; } - shared_ptr<MigrateInfo> migrateInfo(_policy->balance(ns, status, _balancedLastTime)); + shared_ptr<MigrateInfo> migrateInfo(_policy->balance(nss.ns(), status, _balancedLastTime)); if (migrateInfo) { candidateChunks->push_back(migrateInfo); } diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp index e66555b23ec..c74bea08a66 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp @@ -78,18 +78,18 @@ TEST_F(CatalogManagerReplSetTestFixture, GetCollectionExisting) { expectedColl.setEpoch(OID::gen()); auto future = launchAsync([this, &expectedColl] { - return assertGet(catalogManager()->getCollection(expectedColl.getNs())); + return assertGet(catalogManager()->getCollection(expectedColl.getNs().ns())); }); onFindCommand([&expectedColl](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), CollectionType::ConfigNS); + ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); // Ensure the query is correct ASSERT_EQ(query->ns(), CollectionType::ConfigNS); - ASSERT_EQ(query->getFilter(), BSON(CollectionType::fullNs(expectedColl.getNs()))); + ASSERT_EQ(query->getFilter(), BSON(CollectionType::fullNs(expectedColl.getNs().ns()))); ASSERT_EQ(query->getSort(), BSONObj()); ASSERT_EQ(query->getLimit().get(), 1); @@ -129,7 +129,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetDatabaseExisting) { onFindCommand([&expectedDb](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), DatabaseType::ConfigNS); + ASSERT_EQ(nss.ns(), DatabaseType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -338,7 +338,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetAllShardsValid) { onFindCommand([&s1, &s2, &s3](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), ShardType::ConfigNS); + ASSERT_EQ(nss.ns(), ShardType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -424,7 +424,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetChunksForNSWithSortAndLimit) { onFindCommand([&chunksQuery, chunkA, chunkB](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), ChunkType::ConfigNS); + ASSERT_EQ(nss.ns(), ChunkType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -462,7 +462,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetChunksForNSNoSortNoLimit) { onFindCommand([&chunksQuery](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), ChunkType::ConfigNS); + ASSERT_EQ(nss.ns(), ChunkType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -731,7 +731,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetGlobalSettingsBalancerDoc) { onFindCommand([st1](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), SettingsType::ConfigNS); + ASSERT_EQ(nss.ns(), SettingsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -759,7 +759,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetGlobalSettingsChunkSizeDoc) { onFindCommand([st1](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), SettingsType::ConfigNS); + ASSERT_EQ(nss.ns(), SettingsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -784,7 +784,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetGlobalSettingsInvalidDoc) { onFindCommand([](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), SettingsType::ConfigNS); + ASSERT_EQ(nss.ns(), SettingsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -812,7 +812,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetGlobalSettingsNonExistent) { onFindCommand([](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), SettingsType::ConfigNS); + ASSERT_EQ(nss.ns(), SettingsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -863,7 +863,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetCollectionsValidResultsNoDb) { onFindCommand([coll1, coll2, coll3](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), CollectionType::ConfigNS); + ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -910,7 +910,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetCollectionsValidResultsWithDb) { onFindCommand([coll1, coll2](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), CollectionType::ConfigNS); + ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -953,7 +953,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetCollectionsInvalidCollectionType) { onFindCommand([validColl](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), CollectionType::ConfigNS); + ASSERT_EQ(nss.ns(), CollectionType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -994,7 +994,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetDatabasesForShardValid) { onFindCommand([dbt1, dbt2](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), DatabaseType::ConfigNS); + ASSERT_EQ(nss.ns(), DatabaseType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1062,7 +1062,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetTagsForCollection) { onFindCommand([tagA, tagB](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), TagsType::ConfigNS); + ASSERT_EQ(nss.ns(), TagsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1142,7 +1142,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetTagForChunkOneTagFound) { onFindCommand([chunk](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), TagsType::ConfigNS); + ASSERT_EQ(nss.ns(), TagsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1182,7 +1182,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetTagForChunkNoTagFound) { onFindCommand([chunk](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), TagsType::ConfigNS); + ASSERT_EQ(nss.ns(), TagsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1219,7 +1219,7 @@ TEST_F(CatalogManagerReplSetTestFixture, GetTagForChunkInvalidTagDoc) { onFindCommand([chunk](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(nss.toString(), TagsType::ConfigNS); + ASSERT_EQ(nss.ns(), TagsType::ConfigNS); auto query = assertGet(LiteParsedQuery::makeFromFindCommand(nss, request.cmdObj, false)); @@ -1429,7 +1429,7 @@ TEST_F(CatalogManagerReplSetTestFixture, createDatabaseSuccess) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(DatabaseType::ConfigNS, nss.toString()); + ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); return vector<BSONObj>{}; }); @@ -1605,7 +1605,7 @@ TEST_F(CatalogManagerReplSetTestFixture, createDatabaseNoShards) { // Report no databases with the same name already exist onFindCommand([dbname](const RemoteCommandRequest& request) { const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(DatabaseType::ConfigNS, nss.toString()); + ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); return vector<BSONObj>{}; }); @@ -1687,7 +1687,7 @@ TEST_F(CatalogManagerReplSetTestFixture, createDatabaseDuplicateKeyOnInsert) { onFindCommand([&](const RemoteCommandRequest& request) { ASSERT_EQUALS(configHost, request.target); const NamespaceString nss(request.dbname, request.cmdObj.firstElement().String()); - ASSERT_EQ(DatabaseType::ConfigNS, nss.toString()); + ASSERT_EQ(DatabaseType::ConfigNS, nss.ns()); return vector<BSONObj>{}; }); diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp index e663a5dd640..65bd31a8628 100644 --- a/src/mongo/s/chunk_manager.cpp +++ b/src/mongo/s/chunk_manager.cpp @@ -161,7 +161,7 @@ ChunkManager::ChunkManager(const string& ns, const ShardKeyPattern& pattern, boo _chunkRanges() {} ChunkManager::ChunkManager(const CollectionType& coll) - : _ns(coll.getNs()), + : _ns(coll.getNs().ns()), _keyPattern(coll.getKeyPattern()), _unique(coll.getUnique()), _sequenceNumber(NextSequenceNumber.addAndFetch(1)), diff --git a/src/mongo/s/cluster_write.cpp b/src/mongo/s/cluster_write.cpp index 961a67383a6..7133e64f297 100644 --- a/src/mongo/s/cluster_write.cpp +++ b/src/mongo/s/cluster_write.cpp @@ -127,7 +127,7 @@ void splitIfNeeded(const NamespaceString& nss, const TargeterStats& stats) { ChunkManagerPtr chunkManager; ShardPtr dummyShard; - config->getChunkManagerOrPrimary(nss, chunkManager, dummyShard); + config->getChunkManagerOrPrimary(nss.ns(), chunkManager, dummyShard); if (!chunkManager) { return; diff --git a/src/mongo/s/collection_metadata_test.cpp b/src/mongo/s/collection_metadata_test.cpp index 05a44fb5c56..8fe16a8d5f5 100644 --- a/src/mongo/s/collection_metadata_test.cpp +++ b/src/mongo/s/collection_metadata_test.cpp @@ -76,7 +76,7 @@ protected: // Need a chunk on another shard, otherwise the chunks are invalid in general and we // can't load metadata ChunkType chunkType; - chunkType.setNS(NamespaceString{"test.foo"}); + chunkType.setNS(NamespaceString{"test.foo"}.ns()); chunkType.setShard("shard0001"); chunkType.setMin(BSON("a" << MINKEY)); chunkType.setMax(BSON("a" << MAXKEY)); diff --git a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp index c6173244fbb..d57e2de1cce 100644 --- a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp +++ b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp @@ -151,7 +151,7 @@ public: } // This refreshes the chunk metadata if stale. - ChunkManagerPtr manager = config->getChunkManagerIfExists(nss, true); + ChunkManagerPtr manager = config->getChunkManagerIfExists(nss.ns(), true); if (!manager) { return appendCommandStatus( result, diff --git a/src/mongo/s/config.cpp b/src/mongo/s/config.cpp index fc5f9d3bb72..c872d94a189 100644 --- a/src/mongo/s/config.cpp +++ b/src/mongo/s/config.cpp @@ -438,10 +438,10 @@ bool DBConfig::_load() { for (const auto& coll : collections) { if (coll.getDropped()) { - _collections.erase(coll.getNs()); + _collections.erase(coll.getNs().ns()); numCollsErased++; } else { - _collections[coll.getNs()] = CollectionInfo(coll); + _collections[coll.getNs().ns()] = CollectionInfo(coll); numCollsSharded++; } } diff --git a/src/mongo/s/metadata_loader_test.cpp b/src/mongo/s/metadata_loader_test.cpp index bf0fc14b3c8..d38a29d2cf5 100644 --- a/src/mongo/s/metadata_loader_test.cpp +++ b/src/mongo/s/metadata_loader_test.cpp @@ -167,7 +167,7 @@ TEST_F(MetadataLoaderFixture, BadChunk) { dummyConfig.insert(CollectionType::ConfigNS, collInfo.toBSON()); ChunkType chunkInfo; - chunkInfo.setNS(NamespaceString{"test.foo"}); + chunkInfo.setNS(NamespaceString{"test.foo"}.ns()); chunkInfo.setVersion(ChunkVersion(1, 0, collInfo.getEpoch())); ASSERT(!chunkInfo.validate().isOK()); diff --git a/src/mongo/s/mock_ns_targeter.h b/src/mongo/s/mock_ns_targeter.h index 6958c66f5a2..d450899031a 100644 --- a/src/mongo/s/mock_ns_targeter.h +++ b/src/mongo/s/mock_ns_targeter.h @@ -46,7 +46,7 @@ struct MockRange { const NamespaceString nss, const BSONObj& minKey, const BSONObj& maxKey) - : endpoint(endpoint), range(nss, minKey, maxKey, getKeyPattern(minKey)) {} + : endpoint(endpoint), range(nss.ns(), minKey, maxKey, getKeyPattern(minKey)) {} MockRange(const ShardEndpoint& endpoint, const KeyRange& range) : endpoint(endpoint), range(range) {} |