diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-06-17 14:29:48 -0400 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-06-18 13:09:18 -0400 |
commit | 149d8c8f83017db23b104da1f020d0a994fb79f9 (patch) | |
tree | b3de559193c25708fca27234f8d498f08d444ac9 /src/mongo/db/repl/master_slave.cpp | |
parent | dd759f777875702f9618ed9379c5379247cdb7d1 (diff) | |
download | mongo-149d8c8f83017db23b104da1f020d0a994fb79f9.tar.gz |
SERVER-18723 boost -> stdx for thread
Diffstat (limited to 'src/mongo/db/repl/master_slave.cpp')
-rw-r--r-- | src/mongo/db/repl/master_slave.cpp | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index 65f648a2846..b01d74fefe7 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -43,7 +43,6 @@ #include "mongo/db/repl/master_slave.h" #include <pcrecpp.h> -#include <boost/thread/thread.hpp> #include "mongo/db/auth/authorization_manager.h" #include "mongo/db/auth/authorization_session.h" @@ -55,19 +54,19 @@ #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/service_context.h" #include "mongo/db/op_observer.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/ops/update.h" #include "mongo/db/query/internal_plans.h" -#include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/handshake_args.h" #include "mongo/db/repl/oplog.h" +#include "mongo/db/repl/repl_client_info.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/repl/sync_tail.h" #include "mongo/db/server_parameters.h" +#include "mongo/db/service_context.h" #include "mongo/db/storage_options.h" -#include "mongo/util/concurrency/old_thread_pool.h" +#include "mongo/stdx/thread.h" #include "mongo/util/exit.h" #include "mongo/util/log.h" @@ -426,7 +425,7 @@ namespace repl { invariant(txn->lockState()->isW()); Lock::TempRelease tempRelease(txn->lockState()); - if (!_connect(&oplogReader, HostAndPort(hostName), + if (!_connect(&oplogReader, HostAndPort(hostName), getGlobalReplicationCoordinator()->getMyRID())) { msgassertedNoTrace( 14051 , "unable to connect to resync"); } @@ -504,12 +503,12 @@ namespace repl { log() << "resync: done with initial clone for db: " << db << endl; } - + static DatabaseIgnorer ___databaseIgnorer; - + void DatabaseIgnorer::doIgnoreUntilAfter( const string &db, const Timestamp &futureOplogTime ) { if ( futureOplogTime > _ignores[ db ] ) { - _ignores[ db ] = futureOplogTime; + _ignores[ db ] = futureOplogTime; } } @@ -533,19 +532,19 @@ namespace repl { // We are already locked at this point if (dbHolder().get(txn, ns) != NULL) { // Database is already present. - return true; + return true; } BSONElement ts = op.getField( "ts" ); if ( ( ts.type() == Date || ts.type() == bsonTimestamp ) && ___databaseIgnorer.ignoreAt( db, ts.timestamp() ) ) { // Database is ignored due to a previous indication that it is // missing from master after optime "ts". - return false; + return false; } if (Database::duplicateUncasedName(db).empty()) { // No duplicate database names are present. return true; } - + Timestamp lastTime; bool dbOk = false; { @@ -556,7 +555,7 @@ namespace repl { // We always log an operation after executing it (never before), so // a database list will always be valid as of an oplog entry generated // before it was retrieved. - + BSONObj last = oplogReader.findOne( this->ns().c_str(), Query().sort( BSON( "$natural" << -1 ) ) ); if ( !last.isEmpty() ) { BSONElement ts = last.getField( "ts" ); @@ -571,34 +570,34 @@ namespace repl { BSONObjIterator i( info.getField( "databases" ).embeddedObject() ); while( i.more() ) { BSONElement e = i.next(); - + const char * name = e.embeddedObject().getField( "name" ).valuestr(); if ( strcasecmp( name, db ) != 0 ) continue; - + if ( strcmp( name, db ) == 0 ) { // The db exists on master, still need to check that no conflicts exist there. dbOk = true; continue; } - + // The master has a db name that conflicts with the requested name. dbOk = false; break; } } - + if ( !dbOk ) { ___databaseIgnorer.doIgnoreUntilAfter( db, lastTime ); incompleteCloneDbs.erase(db); addDbNextPass.erase(db); - return false; + return false; } - + // Check for duplicates again, since we released the lock above. set< string > duplicates; Database::duplicateUncasedName(db, &duplicates); - + // The database is present on the master and no conflicting databases // are present on the master. Drop any local conflicts. for( set< string >::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i ) { @@ -609,7 +608,7 @@ namespace repl { OldClientContext ctx(txn, *i); dropDatabase(txn, ctx.db()); } - + massert(14034, "Duplicate database names present after attempting to delete duplicates", Database::duplicateUncasedName(db).empty()); return true; @@ -745,7 +744,7 @@ namespace repl { } if (!handleDuplicateDbName(txn, op, ns, clientName)) { - return; + return; } // special case apply for commands to avoid implicit database creation @@ -892,7 +891,7 @@ namespace repl { } } } - // obviously global isn't ideal, but non-repl set is old so + // obviously global isn't ideal, but non-repl set is old so // keeping it simple ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); @@ -1021,7 +1020,7 @@ namespace repl { if ( moreInitialSyncsPending || !oplogReader.more() ) { ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lk(txn->lockState()); - + if (tailing) { okResultCode = 0; // don't sleep } @@ -1132,8 +1131,8 @@ namespace repl { return -1; } - if ( !_connect(&oplogReader, - HostAndPort(hostName), + if ( !_connect(&oplogReader, + HostAndPort(hostName), getGlobalReplicationCoordinator()->getMyRID()) ) { LOG(4) << "can't connect to sync source" << endl; return -1; @@ -1364,13 +1363,13 @@ namespace repl { if ( replSettings.slave ) { verify( replSettings.slave == SimpleSlave ); LOG(1) << "slave=true" << endl; - boost::thread repl_thread(replSlaveThread); + stdx::thread repl_thread(replSlaveThread); } if ( replSettings.master ) { LOG(1) << "master=true" << endl; createOplog(txn); - boost::thread t(replMasterThread); + stdx::thread t(replMasterThread); } if (replSettings.fastsync) { |