diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2018-03-12 11:14:15 -0400 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2018-03-26 15:54:16 -0400 |
commit | af600c3876a26f62d8dde93bf769fc4ca3054072 (patch) | |
tree | ecef32a9b3c6c54501651168cce48093e76e9858 /src/mongo/unittest/benchmark_main.cpp | |
parent | 2676a176759359c8614c0e37b267198259b6789f (diff) | |
download | mongo-af600c3876a26f62d8dde93bf769fc4ca3054072.tar.gz |
SERVER-30170 Embedded can now shutdown and re-initialize.
- ServiceContext* is now closer to be an instance context for the database. We still don't support multiple instances but I wrote the new code with this in mind. Teardown and reinitialize then becomes a matter of being able to delete and re-create the ServiceContext*.
- Use the new MONGO_INITIALIZER that supports deinit/reinit to be able to re-initialize global systems that are decorations on ServiceContext.
- Move creation/destruction of ServiceContext* out of MONGO_INITIALIZER. This so we can hold an exclusive lock during as much as possible of the shutdown (like how mongod does)
- New ServiceContext registrer where we can link in different implementations of ServiceContext (replaces the SetGlobalEnvironment MONGO_INITIALIZER)
- As a result the SetGlobalEnvironment prerequisite for MONGO_INITIALIZERs is gone.
- The ServiceContext is passed to runGlobalInitializers, put in InitializationContext/DeinitializationContext so the initializers know which context they operate on.
Diffstat (limited to 'src/mongo/unittest/benchmark_main.cpp')
-rw-r--r-- | src/mongo/unittest/benchmark_main.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/unittest/benchmark_main.cpp b/src/mongo/unittest/benchmark_main.cpp index a992ddb06bf..b714ace268a 100644 --- a/src/mongo/unittest/benchmark_main.cpp +++ b/src/mongo/unittest/benchmark_main.cpp @@ -33,13 +33,21 @@ #include <benchmark/benchmark.h> #include "mongo/base/initializer.h" +#include "mongo/db/service_context.h" +#include "mongo/db/service_context_registrar.h" #include "mongo/util/signal_handlers_synchronous.h" int main(int argc, char** argv, char** envp) { ::mongo::clearSignalMask(); ::mongo::setupSynchronousSignalHandlers(); - ::mongo::runGlobalInitializersOrDie(argc, argv, envp); + + ::mongo::ServiceContext* serviceContext = nullptr; + if (::mongo::hasServiceContextFactory()) { + ::mongo::setGlobalServiceContext(::mongo::createServiceContext()); + serviceContext = ::mongo::getGlobalServiceContext(); + } + ::mongo::runGlobalInitializersOrDie(argc, argv, envp, serviceContext); // Copied from the BENCHMARK_MAIN macro. ::benchmark::Initialize(&argc, argv); |