diff options
Diffstat (limited to 'configd/src/apps/sentinel/manager.h')
-rw-r--r-- | configd/src/apps/sentinel/manager.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/configd/src/apps/sentinel/manager.h b/configd/src/apps/sentinel/manager.h new file mode 100644 index 00000000000..4eaff7a2ef3 --- /dev/null +++ b/configd/src/apps/sentinel/manager.h @@ -0,0 +1,70 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "service.h" +#include "metrics.h" +#include "state-api.h" +#include "cmdq.h" +#include "rpcserver.h" +#include <vespa/config-sentinel.h> +#include <vespa/config/config.h> +#include <vespa/vespalib/net/state_server.h> +#include <sys/types.h> +#include <sys/select.h> + +#include <list> + +using cloud::config::SentinelConfig; +using config::ConfigSubscriber; +using config::ConfigHandle; + +namespace config::sentinel { + +class OutputConnection; + +class Manager { +private: + typedef std::map<vespalib::string, Service::UP> ServiceMap; + + ConfigSubscriber _subscriber; + ConfigHandle<SentinelConfig>::UP _sentinelHandle; + ServiceMap _services; + ServiceMap _orphans; + std::list<OutputConnection *> _outputConnections; + CommandQueue _cmdQ; + std::unique_ptr<RpcServer> _rpcServer; + int _boundPort; + StartMetrics _startMetrics; + StateApi _stateApi; + std::unique_ptr<vespalib::StateServer> _stateServer; + + Manager(const Manager&); + Manager& operator =(const Manager&); + + Service *serviceByPid(pid_t pid); + Service *serviceByName(const vespalib::string & name); + void handleCommands(); + void handleCmd(const Cmd& cmd); + void handleOutputs(); + void handleChildDeaths(); + void handleRestarts(); + + static int listen(int port); + void configure_port(int port); + + void updateMetrics(); + + void terminateServices(bool catchable, bool printDebug = false); + + void doConfigure(); + +public: + Manager(); + virtual ~Manager(); + void subscribe(const std::string & configId, std::chrono::milliseconds timeout); + bool terminate(); + int doWork(); + void updateActiveFdset(fd_set *fds, int *maxNum); +}; + +} |