blob: 1c1d6ebf41103c1898ace3baaa0e8a60a4593a27 (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/fnet/frt/invokable.h>
class FNET_Task;
class FRT_Supervisor;
namespace slobrok {
class SBEnv;
class RpcServerMap;
class RpcServerManager;
/**
* @class RPCHooks
* @brief The FNET-RPC interface to a location broker
*
* Contains methods for receiveing and unpacking requests,
* invoking the right internal method, and (in most cases)
* packaging and returning the result of the request.
**/
class RPCHooks : public FRT_Invokable
{
public:
struct Metrics {
unsigned long heartBeatFails;
unsigned long registerReqs;
unsigned long mirrorReqs;
unsigned long wantAddReqs;
unsigned long doAddReqs;
unsigned long doRemoveReqs;
unsigned long adminReqs;
unsigned long otherReqs;
static Metrics zero() { return Metrics{0,0,0,0,0,0,0,0}; }
};
private:
SBEnv &_env;
RpcServerMap &_rpcsrvmap;
RpcServerManager &_rpcsrvmanager;
RPCHooks(const RPCHooks &); // Not used
RPCHooks &operator=(const RPCHooks &); // Not used
Metrics _cnts;
FNET_Task *_m_reporter;
public:
explicit RPCHooks(SBEnv &env,
RpcServerMap& rpcsrvmap,
RpcServerManager& rpcsrvman);
virtual ~RPCHooks();
void initRPC(FRT_Supervisor *supervisor);
void reportMetrics();
const Metrics& getMetrics() const { return _cnts; }
void countFailedHeartbeat() { _cnts.heartBeatFails++; }
private:
void rpc_lookupRpcServer(FRT_RPCRequest *req);
void rpc_registerRpcServer(FRT_RPCRequest *req);
void rpc_unregisterRpcServer(FRT_RPCRequest *req);
void rpc_addPeer(FRT_RPCRequest *req);
void rpc_removePeer(FRT_RPCRequest *req);
void rpc_listManagedRpcServers(FRT_RPCRequest *req);
void rpc_lookupManaged(FRT_RPCRequest *req);
void rpc_listAllRpcServers(FRT_RPCRequest *req);
void rpc_mirrorFetch(FRT_RPCRequest *req);
void rpc_incrementalFetch(FRT_RPCRequest *req);
void rpc_wantAdd(FRT_RPCRequest *req);
void rpc_doAdd(FRT_RPCRequest *req);
void rpc_doRemove(FRT_RPCRequest *req);
void rpc_forceUnregisterRpcServer(FRT_RPCRequest *req);
void rpc_listNamesServed(FRT_RPCRequest *req);
void rpc_notifyUnregistered(FRT_RPCRequest *req);
void rpc_getRpcServerHistory(FRT_RPCRequest *req);
void rpc_stop(FRT_RPCRequest *req);
void rpc_suspend(FRT_RPCRequest *req);
void rpc_version(FRT_RPCRequest *req);
void rpc_resume(FRT_RPCRequest *req);
};
} // namespace slobrok
|