diff options
author | Andy Schwerin <Andy Schwerin schwerin@mongodb.com> | 2017-04-05 16:56:55 -0400 |
---|---|---|
committer | Andy Schwerin <Andy Schwerin schwerin@mongodb.com> | 2017-04-06 18:25:12 -0400 |
commit | b8a07e36c6a893c57b6728acca8111993f0c7067 (patch) | |
tree | 74bca1073ed5140348dc79ebb8aae6ba9637c63c /src/mongo/executor | |
parent | 1e28d93c599dcc963eb53986c2e8fb2bc4f8935c (diff) | |
download | mongo-b8a07e36c6a893c57b6728acca8111993f0c7067.tar.gz |
SERVER-28624 Further reduce dependency on ReplicationExecutor type.
* Replace getDiagnosticString() with appendDiagnosticBSON() in TaskExecutors.
* Introduce appendDiagnostics to ReplicationCoordinator, to hide the implementation
detail that ReplicationCoordinatorImpl has a TaskExecutor.
Diffstat (limited to 'src/mongo/executor')
-rw-r--r-- | src/mongo/executor/task_executor.h | 4 | ||||
-rw-r--r-- | src/mongo/executor/thread_pool_task_executor.cpp | 21 | ||||
-rw-r--r-- | src/mongo/executor/thread_pool_task_executor.h | 7 |
3 files changed, 12 insertions, 20 deletions
diff --git a/src/mongo/executor/task_executor.h b/src/mongo/executor/task_executor.h index a17b6482451..04f911da5dc 100644 --- a/src/mongo/executor/task_executor.h +++ b/src/mongo/executor/task_executor.h @@ -134,9 +134,9 @@ public: virtual void join() = 0; /** - * Returns diagnostic information. + * Writes diagnostic information into "b". */ - virtual std::string getDiagnosticString() const = 0; + virtual void appendDiagnosticBSON(BSONObjBuilder* b) const = 0; /** * Gets the current time. Callbacks should use this method to read the system clock. diff --git a/src/mongo/executor/thread_pool_task_executor.cpp b/src/mongo/executor/thread_pool_task_executor.cpp index fcb27cd5c29..7d111ae6f95 100644 --- a/src/mongo/executor/thread_pool_task_executor.cpp +++ b/src/mongo/executor/thread_pool_task_executor.cpp @@ -188,30 +188,24 @@ void ThreadPoolTaskExecutor::join() { invariant(_unsignaledEvents.empty()); } -BSONObj ThreadPoolTaskExecutor::_getDiagnosticBSON() const { +void ThreadPoolTaskExecutor::appendDiagnosticBSON(BSONObjBuilder* b) const { stdx::lock_guard<stdx::mutex> lk(_mutex); - BSONObjBuilder builder; // ThreadPool details // TODO: fill in - BSONObjBuilder poolCounters(builder.subobjStart("pool")); + BSONObjBuilder poolCounters(b->subobjStart("pool")); poolCounters.appendIntOrLL("inProgressCount", _poolInProgressQueue.size()); poolCounters.done(); // Queues - BSONObjBuilder queues(builder.subobjStart("queues")); + BSONObjBuilder queues(b->subobjStart("queues")); queues.appendIntOrLL("networkInProgress", _networkInProgressQueue.size()); queues.appendIntOrLL("sleepers", _sleepersQueue.size()); queues.done(); - builder.appendIntOrLL("unsignaledEvents", _unsignaledEvents.size()); - builder.append("shuttingDown", _inShutdown); - builder.append("networkInterface", _net->getDiagnosticString()); - return builder.obj(); -} - -std::string ThreadPoolTaskExecutor::getDiagnosticString() const { - return _getDiagnosticBSON().toString(); + b->appendIntOrLL("unsignaledEvents", _unsignaledEvents.size()); + b->append("shuttingDown", _inShutdown); + b->append("networkInterface", _net->getDiagnosticString()); } Date_t ThreadPoolTaskExecutor::now() { @@ -376,6 +370,9 @@ void ThreadPoolTaskExecutor::cancel(const CallbackHandle& cbHandle) { invariant(cbHandle.isValid()); auto cbState = checked_cast<CallbackState*>(getCallbackFromHandle(cbHandle)); stdx::unique_lock<stdx::mutex> lk(_mutex); + if (_inShutdown) { + return; + } cbState->canceled.store(1); if (cbState->isNetworkOperation) { lk.unlock(); diff --git a/src/mongo/executor/thread_pool_task_executor.h b/src/mongo/executor/thread_pool_task_executor.h index 98298624b80..9d6a6d940b9 100644 --- a/src/mongo/executor/thread_pool_task_executor.h +++ b/src/mongo/executor/thread_pool_task_executor.h @@ -68,7 +68,7 @@ public: void startup() override; void shutdown() override; void join() override; - std::string getDiagnosticString() const override; + void appendDiagnosticBSON(BSONObjBuilder* b) const; Date_t now() override; StatusWith<EventHandle> makeEvent() override; void signalEvent(const EventHandle& event) override; @@ -147,11 +147,6 @@ private: */ void runCallback(std::shared_ptr<CallbackState> cbState); - /** - * Returns bson for diagnostics - */ - BSONObj _getDiagnosticBSON() const; - // The network interface used for remote command execution and waiting. std::unique_ptr<NetworkInterface> _net; |