summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-11-24 15:32:35 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-11-25 11:57:21 -0500
commit4429df3a6c2e03f9b406fe27aa98caa660506d73 (patch)
treecd84af314c50ec3c30a946a0ce299215b6065738 /src/mongo
parent20f830b37613ca1804775d85303074d5c4eb1bd4 (diff)
downloadmongo-4429df3a6c2e03f9b406fe27aa98caa660506d73.tar.gz
SERVER-14062 Add OperationContext to ServerStatusSection
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/clientcursor.cpp4
-rw-r--r--src/mongo/db/commands/server_status.cpp25
-rw-r--r--src/mongo/db/commands/server_status.h6
-rw-r--r--src/mongo/db/repl/repl_info.cpp19
-rw-r--r--src/mongo/db/stats/lock_server_status_section.cpp8
-rw-r--r--src/mongo/db/stats/range_deleter_server_status.cpp5
-rw-r--r--src/mongo/db/storage/mmap_v1/data_file_sync.cpp3
-rw-r--r--src/mongo/db/storage/mmap_v1/data_file_sync.h3
-rw-r--r--src/mongo/db/storage/mmap_v1/dur.cpp8
-rw-r--r--src/mongo/db/storage/storage_init.cpp11
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_server_status.cpp10
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_server_status.h3
-rw-r--r--src/mongo/util/background.cpp9
-rw-r--r--src/mongo/util/tcmalloc_server_status_section.cpp4
14 files changed, 79 insertions, 39 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index 20d8bc82fb3..ec519ecc6d0 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -323,11 +323,13 @@ namespace mongo {
CursorServerStats() : ServerStatusSection( "cursors" ){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
BSONObjBuilder b;
_appendCursorStats( b );
return b.obj();
}
+
} cursorServerStats;
} // namespace mongo
diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp
index d4bce9bed9e..2704ace0b9b 100644
--- a/src/mongo/db/commands/server_status.cpp
+++ b/src/mongo/db/commands/server_status.cpp
@@ -118,7 +118,7 @@ namespace mongo {
if ( ! include )
continue;
- BSONObj data = section->generateSection(e);
+ BSONObj data = section->generateSection(txn, e);
if ( data.isEmpty() )
continue;
@@ -187,7 +187,8 @@ namespace mongo {
: ServerStatusSection( sectionName ), _counters( counters ){
}
- BSONObj OpCounterServerStatusSection::generateSection(const BSONElement& configElement) const {
+ BSONObj OpCounterServerStatusSection::generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
return _counters->getObj();
}
@@ -203,7 +204,9 @@ namespace mongo {
Connections() : ServerStatusSection( "connections" ){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder bb;
bb.append( "current" , Listener::globalTicketHolder.used() );
bb.append( "available" , Listener::globalTicketHolder.available() );
@@ -218,7 +221,9 @@ namespace mongo {
ExtraInfo() : ServerStatusSection( "extra_info" ){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder bb;
bb.append("note", "fields vary by platform");
@@ -227,6 +232,7 @@ namespace mongo {
return bb.obj();
}
+
} extraInfo;
@@ -235,7 +241,9 @@ namespace mongo {
Asserts() : ServerStatusSection( "asserts" ){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder asserts;
asserts.append( "regular" , assertionCount.regular );
asserts.append( "warning" , assertionCount.warning );
@@ -253,7 +261,9 @@ namespace mongo {
Network() : ServerStatusSection( "network" ){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder b;
networkCounter.append( b );
return b.obj();
@@ -267,7 +277,8 @@ namespace mongo {
Security() : ServerStatusSection( "security" ) {}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
BSONObj result;
if (getSSLManager()) {
result = getSSLManager()->getSSLConfiguration().getServerStatusBSON();
diff --git a/src/mongo/db/commands/server_status.h b/src/mongo/db/commands/server_status.h
index adf761cc5a6..695fac9b8e1 100644
--- a/src/mongo/db/commands/server_status.h
+++ b/src/mongo/db/commands/server_status.h
@@ -74,7 +74,8 @@ namespace mongo {
* @param configElement the element from the actual command related to this section
* so if the section is 'foo', this is cmdObj['foo']
*/
- virtual BSONObj generateSection(const BSONElement& configElement) const = 0;
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const = 0;
private:
const std::string _sectionName;
@@ -85,7 +86,8 @@ namespace mongo {
OpCounterServerStatusSection( const std::string& sectionName, OpCounters* counters );
virtual bool includeByDefault() const { return true; }
- virtual BSONObj generateSection(const BSONElement& configElement) const;
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const;
private:
const OpCounters* _counters;
diff --git a/src/mongo/db/repl/repl_info.cpp b/src/mongo/db/repl/repl_info.cpp
index 42d45c95fb5..9e9d27f68ce 100644
--- a/src/mongo/db/repl/repl_info.cpp
+++ b/src/mongo/db/repl/repl_info.cpp
@@ -139,18 +139,21 @@ namespace repl {
ReplicationInfoServerStatus() : ServerStatusSection( "repl" ){}
bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
- if ( ! getGlobalReplicationCoordinator()->isReplEnabled() )
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
+ if (!getGlobalReplicationCoordinator()->isReplEnabled()) {
return BSONObj();
+ }
int level = configElement.numberInt();
BSONObjBuilder result;
+ appendReplicationInfo(txn, result, level);
- OperationContextImpl txn; // XXX?
- appendReplicationInfo(&txn, result, level);
return result.obj();
}
+
} replicationInfoServerStatus;
class OplogInfoServerStatus : public ServerStatusSection {
@@ -158,19 +161,21 @@ namespace repl {
OplogInfoServerStatus() : ServerStatusSection( "oplog" ){}
bool includeByDefault() const { return false; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
if (!replCoord->isReplEnabled()) {
return BSONObj();
}
- OperationContextImpl txn;
BSONObjBuilder result;
result.append("latestOptime", replCoord->getMyLastOptime());
+
BSONObj o;
uassert(17347,
"Problem reading earliest entry from oplog",
- Helpers::getSingleton(&txn, rsoplog, o));
+ Helpers::getSingleton(txn, rsoplog, o));
result.append("earliestOptime", o["ts"]._opTime());
return result.obj();
}
diff --git a/src/mongo/db/stats/lock_server_status_section.cpp b/src/mongo/db/stats/lock_server_status_section.cpp
index 767be89f7fb..322e5322ad9 100644
--- a/src/mongo/db/stats/lock_server_status_section.cpp
+++ b/src/mongo/db/stats/lock_server_status_section.cpp
@@ -77,7 +77,9 @@ namespace mongo {
virtual bool includeByDefault() const { return true; }
- virtual BSONObj generateSection(const BSONElement& configElement) const {
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder t;
t.append("totalTime", (long long)(1000 * (curTimeMillis64() - _started)));
@@ -126,7 +128,9 @@ namespace mongo {
LockStatsServerStatusSection() : ServerStatusSection("locks"){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder b;
// SERVER-14978: Need to report the global and per-DB lock stats here
diff --git a/src/mongo/db/stats/range_deleter_server_status.cpp b/src/mongo/db/stats/range_deleter_server_status.cpp
index 09b830b59aa..408f7049920 100644
--- a/src/mongo/db/stats/range_deleter_server_status.cpp
+++ b/src/mongo/db/stats/range_deleter_server_status.cpp
@@ -56,7 +56,9 @@ namespace mongo {
RangeDeleterServerStatusSection() : ServerStatusSection( "rangeDeleter" ){}
bool includeByDefault() const { return false; }
- BSONObj generateSection(const BSONElement& configElement) const {
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
RangeDeleter* deleter = getDeleter();
if (!deleter) {
return BSONObj();
@@ -93,5 +95,6 @@ namespace mongo {
return result.obj();
}
+
} rangeDeleterServerStatusSection;
}
diff --git a/src/mongo/db/storage/mmap_v1/data_file_sync.cpp b/src/mongo/db/storage/mmap_v1/data_file_sync.cpp
index 653c01bfa3a..f21b79cf1e4 100644
--- a/src/mongo/db/storage/mmap_v1/data_file_sync.cpp
+++ b/src/mongo/db/storage/mmap_v1/data_file_sync.cpp
@@ -93,7 +93,8 @@ namespace mongo {
}
}
- BSONObj DataFileSync::generateSection(const BSONElement& configElement) const {
+ BSONObj DataFileSync::generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
BSONObjBuilder b;
b.appendNumber( "flushes" , _flushes );
b.appendNumber( "total_ms" , _total_time );
diff --git a/src/mongo/db/storage/mmap_v1/data_file_sync.h b/src/mongo/db/storage/mmap_v1/data_file_sync.h
index 63cb9cb62ba..07341a8bb92 100644
--- a/src/mongo/db/storage/mmap_v1/data_file_sync.h
+++ b/src/mongo/db/storage/mmap_v1/data_file_sync.h
@@ -45,7 +45,8 @@ namespace mongo {
void run();
- virtual BSONObj generateSection(const BSONElement& configElement) const;
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const;
private:
void _flushed(int ms);
diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp
index c758cd88d99..98921e77b21 100644
--- a/src/mongo/db/storage/mmap_v1/dur.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur.cpp
@@ -725,9 +725,13 @@ namespace mongo {
DurSSS() : ServerStatusSection( "dur" ){}
virtual bool includeByDefault() const { return true; }
- BSONObj generateSection(const BSONElement& configElement) const {
- if (!storageGlobalParams.dur)
+ BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
+ if (!storageGlobalParams.dur) {
return BSONObj();
+ }
+
return dur::stats.asObj();
}
diff --git a/src/mongo/db/storage/storage_init.cpp b/src/mongo/db/storage/storage_init.cpp
index 08ed2d69716..4e46afd5a84 100644
--- a/src/mongo/db/storage/storage_init.cpp
+++ b/src/mongo/db/storage/storage_init.cpp
@@ -33,8 +33,8 @@
namespace mongo {
- // TODO: Does this belong here?
- namespace {
+// TODO: Does this belong here?
+namespace {
class StorageSSS : public ServerStatusSection {
public:
@@ -45,12 +45,13 @@ namespace mongo {
virtual bool includeByDefault() const { return true; }
- virtual BSONObj generateSection(const BSONElement& configElement) const {
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
return BSON( "name" << storageGlobalParams.engine );
}
} storageSSS;
- } // namespace
-
+} // namespace
} // namespace mongo
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.cpp
index eb388d236f3..79ebf9d3169 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.cpp
@@ -57,11 +57,13 @@ namespace mongo {
}
BSONObj WiredTigerServerStatusSection::generateSection(
- const BSONElement& configElement) const {
+ OperationContext* txn,
+ const BSONElement& configElement) const {
+
+ WiredTigerSession* session =
+ dynamic_cast<WiredTigerRecoveryUnit*>(txn->recoveryUnit())->getSession();
+ invariant(session);
- boost::scoped_ptr<WiredTigerRecoveryUnit> recoveryUnit(
- dynamic_cast<WiredTigerRecoveryUnit*>(_engine->newRecoveryUnit()));
- WiredTigerSession* session = recoveryUnit->getSession();
WT_SESSION* s = session->getSession();
invariant(s);
const string uri = "statistics:";
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.h b/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.h
index 720087db7e9..21f9871a82a 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_server_status.h
@@ -43,7 +43,8 @@ namespace mongo {
public:
WiredTigerServerStatusSection(WiredTigerKVEngine* engine);
virtual bool includeByDefault() const;
- virtual BSONObj generateSection(const BSONElement& configElement) const;
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const;
private:
WiredTigerKVEngine* _engine;
};
diff --git a/src/mongo/util/background.cpp b/src/mongo/util/background.cpp
index 1022c1e85be..090b665ddd4 100644
--- a/src/mongo/util/background.cpp
+++ b/src/mongo/util/background.cpp
@@ -153,17 +153,18 @@ namespace mongo {
void BackgroundJob::jobBody() {
const string threadName = name();
- if( ! threadName.empty() )
- setThreadName( threadName.c_str() );
+ if (!threadName.empty()) {
+ setThreadName(threadName.c_str());
+ }
LOG(1) << "BackgroundJob starting: " << threadName << endl;
try {
run();
}
- catch ( std::exception& e ) {
+ catch (const std::exception& e) {
error() << "backgroundjob " << threadName << " exception: " << e.what();
- throw e;
+ throw;
}
// We must cache this value so that we can use it after we leave the following scope.
diff --git a/src/mongo/util/tcmalloc_server_status_section.cpp b/src/mongo/util/tcmalloc_server_status_section.cpp
index b7b2719696e..2cb6a375b8e 100644
--- a/src/mongo/util/tcmalloc_server_status_section.cpp
+++ b/src/mongo/util/tcmalloc_server_status_section.cpp
@@ -39,7 +39,9 @@ namespace {
TCMallocServerStatusSection() : ServerStatusSection("tcmalloc") {}
virtual bool includeByDefault() const { return false; }
- virtual BSONObj generateSection(const BSONElement& configElement) const {
+ virtual BSONObj generateSection(OperationContext* txn,
+ const BSONElement& configElement) const {
+
BSONObjBuilder builder;
// For a list of properties see the "Generic Tcmalloc Status" section of