summaryrefslogtreecommitdiff
path: root/src/mongo/embedded
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-06-06 12:02:27 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-06-12 15:04:19 -0400
commit06d98ac518613723d3e5aa80b6877941e164699f (patch)
treebaec365fee3b8ba68dc4e575af71a13dcb811fd6 /src/mongo/embedded
parent8b698cac2d19f0fec502db10501e7059a10d2897 (diff)
downloadmongo-06d98ac518613723d3e5aa80b6877941e164699f.tar.gz
SERVER-35421 Embedded options parsing can re-initialize.
Diffstat (limited to 'src/mongo/embedded')
-rw-r--r--src/mongo/embedded/embedded_options.cpp4
-rw-r--r--src/mongo/embedded/embedded_options.h2
-rw-r--r--src/mongo/embedded/embedded_options_init.cpp59
-rw-r--r--src/mongo/embedded/embedded_options_parser_init.cpp32
4 files changed, 59 insertions, 38 deletions
diff --git a/src/mongo/embedded/embedded_options.cpp b/src/mongo/embedded/embedded_options.cpp
index 949e31ce07b..524a751a5ee 100644
--- a/src/mongo/embedded/embedded_options.cpp
+++ b/src/mongo/embedded/embedded_options.cpp
@@ -151,5 +151,9 @@ Status storeOptions(const moe::Environment& params) {
return Status::OK();
}
+void resetOptions() {
+ storageGlobalParams.reset();
+}
+
} // namespace embedded
} // namespace mongo
diff --git a/src/mongo/embedded/embedded_options.h b/src/mongo/embedded/embedded_options.h
index 126a4da6a25..4498dcd98ed 100644
--- a/src/mongo/embedded/embedded_options.h
+++ b/src/mongo/embedded/embedded_options.h
@@ -46,5 +46,7 @@ Status addOptions(optionenvironment::OptionSection* options);
Status canonicalizeOptions(optionenvironment::Environment* params);
Status storeOptions(const optionenvironment::Environment& params);
+void resetOptions();
+
} // namespace embedded
} // namespace mongo
diff --git a/src/mongo/embedded/embedded_options_init.cpp b/src/mongo/embedded/embedded_options_init.cpp
index f9ffc50afde..e09c67e62d5 100644
--- a/src/mongo/embedded/embedded_options_init.cpp
+++ b/src/mongo/embedded/embedded_options_init.cpp
@@ -38,33 +38,40 @@ MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(EmbeddedOptions)(InitializerContext* cont
return addOptions(&optionenvironment::startupOptions);
}
-MONGO_INITIALIZER_GENERAL(EmbeddedOptions,
- ("BeginStartupOptionValidation", "AllFailPointsRegistered"),
- ("EndStartupOptionValidation"))
-(InitializerContext* context) {
- // Run validation, but tell the Environment that we don't want it to be set as "valid",
- // since we may be making it invalid in the canonicalization process.
- Status ret = optionenvironment::startupOptionsParsed.validate(false);
- if (!ret.isOK()) {
- return ret;
- }
- ret = canonicalizeOptions(&optionenvironment::startupOptionsParsed);
- if (!ret.isOK()) {
- return ret;
- }
- ret = optionenvironment::startupOptionsParsed.validate();
- if (!ret.isOK()) {
- return ret;
- }
- return Status::OK();
-}
+GlobalInitializerRegisterer embeddedOptionsInitializer(
+ "EmbeddedOptions",
+ {"BeginStartupOptionValidation", "AllFailPointsRegistered"},
+ {"EndStartupOptionValidation"},
+ [](InitializerContext* context) {
+ // Run validation, but tell the Environment that we don't want it to be set as "valid",
+ // since we may be making it invalid in the canonicalization process.
+ Status ret = optionenvironment::startupOptionsParsed.validate(false);
+ if (!ret.isOK()) {
+ return ret;
+ }
+ ret = canonicalizeOptions(&optionenvironment::startupOptionsParsed);
+ if (!ret.isOK()) {
+ return ret;
+ }
+ ret = optionenvironment::startupOptionsParsed.validate();
+ if (!ret.isOK()) {
+ return ret;
+ }
+ return Status::OK();
+ },
+ [](DeinitializerContext* context) { return Status::OK(); });
-MONGO_INITIALIZER_GENERAL(EmbeddedOptions_Store,
- ("BeginStartupOptionStorage"),
- ("EndStartupOptionStorage"))
-(InitializerContext* context) {
- return storeOptions(optionenvironment::startupOptionsParsed);
-}
+GlobalInitializerRegisterer embeddedOptionsStore("EmbeddedOptions_Store",
+ {"BeginStartupOptionStorage"},
+ {"EndStartupOptionStorage"},
+ [](InitializerContext* context) {
+ return storeOptions(
+ optionenvironment::startupOptionsParsed);
+ },
+ [](DeinitializerContext* context) {
+ resetOptions();
+ return Status::OK();
+ });
} // namespace embedded
} // namespace mongo
diff --git a/src/mongo/embedded/embedded_options_parser_init.cpp b/src/mongo/embedded/embedded_options_parser_init.cpp
index 1416556828a..54ae228921e 100644
--- a/src/mongo/embedded/embedded_options_parser_init.cpp
+++ b/src/mongo/embedded/embedded_options_parser_init.cpp
@@ -40,18 +40,26 @@
namespace mongo {
namespace optionenvironment {
-MONGO_STARTUP_OPTIONS_PARSE(StartupOptions)(InitializerContext* context) {
- // Embedded uses a YAML config passed in argv to reuse the existing interface, extract it from
- // the first element otherwise use empty string.
- std::string config = !context->args().empty() ? context->args()[0] : "";
-
- OptionsParser parser;
- Status ret =
- parser.runConfigFile(startupOptions, config, context->env(), &startupOptionsParsed);
- uassertStatusOKWithContext(ret, "Options parsing failed.");
-
- return Status::OK();
-}
+GlobalInitializerRegisterer startupOptionsInitializer(
+ "StartupOptions",
+ {"BeginStartupOptionParsing"},
+ {"EndStartupOptionParsing"},
+ [](InitializerContext* context) {
+ // Embedded uses a YAML config passed in argv to reuse the existing interface, extract it
+ // from the first element otherwise use empty string.
+ std::string config = !context->args().empty() ? context->args()[0] : "";
+
+ OptionsParser parser;
+ Status ret =
+ parser.runConfigFile(startupOptions, config, context->env(), &startupOptionsParsed);
+ uassertStatusOKWithContext(ret, "Options parsing failed.");
+
+ return Status::OK();
+ },
+ [](DeinitializerContext* context) {
+ startupOptionsParsed = Environment();
+ return Status::OK();
+ });
} // namespace optionenvironment
} // namespace mongo