blob: a1ae054f888eaf90cea736bc68ce3b91ae1e4aa3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// 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 ConfigHandler {
private:
typedef std::map<vespalib::string, Service::UP> ServiceMap;
ConfigSubscriber _subscriber;
ConfigHandle<SentinelConfig>::UP _sentinelHandle;
ServiceMap _services;
std::list<OutputConnection *> _outputConnections;
CommandQueue _cmdQ;
std::unique_ptr<RpcServer> _rpcServer;
int _boundPort;
StartMetrics _startMetrics;
StateApi _stateApi;
std::unique_ptr<vespalib::StateServer> _stateServer;
ConfigHandler(const ConfigHandler&);
ConfigHandler& operator =(const ConfigHandler&);
Service *serviceByPid(pid_t pid);
Service *serviceByName(const vespalib::string & name);
void handleCommands();
void handleCmd(const Cmd& cmd);
void handleOutputs();
void handleChildDeaths();
static int listen(int port);
void configure_port(int port);
void updateMetrics();
void terminateServices(bool catchable, bool printDebug = false);
void doConfigure();
public:
ConfigHandler();
virtual ~ConfigHandler();
void subscribe(const std::string & configId, uint64_t timeoutMS);
bool terminate();
int doWork();
void updateActiveFdset(fd_set *fds, int *maxNum);
};
}
|