blob: d98cd88a081847d2205976c7992d15f64b2bfc98 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/fnet/frt/invokable.h>
#include <memory>
class FNET_Task;
class FRT_Supervisor;
namespace slobrok {
class SBEnv;
class RpcServerMap;
class RpcServerManager;
class ServiceMapHistory;
/**
* @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;
unsigned long missingConsensusTime;
static Metrics zero() { return Metrics{0,0,0,0,0,0,0,0,0}; }
};
private:
SBEnv &_env;
ServiceMapHistory &_globalHistory;
ServiceMapHistory &_localHistory;
Metrics _cnts;
std::unique_ptr<FNET_Task> _m_reporter;
public:
RPCHooks(SBEnv &env);
~RPCHooks() override;
void initRPC(FRT_Supervisor *supervisor);
void reportMetrics();
const Metrics& getMetrics() const { return _cnts; }
void countFailedHeartbeat() { _cnts.heartBeatFails++; }
void setConsensusTime(unsigned long value) {
_cnts.missingConsensusTime = value;
}
private:
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_incrementalFetch(FRT_RPCRequest *req);
void rpc_doRemove(FRT_RPCRequest *req);
void rpc_fetchLocalView(FRT_RPCRequest *req);
void rpc_listNamesServed(FRT_RPCRequest *req);
/** for unit tests and debugging, consider removing some of these: */
void rpc_lookupRpcServer(FRT_RPCRequest *req);
void rpc_listManagedRpcServers(FRT_RPCRequest *req);
void rpc_lookupManaged(FRT_RPCRequest *req);
void rpc_listAllRpcServers(FRT_RPCRequest *req);
void rpc_wantAdd(FRT_RPCRequest *req);
void rpc_doAdd(FRT_RPCRequest *req);
/** consider removing: */
void rpc_stop(FRT_RPCRequest *req);
void rpc_version(FRT_RPCRequest *req);
};
} // namespace slobrok
|