diff options
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/commands_public.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/config_upgrade_helpers.cpp | 22 | ||||
-rw-r--r-- | src/mongo/s/d_migrate.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/grid.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/grid.h | 2 | ||||
-rw-r--r-- | src/mongo/s/strategy_shard.cpp | 2 |
6 files changed, 17 insertions, 21 deletions
diff --git a/src/mongo/s/commands_public.cpp b/src/mongo/s/commands_public.cpp index 723fccd42de..c1f70e09e01 100644 --- a/src/mongo/s/commands_public.cpp +++ b/src/mongo/s/commands_public.cpp @@ -1867,7 +1867,7 @@ namespace mongo { // this function with any other collection name. uassert(16618, "Illegal attempt to run a command against a namespace other than $cmd.", - NamespaceString(ns).coll == "$cmd"); + nsToCollectionSubstring(ns) == "$cmd"); BSONElement e = jsobj.firstElement(); std::string commandName = e.fieldName(); diff --git a/src/mongo/s/config_upgrade_helpers.cpp b/src/mongo/s/config_upgrade_helpers.cpp index 3cdc40cef33..e586f5a1a06 100644 --- a/src/mongo/s/config_upgrade_helpers.cpp +++ b/src/mongo/s/config_upgrade_helpers.cpp @@ -70,7 +70,7 @@ namespace mongo { return Status::OK(); } - string _extractHashFor(const BSONObj& dbHashResult, const string& collName) { + string _extractHashFor(const BSONObj& dbHashResult, const StringData& collName) { if (dbHashResult["collections"].type() != Object || dbHashResult["collections"].Obj()[collName].type() != String) @@ -123,7 +123,7 @@ namespace mongo { try { ScopedDbConnection conn(configLoc, 30); - resultOk = conn->runCommand(nssA.db, BSON("dbHash" << true), result); + resultOk = conn->runCommand(nssA.db().toString(), BSON("dbHash" << true), result); conn.done(); } catch (const DBException& e) { @@ -132,11 +132,11 @@ namespace mongo { if (!resultOk) { return Status(ErrorCodes::UnknownError, - stream() << "could not run dbHash command on " << nssA.db << " db" + stream() << "could not run dbHash command on " << nssA.db() << " db" << causedBy(result.toString())); } - string hashResultA = _extractHashFor(result, nssA.coll); + string hashResultA = _extractHashFor(result, nssA.coll()); if (hashResultA == "") { return Status(ErrorCodes::RemoteValidationError, @@ -152,7 +152,7 @@ namespace mongo { try { ScopedDbConnection conn(configLoc, 30); - resultOk = conn->runCommand(nssB.db, BSON("dbHash" << true), result); + resultOk = conn->runCommand(nssB.db().toString(), BSON("dbHash" << true), result); conn.done(); } catch (const DBException& e) { @@ -161,11 +161,11 @@ namespace mongo { if (!resultOk) { return Status(ErrorCodes::UnknownError, - stream() << "could not run dbHash command on " << nssB.db << " db" + stream() << "could not run dbHash command on " << nssB.db() << " db" << causedBy(result.toString())); } - string hashResultB = _extractHashFor(result, nssB.coll); + string hashResultB = _extractHashFor(result, nssB.coll()); if (hashResultB == "") { return Status(ErrorCodes::RemoteValidationError, @@ -219,7 +219,7 @@ namespace mongo { verify(fromNSS.isValid()); // TODO: EnsureIndex at some point, if it becomes easier? - string indexesNS = fromNSS.db + ".system.indexes"; + string indexesNS = fromNSS.db().toString() + ".system.indexes"; scoped_ptr<DBClientCursor> cursor(_safeCursor(conn->query(indexesNS, BSON("ns" << fromNS)))); @@ -231,7 +231,7 @@ namespace mongo { newIndexDesc.append("ns", toNS); newIndexDesc.appendElementsUnique(next); - conn->insert(toNSS.db + ".system.indexes", newIndexDesc.done()); + conn->insert(toNSS.db().toString() + ".system.indexes", newIndexDesc.done()); _checkGLE(conn); } } @@ -304,8 +304,8 @@ namespace mongo { // Verify indices haven't changed Status indexStatus = checkIdsTheSame(configLoc, - fromNSS.db + ".system.indexes", - toNSS.db + ".system.indexes"); + fromNSS.db().toString() + ".system.indexes", + toNSS.db().toString() + ".system.indexes"); if (!indexStatus.isOK()) { return indexStatus; diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index cc3ac9939c0..ef97bf08fd6 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -1463,7 +1463,7 @@ namespace mongo { Client::WriteContext ctx( ns ); // Only copy if ns doesn't already exist if ( ! nsdetails( ns ) ) { - string system_namespaces = NamespaceString( ns ).db + ".system.namespaces"; + string system_namespaces = nsToDatabase(ns) + ".system.namespaces"; BSONObj entry = conn->findOne( system_namespaces, BSON( "name" << ns ) ); if ( entry["options"].isABSONObj() ) { string errmsg; diff --git a/src/mongo/s/grid.cpp b/src/mongo/s/grid.cpp index 62ea11f48b2..e3b0e7a6f94 100644 --- a/src/mongo/s/grid.cpp +++ b/src/mongo/s/grid.cpp @@ -38,12 +38,8 @@ namespace mongo { MONGO_FP_DECLARE(neverBalance); - DBConfigPtr Grid::getDBConfig( string database , bool create , const string& shardNameHint ) { - { - string::size_type i = database.find( "." ); - if ( i != string::npos ) - database = database.substr( 0 , i ); - } + DBConfigPtr Grid::getDBConfig( const StringData& ns , bool create , const string& shardNameHint ) { + string database = nsToDatabase( ns ); if ( database == "config" ) return configServerPtr; diff --git a/src/mongo/s/grid.h b/src/mongo/s/grid.h index 6d524fc9326..cfdb9f3647b 100644 --- a/src/mongo/s/grid.h +++ b/src/mongo/s/grid.h @@ -39,7 +39,7 @@ namespace mongo { * gets the config the db. * will return an empty DBConfig if not in db already */ - DBConfigPtr getDBConfig( string ns , bool create=true , const string& shardNameHint="" ); + DBConfigPtr getDBConfig( const StringData& ns , bool create=true , const string& shardNameHint="" ); /** * removes db entry. diff --git a/src/mongo/s/strategy_shard.cpp b/src/mongo/s/strategy_shard.cpp index 08c3511574c..e414b58c3c2 100644 --- a/src/mongo/s/strategy_shard.cpp +++ b/src/mongo/s/strategy_shard.cpp @@ -44,7 +44,7 @@ namespace mongo { class ShardStrategy : public Strategy { bool _isSystemIndexes( const char* ns ) { - return NamespaceString(ns).coll == "system.indexes"; + return nsToCollectionSubstring(ns) == "system.indexes"; } virtual void queryOp( Request& r ) { |