diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-05-27 13:17:16 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-05-27 13:17:19 +0000 |
commit | f002266330e04b61f01ce901733ce83006319dc0 (patch) | |
tree | 279b0623672efcb3bbe0c67e59415ba0274209d0 /configd | |
parent | 469c7245b62be6f5ee114827cd0c69971e54609f (diff) |
rename ConfigHandler class
* since this won't do config subscription etc,
give it a more generic name.
Diffstat (limited to 'configd')
-rw-r--r-- | configd/src/apps/sentinel/CMakeLists.txt | 2 | ||||
-rw-r--r-- | configd/src/apps/sentinel/manager.cpp (renamed from configd/src/apps/sentinel/config-handler.cpp) | 40 | ||||
-rw-r--r-- | configd/src/apps/sentinel/manager.h (renamed from configd/src/apps/sentinel/config-handler.h) | 10 | ||||
-rw-r--r-- | configd/src/apps/sentinel/sentinel.cpp | 4 |
4 files changed, 28 insertions, 28 deletions
diff --git a/configd/src/apps/sentinel/CMakeLists.txt b/configd/src/apps/sentinel/CMakeLists.txt index b4fca4a3285..765988fa2ef 100644 --- a/configd/src/apps/sentinel/CMakeLists.txt +++ b/configd/src/apps/sentinel/CMakeLists.txt @@ -3,7 +3,7 @@ vespa_add_executable(configd_config-sentinel_app SOURCES sentinel.cpp service.cpp - config-handler.cpp + manager.cpp line-splitter.cpp output-connection.cpp metrics.cpp diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/manager.cpp index 9c39b13ba4c..bfd9a5e2bef 100644 --- a/configd/src/apps/sentinel/config-handler.cpp +++ b/configd/src/apps/sentinel/manager.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "config-handler.h" +#include "manager.h" #include "output-connection.h" #include <vespa/vespalib/net/socket_address.h> @@ -11,12 +11,12 @@ #include <sys/wait.h> #include <vespa/log/log.h> -LOG_SETUP(".config-handler"); +LOG_SETUP(".manager"); namespace config::sentinel { void -ConfigHandler::configure_port(int port) +Manager::configure_port(int port) { if (port == 0) { port = 19098; @@ -36,7 +36,7 @@ ConfigHandler::configure_port(int port) } } -ConfigHandler::ConfigHandler() +Manager::Manager() : _subscriber(), _services(), _outputConnections(), @@ -47,7 +47,7 @@ ConfigHandler::ConfigHandler() _startMetrics.startedTime = vespalib::steady_clock::now(); } -ConfigHandler::~ConfigHandler() +Manager::~Manager() { terminateServices(false); for (OutputConnection * conn : _outputConnections) { @@ -56,7 +56,7 @@ ConfigHandler::~ConfigHandler() } void -ConfigHandler::terminateServices(bool catchable, bool printDebug) +Manager::terminateServices(bool catchable, bool printDebug) { for (const auto & entry : _services) { Service *service = entry.second.get(); @@ -74,7 +74,7 @@ ConfigHandler::terminateServices(bool catchable, bool printDebug) bool -ConfigHandler::terminate() +Manager::terminate() { // Call terminate(true) for all services. // Give them 58 seconds to exit cleanly, then terminate(false) all @@ -98,13 +98,13 @@ ConfigHandler::terminate() } void -ConfigHandler::subscribe(const std::string & configId, std::chrono::milliseconds timeout) +Manager::subscribe(const std::string & configId, std::chrono::milliseconds timeout) { _sentinelHandle = _subscriber.subscribe<SentinelConfig>(configId, timeout); } void -ConfigHandler::doConfigure() +Manager::doConfigure() { std::unique_ptr<SentinelConfig> cfg(_sentinelHandle->getConfig()); const SentinelConfig& config(*cfg); @@ -117,7 +117,7 @@ ConfigHandler::doConfigure() _rpcServer = std::make_unique<RpcServer>(config.port.rpc, _cmdQ); } - LOG(debug, "ConfigHandler::configure() %d config elements, tenant(%s), application(%s), instance(%s)", + LOG(debug, "Manager::configure() %d config elements, tenant(%s), application(%s), instance(%s)", (int)config.service.size(), config.application.tenant.c_str(), config.application.name.c_str(), config.application.instance.c_str()); ServiceMap services; @@ -146,7 +146,7 @@ ConfigHandler::doConfigure() int -ConfigHandler::doWork() +Manager::doWork() { // Return true if there are any running services, false if not. @@ -169,7 +169,7 @@ ConfigHandler::doWork() } void -ConfigHandler::handleRestarts() +Manager::handleRestarts() { for (const auto & entry : _services) { Service & svc = *(entry.second); @@ -180,7 +180,7 @@ ConfigHandler::handleRestarts() } void -ConfigHandler::handleChildDeaths() +Manager::handleChildDeaths() { // See if any of our child processes have exited, and take // the appropriate action. @@ -203,7 +203,7 @@ ConfigHandler::handleChildDeaths() } void -ConfigHandler::updateActiveFdset(fd_set *fds, int *maxNum) +Manager::updateActiveFdset(fd_set *fds, int *maxNum) { // ### _Possibly put an assert here if fd is > 1023??? for (OutputConnection *c : _outputConnections) { @@ -218,7 +218,7 @@ ConfigHandler::updateActiveFdset(fd_set *fds, int *maxNum) } void -ConfigHandler::handleOutputs() +Manager::handleOutputs() { std::list<OutputConnection *>::iterator dst; std::list<OutputConnection *>::const_iterator src; @@ -241,7 +241,7 @@ ConfigHandler::handleOutputs() } void -ConfigHandler::handleCommands() +Manager::handleCommands() { // handle RPC commands std::vector<Cmd::UP> got = _cmdQ.drain(); @@ -252,7 +252,7 @@ ConfigHandler::handleCommands() } Service * -ConfigHandler::serviceByPid(pid_t pid) +Manager::serviceByPid(pid_t pid) { for (const auto & service : _services) { if (service.second->pid() == pid) { @@ -269,7 +269,7 @@ ConfigHandler::serviceByPid(pid_t pid) } Service * -ConfigHandler::serviceByName(const vespalib::string & name) +Manager::serviceByName(const vespalib::string & name) { auto found(_services.find(name)); if (found != _services.end()) { @@ -280,7 +280,7 @@ ConfigHandler::serviceByName(const vespalib::string & name) void -ConfigHandler::handleCmd(const Cmd& cmd) +Manager::handleCmd(const Cmd& cmd) { switch (cmd.type()) { case Cmd::LIST: @@ -353,7 +353,7 @@ ConfigHandler::handleCmd(const Cmd& cmd) } void -ConfigHandler::updateMetrics() +Manager::updateMetrics() { _startMetrics.maybeLog(); } diff --git a/configd/src/apps/sentinel/config-handler.h b/configd/src/apps/sentinel/manager.h index 463e9e7ce6a..4eaff7a2ef3 100644 --- a/configd/src/apps/sentinel/config-handler.h +++ b/configd/src/apps/sentinel/manager.h @@ -22,7 +22,7 @@ namespace config::sentinel { class OutputConnection; -class ConfigHandler { +class Manager { private: typedef std::map<vespalib::string, Service::UP> ServiceMap; @@ -38,8 +38,8 @@ private: StateApi _stateApi; std::unique_ptr<vespalib::StateServer> _stateServer; - ConfigHandler(const ConfigHandler&); - ConfigHandler& operator =(const ConfigHandler&); + Manager(const Manager&); + Manager& operator =(const Manager&); Service *serviceByPid(pid_t pid); Service *serviceByName(const vespalib::string & name); @@ -59,8 +59,8 @@ private: void doConfigure(); public: - ConfigHandler(); - virtual ~ConfigHandler(); + Manager(); + virtual ~Manager(); void subscribe(const std::string & configId, std::chrono::milliseconds timeout); bool terminate(); int doWork(); diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp index 1bca6f72d10..9d5a18d249f 100644 --- a/configd/src/apps/sentinel/sentinel.cpp +++ b/configd/src/apps/sentinel/sentinel.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "config-handler.h" +#include "manager.h" #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/util/signalhandler.h> #include <vespa/vespalib/util/exceptions.h> @@ -61,7 +61,7 @@ main(int argc, char **argv) } setlocale(LC_ALL, "C"); - sentinel::ConfigHandler handler; + sentinel::Manager handler; LOG(debug, "Reading configuration"); try { |