diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2015-05-21 13:58:59 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2015-05-22 16:50:00 -0400 |
commit | d6e686859c6187df791b7f61abbb9839f7e85c9a (patch) | |
tree | 16d1d4572d9d951683a75256ec89ec95bfebf7b6 | |
parent | 765616c3dee87c963d57f8f80d68b4b06ef5f679 (diff) | |
download | mongo-d6e686859c6187df791b7f61abbb9839f7e85c9a.tar.gz |
SERVER-18277/SERVER-18482 Remove "_remote" field from CurOp.
-rw-r--r-- | src/mongo/db/client.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/clientlistplugin.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/batch_executor.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/curop.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/curop.h | 12 | ||||
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/index_builder.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/instance.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/querytests.cpp | 3 |
9 files changed, 21 insertions, 28 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp index f323bcfe02c..4b220a308dd 100644 --- a/src/mongo/db/client.cpp +++ b/src/mongo/db/client.cpp @@ -108,6 +108,10 @@ namespace mongo { if (_connectionId) { builder.appendNumber("connectionId", _connectionId); } + + if (hasRemote()) { + builder.append("client", getRemote().toString()); + } } void Client::setOperationContext(OperationContext* txn) { diff --git a/src/mongo/db/clientlistplugin.cpp b/src/mongo/db/clientlistplugin.cpp index 3cef57b041c..9bd2ca06f3f 100644 --- a/src/mongo/db/clientlistplugin.cpp +++ b/src/mongo/db/clientlistplugin.cpp @@ -132,7 +132,7 @@ namespace { tablecell(ss, ""); } - tablecell(ss, curOp->getRemoteString()); + tablecell(ss, client->clientAddress(true /*includePort*/)); tablecell(ss, curOp->getMessage()); tablecell(ss, curOp->getProgressMeter().toString()); diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index ce52fa66ab4..c698c352e50 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -503,7 +503,6 @@ namespace mongo { client->hasRemote() ? client->getRemote() : HostAndPort( "0.0.0.0", 0 ); // TODO Modify CurOp "wrapped" constructor to take an opcode, so calling .reset() // is unneeded - currentOp->reset( remote, getOpCode( currWrite.getRequest()->getBatchType() ) ); currentOp->ensureStarted(); currentOp->setNS( currWrite.getRequest()->getNS() ); @@ -897,7 +896,7 @@ namespace mongo { WriteErrorDetail** error ) { // BEGIN CURRENT OP - CurOp currentOp(_txn->getClient()); + CurOp currentOp(_txn->getClient(), dbUpdate); beginCurrentOp( ¤tOp, _txn->getClient(), updateItem ); incOpStats( updateItem ); @@ -941,7 +940,7 @@ namespace mongo { // Removes are similar to updates, but page faults are handled externally // BEGIN CURRENT OP - CurOp currentOp(_txn->getClient()); + CurOp currentOp(_txn->getClient(), dbDelete); beginCurrentOp( ¤tOp, _txn->getClient(), removeItem ); incOpStats( removeItem ); @@ -1136,7 +1135,7 @@ namespace mongo { void WriteBatchExecutor::execOneInsert(ExecInsertsState* state, WriteErrorDetail** error) { BatchItemRef currInsertItem(state->request, state->currIndex); - CurOp currentOp(_txn->getClient()); + CurOp currentOp(_txn->getClient(), dbInsert); beginCurrentOp( ¤tOp, _txn->getClient(), currInsertItem ); incOpStats(currInsertItem); diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index b1bed4a5949..57b3d780d11 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -171,6 +171,11 @@ namespace mongo { _command = NULL; } + CurOp::CurOp(Client* client, int op) : CurOp(client, &_curopStack(client)) { + _op = op; + _active = true; + } + void CurOp::_reset() { _isCommand = false; _dbprofile = 0; @@ -194,12 +199,8 @@ namespace mongo { _active = true; // this should be last for ui clarity } - void CurOp::reset( const HostAndPort& remote, int op ) { + void CurOp::reset(int op) { reset(); - if( _remote != remote ) { - // todo : _remote is not thread safe yet is used as such! - _remote = remote; - } _op = op; } @@ -283,10 +284,6 @@ namespace mongo { builder->append( "planSummary" , debug().planSummary.toString() ); } - if( !_remote.empty() ) { - builder->append("client", _remote.toString()); - } - if ( ! _message.empty() ) { if ( _progressMeter.isActive() ) { StringBuilder buf; diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 80beedf3ab2..b3f96d66d3a 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -202,15 +202,16 @@ namespace mongo { static CurOp* get(const OperationContext& opCtx); explicit CurOp(Client* client); + CurOp(Client* client, int op); ~CurOp(); bool haveQuery() const { return _query.have(); } BSONObj query() const { return _query.get(); } void appendQuery( BSONObjBuilder& b , StringData name ) const { _query.append( b , name ); } - + void enter(const char* ns, int dbProfileLevel); void reset(); - void reset( const HostAndPort& remote, int op ); + void reset(int op); void markCommand() { _isCommand = true; } OpDebug& debug() { return _debug; } std::string getNS() const { return _ns.toString(); } @@ -297,12 +298,6 @@ namespace mongo { void reportState(BSONObjBuilder* builder); - std::string getRemoteString( bool includePort = true ) { - if (includePort) - return _remote.toString(); - return _remote.host(); - } - ProgressMeter& setMessage(const char * msg, std::string name = "Progress", unsigned long long progressMeterTotal = 0, @@ -349,7 +344,6 @@ namespace mongo { int _dbprofile; // 0=off, 1=slow, 2=all unsigned int _opNum; ThreadSafeString _ns; - HostAndPort _remote; // CAREFUL here with thread safety CachedBSONObj<512> _query; // CachedBSONObj is thread safe OpDebug _debug; ThreadSafeString _message; diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index a93740dab89..371fbafe180 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -1082,7 +1082,7 @@ namespace mongo { int, string& errmsg, BSONObjBuilder& result) { - result << "you" << CurOp::get(txn)->getRemoteString(); + result << "you" << txn->getClient()->clientAddress(true /*includePort*/); return true; } } cmdWhatsMyUri; diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp index 1467d8c71a7..7baf390792d 100644 --- a/src/mongo/db/index_builder.cpp +++ b/src/mongo/db/index_builder.cpp @@ -87,7 +87,7 @@ namespace { AuthorizationSession::get(txn.getClient())->grantInternalAuthorization(); - CurOp::get(txn)->reset(HostAndPort(), dbInsert); + CurOp::get(txn)->reset(dbInsert); NamespaceString ns(_index["ns"].String()); ScopedTransaction transaction(&txn, MODE_IX); diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 4f89cf4e7ca..f5399564d6e 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -522,7 +522,7 @@ namespace { } CurOp& currentOp = *CurOp::get(txn); - currentOp.reset(remote,op); + currentOp.reset(op); OpDebug& debug = currentOp.debug(); debug.op = op; diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index 64381281ec9..5926472b7e6 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -1463,8 +1463,7 @@ namespace QueryTests { void run() { BSONObj result; _client.runCommand( "admin", BSON( "whatsmyuri" << 1 ), result ); - SockAddr unknownAddress("0.0.0.0", 0); - ASSERT_EQUALS( unknownAddress.toString(), result[ "you" ].str() ); + ASSERT_EQUALS("", result[ "you" ].str()); } }; |