summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2019-02-21 16:01:19 +0000
committerSara Golemon <sara.golemon@mongodb.com>2019-02-22 20:07:50 +0000
commita6b27fa913809d886ae481a8a3af3a176910b3b0 (patch)
tree1fa2d0d0f78149944d5f5798f1ff0c9d921c0fe9 /src
parent0ab7df179a7329fea4c28049d1ff532010720280 (diff)
downloadmongo-a6b27fa913809d886ae481a8a3af3a176910b3b0.tar.gz
SERVER-39716 Convert WiredTiger config options to IDL
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/storage/wiredtiger/SConscript1
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp135
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h16
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_global_options.idl107
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp12
5 files changed, 143 insertions, 128 deletions
diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript
index d7f1eb61b96..d4744276753 100644
--- a/src/mongo/db/storage/wiredtiger/SConscript
+++ b/src/mongo/db/storage/wiredtiger/SConscript
@@ -95,6 +95,7 @@ if wiredtiger:
'wiredtiger_options_init.cpp',
'wiredtiger_record_store_mongod.cpp',
'wiredtiger_server_status.cpp',
+ env.Idlc('wiredtiger_global_options.idl')[0],
],
LIBDEPS=[
'storage_wiredtiger_core',
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
index e4661994431..63424bf4844 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
@@ -31,140 +31,51 @@
#include "mongo/platform/basic.h"
-#include "mongo/base/status.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_global_options.h"
-#include "mongo/db/storage/wiredtiger/wiredtiger_record_store.h"
+
#include "mongo/util/log.h"
-#include "mongo/util/options_parser/constraints.h"
+
+namespace moe = mongo::optionenvironment;
namespace mongo {
WiredTigerGlobalOptions wiredTigerGlobalOptions;
-Status WiredTigerGlobalOptions::add(moe::OptionSection* options) {
- moe::OptionSection wiredTigerOptions("WiredTiger options");
-
- // WiredTiger storage engine options
- wiredTigerOptions.addOptionChaining("storage.wiredTiger.engineConfig.cacheSizeGB",
- "wiredTigerCacheSizeGB",
- moe::Double,
- "maximum amount of memory to allocate for cache; "
- "defaults to 1/2 of physical RAM");
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.engineConfig.statisticsLogDelaySecs",
- "wiredTigerStatisticsLogDelaySecs",
- moe::Int,
- "seconds to wait between each write to a statistics file in the dbpath; "
- "0 means do not log statistics")
- // FTDC supercedes WiredTiger's statistics logging.
- .hidden()
- .validRange(0, 100000)
- .setDefault(moe::Value(0));
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.engineConfig.journalCompressor",
- "wiredTigerJournalCompressor",
- moe::String,
- "use a compressor for log records [none|snappy|zlib|zstd]")
- .format("(:?none)|(:?snappy)|(:?zlib)|(:?zstd)", "(none/snappy/zlib/zstd)")
- .setDefault(moe::Value(std::string("snappy")));
- wiredTigerOptions.addOptionChaining("storage.wiredTiger.engineConfig.directoryForIndexes",
- "wiredTigerDirectoryForIndexes",
- moe::Switch,
- "Put indexes and data in different directories");
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.engineConfig.configString",
- "wiredTigerEngineConfigString",
- moe::String,
- "WiredTiger storage engine custom "
- "configuration settings")
- .hidden();
-
- // WiredTiger collection options
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.collectionConfig.blockCompressor",
- "wiredTigerCollectionBlockCompressor",
- moe::String,
- "block compression algorithm for collection data "
- "[none|snappy|zlib|zstd]")
- .format("(:?none)|(:?snappy)|(:?zlib)|(?:zstd)", "(none/snappy/zlib/zstd)")
- .setDefault(moe::Value(std::string("snappy")));
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.collectionConfig.configString",
- "wiredTigerCollectionConfigString",
- moe::String,
- "WiredTiger custom collection configuration settings")
- .hidden();
-
-
- // WiredTiger index options
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.indexConfig.prefixCompression",
- "wiredTigerIndexPrefixCompression",
- moe::Bool,
- "use prefix compression on row-store leaf pages")
- .setDefault(moe::Value(true));
- wiredTigerOptions
- .addOptionChaining("storage.wiredTiger.indexConfig.configString",
- "wiredTigerIndexConfigString",
- moe::String,
- "WiredTiger custom index configuration settings")
- .hidden();
-
- return options->addSection(wiredTigerOptions);
-}
-
-Status WiredTigerGlobalOptions::store(const moe::Environment& params,
- const std::vector<std::string>& args) {
+Status WiredTigerGlobalOptions::store(const moe::Environment& params) {
// WiredTiger storage engine options
- if (params.count("storage.wiredTiger.engineConfig.cacheSizeGB")) {
- wiredTigerGlobalOptions.cacheSizeGB =
- params["storage.wiredTiger.engineConfig.cacheSizeGB"].as<double>();
- }
if (params.count("storage.syncPeriodSecs")) {
wiredTigerGlobalOptions.checkpointDelaySecs =
static_cast<size_t>(params["storage.syncPeriodSecs"].as<double>());
}
- if (params.count("storage.wiredTiger.engineConfig.statisticsLogDelaySecs")) {
- wiredTigerGlobalOptions.statisticsLogDelaySecs =
- params["storage.wiredTiger.engineConfig.statisticsLogDelaySecs"].as<int>();
- }
- if (params.count("storage.wiredTiger.engineConfig.journalCompressor")) {
- wiredTigerGlobalOptions.journalCompressor =
- params["storage.wiredTiger.engineConfig.journalCompressor"].as<std::string>();
- }
- if (params.count("storage.wiredTiger.engineConfig.directoryForIndexes")) {
- wiredTigerGlobalOptions.directoryForIndexes =
- params["storage.wiredTiger.engineConfig.directoryForIndexes"].as<bool>();
- }
- if (params.count("storage.wiredTiger.engineConfig.configString")) {
- wiredTigerGlobalOptions.engineConfig =
- params["storage.wiredTiger.engineConfig.configString"].as<std::string>();
+
+ if (!wiredTigerGlobalOptions.engineConfig.empty()) {
log() << "Engine custom option: " << wiredTigerGlobalOptions.engineConfig;
}
- // WiredTiger collection options
- if (params.count("storage.wiredTiger.collectionConfig.blockCompressor")) {
- wiredTigerGlobalOptions.collectionBlockCompressor =
- params["storage.wiredTiger.collectionConfig.blockCompressor"].as<std::string>();
- }
- if (params.count("storage.wiredTiger.collectionConfig.configString")) {
- wiredTigerGlobalOptions.collectionConfig =
- params["storage.wiredTiger.collectionConfig.configString"].as<std::string>();
+ if (!wiredTigerGlobalOptions.collectionConfig.empty()) {
log() << "Collection custom option: " << wiredTigerGlobalOptions.collectionConfig;
}
- // WiredTiger index options
- if (params.count("storage.wiredTiger.indexConfig.prefixCompression")) {
- wiredTigerGlobalOptions.useIndexPrefixCompression =
- params["storage.wiredTiger.indexConfig.prefixCompression"].as<bool>();
- }
- if (params.count("storage.wiredTiger.indexConfig.configString")) {
- wiredTigerGlobalOptions.indexConfig =
- params["storage.wiredTiger.indexConfig.configString"].as<std::string>();
+ if (!wiredTigerGlobalOptions.indexConfig.empty()) {
log() << "Index custom option: " << wiredTigerGlobalOptions.indexConfig;
}
return Status::OK();
}
+Status WiredTigerGlobalOptions::validateWiredTigerCompressor(const std::string& value) {
+ constexpr auto kNone = "none"_sd;
+ constexpr auto kSnappy = "snappy"_sd;
+ constexpr auto kZlib = "zlib"_sd;
+ constexpr auto kZstd = "zstd"_sd;
+
+ if (!kNone.equalCaseInsensitive(value) && !kSnappy.equalCaseInsensitive(value) &&
+ !kZlib.equalCaseInsensitive(value) && !kZstd.equalCaseInsensitive(value)) {
+ return {ErrorCodes::BadValue,
+ "Compression option must be one of: 'none', 'snappy', 'zlib', or 'zstd'"};
+ }
+
+ return Status::OK();
+}
+
} // namespace mongo
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h
index ad47a6cc177..f77273a4289 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.h
@@ -29,12 +29,12 @@
#pragma once
-#include "mongo/util/options_parser/startup_option_init.h"
-#include "mongo/util/options_parser/startup_options.h"
+#include <string>
-namespace mongo {
+#include "mongo/base/status.h"
+#include "mongo/util/options_parser/environment.h"
-namespace moe = mongo::optionenvironment;
+namespace mongo {
class WiredTigerGlobalOptions {
public:
@@ -46,8 +46,7 @@ public:
useCollectionPrefixCompression(false),
useIndexPrefixCompression(false){};
- Status add(moe::OptionSection* options);
- Status store(const moe::Environment& params, const std::vector<std::string>& args);
+ Status store(const optionenvironment::Environment& params);
double cacheSizeGB;
size_t checkpointDelaySecs;
@@ -62,7 +61,10 @@ public:
bool useIndexPrefixCompression;
std::string collectionConfig;
std::string indexConfig;
+
+ static Status validateWiredTigerCompressor(const std::string&);
};
extern WiredTigerGlobalOptions wiredTigerGlobalOptions;
-}
+
+} // namespace mongo
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.idl b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.idl
new file mode 100644
index 00000000000..2b02e73d6a9
--- /dev/null
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.idl
@@ -0,0 +1,107 @@
+# Copyright (C) 2019-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/storage/wiredtiger/wiredtiger_global_options.h"
+ configs:
+ section: 'WiredTiger options'
+ source: [ cli, ini, yaml ]
+
+configs:
+ # WiredTiger storage engine options
+ "storage.wiredTiger.engineConfig.cacheSizeGB":
+ description: >-
+ Maximum amount of memory to allocate for cache;
+ Defaults to 1/2 of physical RAM
+ arg_vartype: Double
+ cpp_varname: 'wiredTigerGlobalOptions.cacheSizeGB'
+ short_name: wiredTigerCacheSizeGB
+ "storage.wiredTiger.engineConfig.statisticsLogDelaySecs":
+ # FTDC supercedes WiredTiger's statistics logging.
+ description: >-
+ Seconds to wait between each write to a statistics file in the dbpath;
+ 0 means do not log statistics
+ arg_vartype: Int
+ cpp_varname: 'wiredTigerGlobalOptions.statisticsLogDelaySecs'
+ short_name: wiredTigerStatisticsLogDelaySecs
+ hidden: true
+ validator:
+ gte: 0
+ lte: 100000
+ default: 0
+ "storage.wiredTiger.engineConfig.journalCompressor":
+ description: 'Use a compressor for log records [none|snappy|zlib|zstd]'
+ arg_vartype: String
+ cpp_varname: 'wiredTigerGlobalOptions.journalCompressor'
+ short_name: wiredTigerJournalCompressor
+ default: 'snappy'
+ validator:
+ callback: 'WiredTigerGlobalOptions::validateWiredTigerCompressor'
+ "storage.wiredTiger.engineConfig.directoryForIndexes":
+ description: 'Put indexes and data in different directories'
+ arg_vartype: Switch
+ cpp_varname: 'wiredTigerGlobalOptions.directoryForIndexes'
+ short_name: wiredTigerDirectoryForIndexes
+ "storage.wiredTiger.engineConfig.configString":
+ description: 'WiredTiger storage engine custom configuration setting'
+ arg_vartype: String
+ cpp_varname: 'wiredTigerGlobalOptions.engineConfig'
+ short_name: wiredTigerEngineConfigString
+ hidden: true
+
+ # WiredTiger collection options
+ "storage.wiredTiger.collectionConfig.blockCompressor":
+ description: 'Block compression algorithm for collection data [none|snappy|zlib|zstd]'
+ arg_vartype: String
+ cpp_varname: 'wiredTigerGlobalOptions.collectionBlockCompressor'
+ short_name: wiredTigerCollectionBlockCompressor
+ validator:
+ callback: 'WiredTigerGlobalOptions::validateWiredTigerCompressor'
+ default: snappy
+ "storage.wiredTiger.collectionConfig.configString":
+ description: 'WiredTiger custom collection configuration settings'
+ arg_vartype: String
+ cpp_varname: 'wiredTigerGlobalOptions.collectionConfig'
+ short_name: wiredTigerCollectionConfigString
+ hidden: true
+
+ # WiredTiger index options
+ "storage.wiredTiger.indexConfig.prefixCompression":
+ description: 'Use prefix compression on row-store leaf pages'
+ arg_vartype: Bool
+ cpp_varname: 'wiredTigerGlobalOptions.useIndexPrefixCompression'
+ short_name: wiredTigerIndexPrefixCompression
+ default: true
+ "storage.wiredTiger.indexConfig.configString":
+ description: 'WiredTiger custom index configuration settings'
+ arg_vartype: String
+ cpp_varname: 'wiredTigerGlobalOptions.indexConfig'
+ short_name: wiredTigerIndexConfigString
+ hidden: true
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp
index 328b1f55950..6e4cbf157ab 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_options_init.cpp
@@ -37,18 +37,12 @@
#include "mongo/util/exit_code.h"
#include "mongo/util/options_parser/startup_options.h"
-namespace mongo {
-
-MONGO_MODULE_STARTUP_OPTIONS_REGISTER(WiredTigerOptions)(InitializerContext* context) {
- return wiredTigerGlobalOptions.add(&moe::startupOptions);
-}
+namespace moe = mongo::optionenvironment;
-MONGO_STARTUP_OPTIONS_VALIDATE(WiredTigerOptions)(InitializerContext* context) {
- return Status::OK();
-}
+namespace mongo {
MONGO_STARTUP_OPTIONS_STORE(WiredTigerOptions)(InitializerContext* context) {
- Status ret = wiredTigerGlobalOptions.store(moe::startupOptionsParsed, context->args());
+ Status ret = wiredTigerGlobalOptions.store(moe::startupOptionsParsed);
if (!ret.isOK()) {
std::cerr << ret.toString() << std::endl;
std::cerr << "try '" << context->args()[0] << " --help' for more information" << std::endl;