diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2019-01-24 11:09:27 -0500 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2019-01-24 11:09:27 -0500 |
commit | 731bc64f8dbbee1def448b10feca305887bdc180 (patch) | |
tree | 50663e4c2a349feea8462e60e8501fbbcc89f981 /src/mongo/db/ftdc | |
parent | 3c5bb991e11d25fb767ee5c6fb249c3bcafa32a3 (diff) | |
download | mongo-731bc64f8dbbee1def448b10feca305887bdc180.tar.gz |
SERVER-38464 Add setParameter for custom FTDC data directory
Diffstat (limited to 'src/mongo/db/ftdc')
-rw-r--r-- | src/mongo/db/ftdc/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/ftdc/ftdc_mongod.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/ftdc/ftdc_mongos.cpp | 35 | ||||
-rw-r--r-- | src/mongo/db/ftdc/ftdc_mongos.idl | 40 | ||||
-rw-r--r-- | src/mongo/db/ftdc/ftdc_server.cpp | 36 | ||||
-rw-r--r-- | src/mongo/db/ftdc/ftdc_server.h | 5 | ||||
-rw-r--r-- | src/mongo/db/ftdc/ftdc_server.idl | 6 |
7 files changed, 54 insertions, 77 deletions
diff --git a/src/mongo/db/ftdc/SConscript b/src/mongo/db/ftdc/SConscript index dd662a24c1c..8be42abcbc5 100644 --- a/src/mongo/db/ftdc/SConscript +++ b/src/mongo/db/ftdc/SConscript @@ -81,7 +81,6 @@ env.Library( env.Library( target='ftdc_mongos', source=[ - env.Idlc('ftdc_mongos.idl')[0], 'ftdc_mongos.cpp', ], LIBDEPS_PRIVATE=[ diff --git a/src/mongo/db/ftdc/ftdc_mongod.cpp b/src/mongo/db/ftdc/ftdc_mongod.cpp index b4b9cf2bd77..71c1df02dc4 100644 --- a/src/mongo/db/ftdc/ftdc_mongod.cpp +++ b/src/mongo/db/ftdc/ftdc_mongod.cpp @@ -64,8 +64,12 @@ void registerMongoDCollectors(FTDCController* controller) { } // namespace void startMongoDFTDC() { - boost::filesystem::path dir(storageGlobalParams.dbpath); - dir /= kFTDCDefaultDirectory.toString(); + auto dir = getFTDCDirectoryPathParameter(); + + if (dir.empty()) { + dir = storageGlobalParams.dbpath; + dir /= kFTDCDefaultDirectory.toString(); + } startFTDC(dir, FTDCStartMode::kStart, registerMongoDCollectors); } diff --git a/src/mongo/db/ftdc/ftdc_mongos.cpp b/src/mongo/db/ftdc/ftdc_mongos.cpp index 15a8f28f1d5..604f195d52b 100644 --- a/src/mongo/db/ftdc/ftdc_mongos.cpp +++ b/src/mongo/db/ftdc/ftdc_mongos.cpp @@ -36,7 +36,6 @@ #include <boost/filesystem.hpp> #include "mongo/db/ftdc/controller.h" -#include "mongo/db/ftdc/ftdc_mongos_gen.h" #include "mongo/db/ftdc/ftdc_server.h" #include "mongo/db/server_parameters.h" #include "mongo/stdx/thread.h" @@ -45,36 +44,6 @@ namespace mongo { -namespace { - -/** - * Expose diagnosticDataCollectionDirectoryPath set parameter to specify the MongoS FTDC path. - */ -synchronized_value<boost::filesystem::path> ftdcDirectoryPathParameter; -} // namespace - -void DiagnosticDataCollectionDirectoryPathServerParameter::append(OperationContext* opCtx, - BSONObjBuilder& b, - const std::string& name) { - b.append(name, ftdcDirectoryPathParameter->generic_string()); -} - -Status DiagnosticDataCollectionDirectoryPathServerParameter::setFromString(const std::string& str) { - if (hasGlobalServiceContext()) { - FTDCController* controller = FTDCController::get(getGlobalServiceContext()); - if (controller) { - Status s = controller->setDirectory(str); - if (!s.isOK()) { - return s; - } - } - } - - ftdcDirectoryPathParameter = str; - - return Status::OK(); -} - void registerMongoSCollectors(FTDCController* controller) { // PoolStats controller->addPeriodicCollector(stdx::make_unique<FTDCSimpleInternalCommandCollector>( @@ -89,7 +58,7 @@ void startMongoSFTDC() { // Only attempt to enable FTDC if we have a path to log files to. FTDCStartMode startMode = FTDCStartMode::kStart; - auto directory = ftdcDirectoryPathParameter.get(); + auto directory = getFTDCDirectoryPathParameter(); if (directory.empty()) { if (serverGlobalParams.logpath.empty()) { @@ -100,11 +69,9 @@ void startMongoSFTDC() { directory = boost::filesystem::absolute( FTDCUtil::getMongoSPath(serverGlobalParams.logpath), serverGlobalParams.cwd); - // Update the server parameter with the computed path. // Note: If the computed FTDC directory conflicts with an existing file, then FTDC will // warn about the conflict, and not startup. It will not terminate MongoS in this // situation. - ftdcDirectoryPathParameter = directory; } } diff --git a/src/mongo/db/ftdc/ftdc_mongos.idl b/src/mongo/db/ftdc/ftdc_mongos.idl deleted file mode 100644 index f8546f3e639..00000000000 --- a/src/mongo/db/ftdc/ftdc_mongos.idl +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2018-present MongoDB, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the Server Side Public License, version 1, -# as published by MongoDB, Inc. -# -# 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 -# Server Side Public License for more details. -# -# You should have received a copy of the Server Side Public License -# along with this program. If not, see -# <http://www.mongodb.com/licensing/server-side-public-license>. -# -# 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 Server Side 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. -# - -global: - cpp_namespace: "mongo" - cpp_includes: - - "mongo/db/ftdc/ftdc_mongos.h" - -server_parameters: - - diagnosticDataCollectionDirectoryPath: - description: "Specify the directory for the diagnostic directory for mongos" - set_at: [startup, runtime] - cpp_class: DiagnosticDataCollectionDirectoryPathServerParameter - diff --git a/src/mongo/db/ftdc/ftdc_server.cpp b/src/mongo/db/ftdc/ftdc_server.cpp index 3ea6a751aa3..b07c04f104b 100644 --- a/src/mongo/db/ftdc/ftdc_server.cpp +++ b/src/mongo/db/ftdc/ftdc_server.cpp @@ -42,11 +42,13 @@ #include "mongo/db/ftdc/collector.h" #include "mongo/db/ftdc/config.h" #include "mongo/db/ftdc/controller.h" +#include "mongo/db/ftdc/ftdc_server_gen.h" #include "mongo/db/ftdc/ftdc_system_stats.h" #include "mongo/db/jsobj.h" #include "mongo/db/server_parameters.h" #include "mongo/db/service_context.h" #include "mongo/stdx/memory.h" +#include "mongo/util/synchronized_value.h" namespace mongo { @@ -62,10 +64,42 @@ FTDCController* getGlobalFTDCController() { return getFTDCController(getGlobalServiceContext()).get(); } +/** + * Expose diagnosticDataCollectionDirectoryPath set parameter to specify the MongoD and MongoS FTDC + * path. + */ +synchronized_value<boost::filesystem::path> ftdcDirectoryPathParameter; + } // namespace FTDCStartupParams ftdcStartupParams; +void DiagnosticDataCollectionDirectoryPathServerParameter::append(OperationContext* opCtx, + BSONObjBuilder& b, + const std::string& name) { + b.append(name, ftdcDirectoryPathParameter->generic_string()); +} + +Status DiagnosticDataCollectionDirectoryPathServerParameter::setFromString(const std::string& str) { + if (hasGlobalServiceContext()) { + FTDCController* controller = FTDCController::get(getGlobalServiceContext()); + if (controller) { + Status s = controller->setDirectory(str); + if (!s.isOK()) { + return s; + } + } + } + + ftdcDirectoryPathParameter = str; + + return Status::OK(); +} + +boost::filesystem::path getFTDCDirectoryPathParameter() { + return ftdcDirectoryPathParameter.get(); +} + Status onUpdateFTDCEnabled(const bool value) { auto controller = getGlobalFTDCController(); if (controller) { @@ -177,6 +211,8 @@ void startFTDC(boost::filesystem::path& path, config.maxSamplesPerInterimMetricChunk = ftdcStartupParams.maxSamplesPerInterimMetricChunk.load(); + ftdcDirectoryPathParameter = path; + auto controller = stdx::make_unique<FTDCController>(path, config); // Install periodic collectors diff --git a/src/mongo/db/ftdc/ftdc_server.h b/src/mongo/db/ftdc/ftdc_server.h index 1d121e0c705..382d36d5e3d 100644 --- a/src/mongo/db/ftdc/ftdc_server.h +++ b/src/mongo/db/ftdc/ftdc_server.h @@ -135,4 +135,9 @@ Status onUpdateFTDCFileSize(const std::int32_t value); Status onUpdateFTDCSamplesPerChunk(const std::int32_t value); Status onUpdateFTDCPerInterimUpdate(const std::int32_t value); +/** + * Server Parameter accessors + */ +boost::filesystem::path getFTDCDirectoryPathParameter(); + } // namespace mongo diff --git a/src/mongo/db/ftdc/ftdc_server.idl b/src/mongo/db/ftdc/ftdc_server.idl index d1b14d7d613..e9125fe492b 100644 --- a/src/mongo/db/ftdc/ftdc_server.idl +++ b/src/mongo/db/ftdc/ftdc_server.idl @@ -81,3 +81,9 @@ server_parameters: on_update: "onUpdateFTDCPerInterimUpdate" validator: gte: 2 + + diagnosticDataCollectionDirectoryPath: + description: "Specify the directory for the diagnostic data directory." + set_at: [startup, runtime] + cpp_class: DiagnosticDataCollectionDirectoryPathServerParameter + |