summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/base_cloner.h5
-rw-r--r--src/mongo/db/repl/base_cloner_test_fixture.cpp7
-rw-r--r--src/mongo/db/repl/collection_cloner.cpp15
-rw-r--r--src/mongo/db/repl/collection_cloner.h2
-rw-r--r--src/mongo/db/repl/database_cloner.cpp18
-rw-r--r--src/mongo/db/repl/database_cloner.h4
-rw-r--r--src/mongo/db/repl/multiapplier.cpp15
-rw-r--r--src/mongo/db/repl/multiapplier.h10
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp3
-rw-r--r--src/mongo/db/repl/replication_coordinator.h11
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state.h1
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h4
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.h4
-rw-r--r--src/mongo/db/repl/replication_executor.cpp82
-rw-r--r--src/mongo/db/repl/replication_executor.h7
-rw-r--r--src/mongo/db/s/sharding_task_executor.cpp4
-rw-r--r--src/mongo/db/s/sharding_task_executor.h2
18 files changed, 56 insertions, 143 deletions
diff --git a/src/mongo/db/repl/base_cloner.h b/src/mongo/db/repl/base_cloner.h
index 23218b09785..d73def7e5dc 100644
--- a/src/mongo/db/repl/base_cloner.h
+++ b/src/mongo/db/repl/base_cloner.h
@@ -49,11 +49,6 @@ public:
virtual ~BaseCloner() {}
/**
- * Returns diagnostic information.
- */
- virtual std::string getDiagnosticString() const = 0;
-
- /**
* Returns true if the cloner has been started (but has not completed).
*/
virtual bool isActive() const = 0;
diff --git a/src/mongo/db/repl/base_cloner_test_fixture.cpp b/src/mongo/db/repl/base_cloner_test_fixture.cpp
index 58eca351ca7..ebaa135090f 100644
--- a/src/mongo/db/repl/base_cloner_test_fixture.cpp
+++ b/src/mongo/db/repl/base_cloner_test_fixture.cpp
@@ -157,8 +157,10 @@ void BaseClonerTest::scheduleNetworkResponse(NetworkOperationIterator noi,
void BaseClonerTest::scheduleNetworkResponse(const BSONObj& obj) {
if (!getNet()->hasReadyRequests()) {
+ BSONObjBuilder b;
+ getExecutor().appendDiagnosticBSON(&b);
log() << "Expected network request for resp: " << obj;
- log() << " replExec: " << getExecutor().getDiagnosticString();
+ log() << " replExec: " << b.done();
log() << " net:" << getNet()->getDiagnosticString();
}
if (getStatus() != getDetectableErrorStatus()) {
@@ -190,9 +192,6 @@ void BaseClonerTest::finishProcessingNetworkResponse() {
}
void BaseClonerTest::testLifeCycle() {
- // GetDiagnosticString
- ASSERT_FALSE(getCloner()->getDiagnosticString().empty());
-
// IsActiveAfterStart
ASSERT_FALSE(getCloner()->isActive());
ASSERT_OK(getCloner()->startup());
diff --git a/src/mongo/db/repl/collection_cloner.cpp b/src/mongo/db/repl/collection_cloner.cpp
index c89709f2fe8..72fc777ff08 100644
--- a/src/mongo/db/repl/collection_cloner.cpp
+++ b/src/mongo/db/repl/collection_cloner.cpp
@@ -154,21 +154,6 @@ const NamespaceString& CollectionCloner::getSourceNamespace() const {
return _sourceNss;
}
-std::string CollectionCloner::getDiagnosticString() const {
- LockGuard lk(_mutex);
- str::stream output;
- output << "CollectionCloner";
- output << " executor: " << _executor->getDiagnosticString();
- output << " source: " << _source.toString();
- output << " source namespace: " << _sourceNss.toString();
- output << " destination namespace: " << _destNss.toString();
- output << " collection options: " << _options.toBSON();
- output << " active: " << _isActive_inlock();
- output << " listIndexes fetcher: " << _listIndexesFetcher.getDiagnosticString();
- output << " find fetcher: " << (_findFetcher ? _findFetcher->getDiagnosticString() : "");
- return output;
-}
-
bool CollectionCloner::isActive() const {
LockGuard lk(_mutex);
return _isActive_inlock();
diff --git a/src/mongo/db/repl/collection_cloner.h b/src/mongo/db/repl/collection_cloner.h
index 1c65161fd97..9f08215a078 100644
--- a/src/mongo/db/repl/collection_cloner.h
+++ b/src/mongo/db/repl/collection_cloner.h
@@ -114,8 +114,6 @@ public:
const NamespaceString& getSourceNamespace() const;
- std::string getDiagnosticString() const override;
-
bool isActive() const override;
Status startup() noexcept override;
diff --git a/src/mongo/db/repl/database_cloner.cpp b/src/mongo/db/repl/database_cloner.cpp
index fe892ba157f..649d6d8efa3 100644
--- a/src/mongo/db/repl/database_cloner.cpp
+++ b/src/mongo/db/repl/database_cloner.cpp
@@ -142,24 +142,6 @@ const std::vector<BSONObj>& DatabaseCloner::getCollectionInfos_forTest() const {
return _collectionInfos;
}
-std::string DatabaseCloner::getDiagnosticString() const {
- LockGuard lk(_mutex);
- return _getDiagnosticString_inlock();
-}
-
-std::string DatabaseCloner::_getDiagnosticString_inlock() const {
- str::stream output;
- output << "DatabaseCloner";
- output << " executor: " << _executor->getDiagnosticString();
- output << " source: " << _source.toString();
- output << " database: " << _dbname;
- output << " listCollections filter" << _listCollectionsFilter;
- output << " active: " << _isActive_inlock();
- output << " collection info objects (empty if listCollections is in progress): "
- << _collectionInfos.size();
- return output;
-}
-
bool DatabaseCloner::isActive() const {
LockGuard lk(_mutex);
return _isActive_inlock();
diff --git a/src/mongo/db/repl/database_cloner.h b/src/mongo/db/repl/database_cloner.h
index 97a4c0cbc4c..73006606586 100644
--- a/src/mongo/db/repl/database_cloner.h
+++ b/src/mongo/db/repl/database_cloner.h
@@ -130,8 +130,6 @@ public:
*/
const std::vector<BSONObj>& getCollectionInfos_forTest() const;
- std::string getDiagnosticString() const override;
-
bool isActive() const override;
Status startup() noexcept override;
@@ -203,8 +201,6 @@ private:
*/
void _finishCallback_inlock(UniqueLock& lk, const Status& status);
- std::string _getDiagnosticString_inlock() const;
-
//
// All member variables are labeled with one of the following codes indicating the
// synchronization rules for accessing them.
diff --git a/src/mongo/db/repl/multiapplier.cpp b/src/mongo/db/repl/multiapplier.cpp
index ac78a4f2c8c..32efe2c68a7 100644
--- a/src/mongo/db/repl/multiapplier.cpp
+++ b/src/mongo/db/repl/multiapplier.cpp
@@ -67,21 +67,6 @@ MultiApplier::~MultiApplier() {
DESTRUCTOR_GUARD(shutdown(); join(););
}
-std::string MultiApplier::toString() const {
- return getDiagnosticString();
-}
-
-std::string MultiApplier::getDiagnosticString() const {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
- str::stream output;
- output << "MultiApplier";
- output << " active: " << _isActive_inlock();
- output << ", ops: " << _operations.front().ts.timestamp().toString();
- output << " - " << _operations.back().ts.timestamp().toString();
- output << ", executor: " << _executor->getDiagnosticString();
- return output;
-}
-
bool MultiApplier::isActive() const {
stdx::lock_guard<stdx::mutex> lk(_mutex);
return _isActive_inlock();
diff --git a/src/mongo/db/repl/multiapplier.h b/src/mongo/db/repl/multiapplier.h
index 37f094b0324..97567fde6cc 100644
--- a/src/mongo/db/repl/multiapplier.h
+++ b/src/mongo/db/repl/multiapplier.h
@@ -101,16 +101,6 @@ public:
virtual ~MultiApplier();
/**
- * Returns diagnostic information.
- */
- std::string getDiagnosticString() const;
-
- /**
- * Returns an informational string.
- */
- std::string toString() const;
-
- /**
* Returns true if the applier has been started (but has not completed).
*/
bool isActive() const;
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index 2f3b46bcfc0..2429351c364 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -76,8 +76,7 @@ class ReplExecutorSSM : public ServerStatusMetric {
public:
ReplExecutorSSM() : ServerStatusMetric("repl.executor") {}
virtual void appendAtLeaf(BSONObjBuilder& b) const {
- ReplicationExecutor* exec = getGlobalReplicationCoordinator()->getExecutor();
- b.append("executor", exec->getDiagnosticBSON());
+ getGlobalReplicationCoordinator()->appendDiagnosticBSON(&b);
}
} replExecutorSSM;
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index d5557213bb4..8446e718d30 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -73,7 +73,6 @@ class OplogReader;
class OpTime;
class ReadConcernArgs;
class ReplSetConfig;
-class ReplicationExecutor;
class ReplSetHeartbeatArgs;
class ReplSetHeartbeatArgsV1;
class ReplSetHeartbeatResponse;
@@ -133,11 +132,6 @@ public:
virtual void shutdown(OperationContext* opCtx) = 0;
/**
- * Returns a pointer to the ReplicationExecutor.
- */
- virtual ReplicationExecutor* getExecutor() = 0;
-
- /**
* Returns a reference to the parsed command line arguments that are related to replication.
*/
virtual const ReplSettings& getSettings() const = 0;
@@ -857,6 +851,11 @@ public:
virtual OpTime getCurrentCommittedSnapshotOpTime() const = 0;
/**
+ * Appends diagnostics about the replication subsystem.
+ */
+ virtual void appendDiagnosticBSON(BSONObjBuilder* bob) = 0;
+
+ /**
* Appends connection information to the provided BSONObjBuilder.
*/
virtual void appendConnectionStats(executor::ConnectionPoolStats* stats) const = 0;
diff --git a/src/mongo/db/repl/replication_coordinator_external_state.h b/src/mongo/db/repl/replication_coordinator_external_state.h
index 4ef66c3dc15..2724cde6e66 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state.h
@@ -58,7 +58,6 @@ namespace repl {
class LastVote;
class ReplSettings;
class ReplicationCoordinator;
-class ReplicationExecutor;
/**
* This class represents the interface the ReplicationCoordinator uses to interact with the
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 20a4f921310..abc0844d4fb 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -410,6 +410,11 @@ LogicalTime ReplicationCoordinatorImpl::_getCurrentCommittedLogicalTime_inlock()
return LogicalTime(_getCurrentCommittedSnapshotOpTime_inlock().getTimestamp());
}
+void ReplicationCoordinatorImpl::appendDiagnosticBSON(mongo::BSONObjBuilder* bob) {
+ BSONObjBuilder eBuilder(bob->subobjStart("executor"));
+ _replExecutor.appendDiagnosticBSON(&eBuilder);
+}
+
void ReplicationCoordinatorImpl::appendConnectionStats(executor::ConnectionPoolStats* stats) const {
_replExecutor.appendConnectionStats(stats);
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index 1fdff0ca777..84b1fce4a6b 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -105,10 +105,12 @@ public:
virtual void shutdown(OperationContext* opCtx) override;
- virtual ReplicationExecutor* getExecutor() override {
+ ReplicationExecutor* getExecutor() {
return &_replExecutor;
}
+ virtual void appendDiagnosticBSON(BSONObjBuilder* bob) override;
+
virtual const ReplSettings& getSettings() const override;
virtual Mode getReplicationMode() const override;
diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h
index 0e9109b1665..fdfa491f0ad 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_mock.h
@@ -57,9 +57,7 @@ public:
virtual void shutdown(OperationContext* opCtx);
- virtual ReplicationExecutor* getExecutor() override {
- return nullptr;
- };
+ virtual void appendDiagnosticBSON(BSONObjBuilder* bob) override {}
virtual const ReplSettings& getSettings() const;
diff --git a/src/mongo/db/repl/replication_executor.cpp b/src/mongo/db/repl/replication_executor.cpp
index 3f9f0c5836b..8dc65f6d7e3 100644
--- a/src/mongo/db/repl/replication_executor.cpp
+++ b/src/mongo/db/repl/replication_executor.cpp
@@ -71,59 +71,45 @@ ReplicationExecutor::~ReplicationExecutor() {
}
BSONObj ReplicationExecutor::getDiagnosticBSON() const {
+ BSONObjBuilder b;
+ appendDiagnosticBSON(&b);
+ return b.obj();
+}
+
+void ReplicationExecutor::appendDiagnosticBSON(BSONObjBuilder* builder) const {
stdx::lock_guard<stdx::mutex> lk(_mutex);
- BSONObjBuilder builder;
// Counters
- BSONObjBuilder counters(builder.subobjStart("counters"));
- counters.appendIntOrLL("eventCreated", _counterCreatedEvents);
- counters.appendIntOrLL("eventWait", _counterCreatedEvents);
- counters.appendIntOrLL("cancels", _counterCancels);
- counters.appendIntOrLL("waits", _counterWaits);
- counters.appendIntOrLL("scheduledNetCmd", _counterScheduledCommands);
- counters.appendIntOrLL("scheduledDBWork", _counterScheduledDBWorks);
- counters.appendIntOrLL("scheduledXclWork", _counterScheduledExclusiveWorks);
- counters.appendIntOrLL("scheduledWorkAt", _counterScheduledWorkAts);
- counters.appendIntOrLL("scheduledWork", _counterScheduledWorks);
- counters.appendIntOrLL("schedulingFailures", _counterSchedulingFailures);
- counters.done();
+ {
+ BSONObjBuilder counters(builder->subobjStart("counters"));
+ counters.appendIntOrLL("eventCreated", _counterCreatedEvents);
+ counters.appendIntOrLL("eventWait", _counterCreatedEvents);
+ counters.appendIntOrLL("cancels", _counterCancels);
+ counters.appendIntOrLL("waits", _counterWaits);
+ counters.appendIntOrLL("scheduledNetCmd", _counterScheduledCommands);
+ counters.appendIntOrLL("scheduledDBWork", _counterScheduledDBWorks);
+ counters.appendIntOrLL("scheduledXclWork", _counterScheduledExclusiveWorks);
+ counters.appendIntOrLL("scheduledWorkAt", _counterScheduledWorkAts);
+ counters.appendIntOrLL("scheduledWork", _counterScheduledWorks);
+ counters.appendIntOrLL("schedulingFailures", _counterSchedulingFailures);
+ }
// Queues
- BSONObjBuilder queues(builder.subobjStart("queues"));
- queues.appendIntOrLL("networkInProgress", _networkInProgressQueue.size());
- queues.appendIntOrLL("dbWorkInProgress", _dbWorkInProgressQueue.size());
- queues.appendIntOrLL("exclusiveInProgress", _exclusiveLockInProgressQueue.size());
- queues.appendIntOrLL("sleepers", _sleepersQueue.size());
- queues.appendIntOrLL("ready", _readyQueue.size());
- queues.appendIntOrLL("free", _freeQueue.size());
- queues.done();
-
- builder.appendIntOrLL("unsignaledEvents", _unsignaledEvents.size());
- builder.appendIntOrLL("eventWaiters", _totalEventWaiters);
- builder.append("shuttingDown", _inShutdown);
- builder.append("networkInterface", _networkInterface->getDiagnosticString());
- return builder.obj();
-}
-
-std::string ReplicationExecutor::getDiagnosticString() const {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
- return _getDiagnosticString_inlock();
-}
-
-std::string ReplicationExecutor::_getDiagnosticString_inlock() const {
- str::stream output;
- output << "ReplicationExecutor";
- output << " networkInProgress:" << _networkInProgressQueue.size();
- output << " dbWorkInProgress:" << _dbWorkInProgressQueue.size();
- output << " exclusiveInProgress:" << _exclusiveLockInProgressQueue.size();
- output << " sleeperQueue:" << _sleepersQueue.size();
- output << " ready:" << _readyQueue.size();
- output << " free:" << _freeQueue.size();
- output << " unsignaledEvents:" << _unsignaledEvents.size();
- output << " eventWaiters:" << _totalEventWaiters;
- output << " shuttingDown:" << _inShutdown;
- output << " networkInterface:" << _networkInterface->getDiagnosticString();
- return output;
+ {
+ BSONObjBuilder queues(builder->subobjStart("queues"));
+ queues.appendIntOrLL("networkInProgress", _networkInProgressQueue.size());
+ queues.appendIntOrLL("dbWorkInProgress", _dbWorkInProgressQueue.size());
+ queues.appendIntOrLL("exclusiveInProgress", _exclusiveLockInProgressQueue.size());
+ queues.appendIntOrLL("sleepers", _sleepersQueue.size());
+ queues.appendIntOrLL("ready", _readyQueue.size());
+ queues.appendIntOrLL("free", _freeQueue.size());
+ queues.done();
+ }
+
+ builder->appendIntOrLL("unsignaledEvents", _unsignaledEvents.size());
+ builder->appendIntOrLL("eventWaiters", _totalEventWaiters);
+ builder->append("shuttingDown", _inShutdown);
+ builder->append("networkInterface", _networkInterface->getDiagnosticString());
}
Date_t ReplicationExecutor::now() {
diff --git a/src/mongo/db/repl/replication_executor.h b/src/mongo/db/repl/replication_executor.h
index c5e20a8ac68..3205b816776 100644
--- a/src/mongo/db/repl/replication_executor.h
+++ b/src/mongo/db/repl/replication_executor.h
@@ -105,8 +105,8 @@ public:
*/
virtual ~ReplicationExecutor();
- std::string getDiagnosticString() const override;
BSONObj getDiagnosticBSON() const;
+ void appendDiagnosticBSON(BSONObjBuilder* b) const override;
Date_t now() override;
void startup() override;
void shutdown() override;
@@ -226,11 +226,6 @@ private:
typedef stdx::list<EventHandle> EventList;
/**
- * Returns diagnostic info
- */
- std::string _getDiagnosticString_inlock() const;
-
- /**
* Implementation of makeEvent() for use when _mutex is already held.
*/
StatusWith<EventHandle> makeEvent_inlock();
diff --git a/src/mongo/db/s/sharding_task_executor.cpp b/src/mongo/db/s/sharding_task_executor.cpp
index 83cfc8cb833..17f5b5fd861 100644
--- a/src/mongo/db/s/sharding_task_executor.cpp
+++ b/src/mongo/db/s/sharding_task_executor.cpp
@@ -64,8 +64,8 @@ void ShardingTaskExecutor::join() {
_executor->join();
}
-std::string ShardingTaskExecutor::getDiagnosticString() const {
- return _executor->getDiagnosticString();
+void ShardingTaskExecutor::appendDiagnosticBSON(mongo::BSONObjBuilder* builder) const {
+ _executor->appendDiagnosticBSON(builder);
}
Date_t ShardingTaskExecutor::now() {
diff --git a/src/mongo/db/s/sharding_task_executor.h b/src/mongo/db/s/sharding_task_executor.h
index 7828b56dd94..efd4bff1de2 100644
--- a/src/mongo/db/s/sharding_task_executor.h
+++ b/src/mongo/db/s/sharding_task_executor.h
@@ -56,7 +56,7 @@ public:
void startup() override;
void shutdown() override;
void join() override;
- std::string getDiagnosticString() const override;
+ void appendDiagnosticBSON(BSONObjBuilder* builder) const override;
Date_t now() override;
StatusWith<EventHandle> makeEvent() override;
void signalEvent(const EventHandle& event) override;