diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-24 12:50:31 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-24 12:50:31 +0000 |
commit | 9d8de3b985984987a4eae67e5d6d3a3fbdfc7efa (patch) | |
tree | 70eeb1abeaa1fd22dbfd8ed5f07409f643cc6a9d /searchcore/src/apps | |
parent | 4ed0d2b6f00c82bc3ba8a3290576a7bedfdd1895 (diff) |
- Create the common transport and threadpool in the main loop.
- Also use the common transport for config subscriptions.
- Put The TransportConfig in the fnet namespace.
Diffstat (limited to 'searchcore/src/apps')
-rw-r--r-- | searchcore/src/apps/proton/proton.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index 61536f924a5..552e6688532 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -5,9 +5,13 @@ #include <vespa/metrics/metricmanager.h> #include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/util/programoptions.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/config/common/exceptions.h> +#include <vespa/config/common/configcontext.h> +#include <vespa/fnet/transport.h> +#include <vespa/fastos/thread.h> #include <vespa/fastos/app.h> #include <iostream> #include <thread> @@ -186,8 +190,14 @@ App::Main() LOG(debug, "serviceidentity: '%s'", params.serviceidentity.c_str()); LOG(debug, "subscribeTimeout: '%" PRIu64 "'", params.subscribeTimeout); std::chrono::milliseconds subscribeTimeout(params.subscribeTimeout); - config::ConfigUri identityUri(params.identity); - protonUP = std::make_unique<proton::Proton>(identityUri, _argc > 0 ? _argv[0] : "proton", subscribeTimeout); + FastOS_ThreadPool threadPool(128_Ki); + uint32_t numProcs = std::thread::hardware_concurrency(); + FNET_Transport transport(fnet::TransportConfig(std::max(1u, std::min(4u, numProcs/8)))); + transport.Start(&threadPool); + config::ConfigServerSpec configServerSpec(transport); + config::ConfigUri identityUri(params.identity, std::make_shared<config::ConfigContext>(configServerSpec)); + protonUP = std::make_unique<proton::Proton>(threadPool, transport, identityUri, + _argc > 0 ? _argv[0] : "proton", subscribeTimeout); proton::Proton & proton = *protonUP; proton::BootstrapConfig::SP configSnapshot = proton.init(); if (proton.hasAbortedInit()) { @@ -228,6 +238,7 @@ App::Main() EV_STOPPING("servicelayer", "clean shutdown"); } protonUP.reset(); + transport.ShutDown(true); EV_STOPPING("proton", "clean shutdown"); } } catch (const vespalib::InvalidCommandLineArgumentsException &e) { |