diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-08-26 17:58:00 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2014-08-27 10:49:14 -0400 |
commit | c069fc13a91204940c82a90f7c2c2f09b80c3428 (patch) | |
tree | 9092ff3c0695c2c7cedb309f334951b3f97d7930 /src/mongo | |
parent | 32643343be6e0100a887dae4a44d33f710dfd086 (diff) | |
download | mongo-c069fc13a91204940c82a90f7c2c2f09b80c3428.tar.gz |
SERVER-14668 Remove d_globals.h/.cpp
They were only used for ClientCursorMonitor startup, so I moved this to be
a singleton task.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/clientcursor.cpp | 41 | ||||
-rw-r--r-- | src/mongo/db/clientcursor.h | 7 | ||||
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/d_globals.cpp | 47 | ||||
-rw-r--r-- | src/mongo/db/d_globals.h | 53 | ||||
-rw-r--r-- | src/mongo/db/db.cpp | 4 |
7 files changed, 30 insertions, 124 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript index e19a521e9e7..9cd225a834a 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -560,7 +560,6 @@ env.Library('global_environment_experiment', # libs. serverOnlyFiles = [ "db/curop.cpp", "db/global_environment_d.cpp", - "db/d_globals.cpp", "util/compress.cpp", "db/ttl.cpp", "util/logfile.cpp", diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp index df7d55f419b..c005376730f 100644 --- a/src/mongo/db/clientcursor.cpp +++ b/src/mongo/db/clientcursor.cpp @@ -222,23 +222,32 @@ namespace mongo { // ClientCursorMonitor // - void ClientCursorMonitor::run() { - Client::initThread("clientcursormon"); - Client& client = cc(); - Timer t; - const int Secs = 4; - while (!inShutdown()) { - OperationContextImpl txn; - cursorStatsTimedOut.increment( - CollectionCursorCache::timeoutCursorsGlobal(&txn, t.millisReset())); - sleepsecs(Secs); + /** + * Thread for timing out old cursors + */ + class ClientCursorMonitor : public BackgroundJob { + public: + std::string name() const { return "ClientCursorMonitor"; } + + void run() { + Client::initThread("clientcursormon"); + Client& client = cc(); + Timer t; + const int Secs = 4; + while (!inShutdown()) { + OperationContextImpl txn; + cursorStatsTimedOut.increment( + CollectionCursorCache::timeoutCursorsGlobal(&txn, t.millisReset())); + sleepsecs(Secs); + } + client.shutdown(); } - client.shutdown(); - } + }; namespace { - ClientCursorMonitor clientCursorMonitor; - + // Only one instance of the ClientCursorMonitor exists + ClientCursorMonitor clientCursorMonitor = ClientCursorMonitor(); + void _appendCursorStats( BSONObjBuilder& b ) { b.append( "note" , "deprecated, use server status metrics" ); b.appendNumber("clientCursors_size", cursorStatsOpen.get() ); @@ -249,6 +258,10 @@ namespace mongo { } } + void startClientCursorMonitor() { + clientCursorMonitor.go(); + } + // QUESTION: Restrict to the namespace from which this command was issued? // Alternatively, make this command admin-only? // TODO: remove this for 2.8 diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index 30a699e8011..6e8fb2e1219 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -225,11 +225,6 @@ namespace mongo { ClientCursor* _cursor; }; - /** thread for timing out old cursors */ - class ClientCursorMonitor : public BackgroundJob { - public: - std::string name() const { return "ClientCursorMonitor"; } - void run(); - }; + void startClientCursorMonitor(); } // namespace mongo diff --git a/src/mongo/db/concurrency/d_concurrency.cpp b/src/mongo/db/concurrency/d_concurrency.cpp index 82f71ae5c09..b22fc017bd9 100644 --- a/src/mongo/db/concurrency/d_concurrency.cpp +++ b/src/mongo/db/concurrency/d_concurrency.cpp @@ -35,7 +35,6 @@ #include "mongo/db/client.h" #include "mongo/db/commands/server_status.h" #include "mongo/db/curop.h" -#include "mongo/db/d_globals.h" #include "mongo/db/global_environment_experiment.h" #include "mongo/db/concurrency/lock_stat.h" #include "mongo/db/server_parameters.h" diff --git a/src/mongo/db/d_globals.cpp b/src/mongo/db/d_globals.cpp deleted file mode 100644 index 97752a57436..00000000000 --- a/src/mongo/db/d_globals.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// @file d_globals.cpp - -/** -* Copyright (C) 2012 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ - -#include "mongo/pch.h" - -#include "mongo/db/d_globals.h" - -#include "mongo/db/clientcursor.h" -#include "mongo/util/concurrency/rwlock.h" - -namespace mongo { - - DGlobals::DGlobals() : - clientCursorMonitor( *(new ClientCursorMonitor()) ) - { - } - - DGlobals d; - -} diff --git a/src/mongo/db/d_globals.h b/src/mongo/db/d_globals.h deleted file mode 100644 index ec68900f650..00000000000 --- a/src/mongo/db/d_globals.h +++ /dev/null @@ -1,53 +0,0 @@ -// @file d_globals.h - -/** -* Copyright (C) 2012 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ - -// -// these are global variables used in mongod ("d"). also used in test binary as that is effectively a variation on mongod code. -// that is, these are not in mongos. -// - -#pragma once - -namespace mongo { - - class RWLockRecursive; - class ClientCursorMonitor; - - struct DGlobals : boost::noncopyable { - DGlobals(); - - // these are intentionally never deleted: - ClientCursorMonitor& clientCursorMonitor; - - }; - - extern DGlobals d; - -}; diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index 8abf9aa1a0e..ee268b50f80 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -52,7 +52,6 @@ #include "mongo/db/commands/server_status.h" #include "mongo/db/commands/server_status_metric.h" #include "mongo/db/concurrency/d_concurrency.h" -#include "mongo/db/d_globals.h" #include "mongo/db/db.h" #include "mongo/db/dbmessage.h" #include "mongo/db/dbwebserver.h" @@ -641,7 +640,8 @@ namespace mongo { if (serverGlobalParams.isHttpInterfaceEnabled) snapshotThread.go(); - d.clientCursorMonitor.go(); + startClientCursorMonitor(); + PeriodicTask::startRunningPeriodicTasks(); if (missingRepl) { // a warning was logged earlier |