blob: 3e4187cd1912f13127e1b6c82272953036a5d932 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "named_service.h"
#include "monitor.h"
#include <vespa/fnet/frt/invoker.h>
namespace slobrok {
//-----------------------------------------------------------------------------
class IRpcServerManager;
/**
* @class ManagedRpcServer
* @brief A NamedService that is managed by this location broker
*
* This class contains the logic to monitor the connection to a
* NamedService and also to do a healthCheck using the RPC method
* slobrok.checkRpcServer on the connection, notifying its
* manager using callbacks in the IRpcServerManager interface.
**/
class ManagedRpcServer: public NamedService,
public FRT_IRequestWait,
public FNET_Task,
public IMonitoredServer
{
public:
ManagedRpcServer(const ManagedRpcServer&) = delete;
ManagedRpcServer& operator=(const ManagedRpcServer&) = delete;
ManagedRpcServer(const std::string & name, const std::string & spec, IRpcServerManager &manager);
~ManagedRpcServer();
void healthCheck();
void PerformTask() override;
private:
IRpcServerManager &_mmanager;
Monitor _monitor;
FRT_Target *_monitoredServer;
FRT_RPCRequest *_checkServerReq;
void cleanupMonitor();
bool validateRpcServer(uint32_t numstrings,
FRT_StringValue *strings);
public:
void RequestDone(FRT_RPCRequest *req) override;
void notifyDisconnected() override; // lost connection to service
};
//-----------------------------------------------------------------------------
} // namespace slobrok
|