blob: 9d3d14c6aeb014dfbba646f7c18ae7543ebfc4e2 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "cmdq.h"
#include "env.h"
#include "metrics.h"
#include "rpcserver.h"
#include "service.h"
#include "state-api.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;
/**
* Management of services.
* Handles requests from RPC, service events,
* and service configuration updates.
**/
class Manager {
private:
typedef std::map<vespalib::string, Service::UP> ServiceMap;
Env &_env;
ServiceMap _services;
ServiceMap _orphans;
std::list<OutputConnection *> _outputConnections;
Manager(const Manager&) = delete;
Manager& operator =(const Manager&) = delete;
Service *serviceByPid(pid_t pid);
Service *serviceByName(const vespalib::string & name);
void handleCommands();
void handleCmd(const Cmd& cmd);
void handleOutputs();
void handleChildDeaths();
void handleRestarts();
void updateMetrics();
void terminateServices(bool catchable, bool printDebug = false);
void doConfigure();
public:
Manager(Env &env);
virtual ~Manager();
bool terminate();
int doWork();
void updateActiveFdset(fd_set *fds, int *maxNum);
};
}
|