-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsm_protocol.h
113 lines (94 loc) · 1.82 KB
/
rsm_protocol.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef rsm_protocol_h
#define rsm_protocol_h
#include "rpc.h"
class rsm_client_protocol {
public:
enum xxstatus { OK, ERR, NOTPRIMARY, BUSY};
typedef int status;
enum rpc_numbers {
invoke = 0x9001,
members,
};
};
struct viewstamp {
viewstamp (unsigned int _vid = 0, unsigned int _seqno = 0) {
vid = _vid;
seqno = _seqno;
};
unsigned int vid;
unsigned int seqno;
};
class rsm_protocol {
public:
enum xxstatus { OK, ERR, BUSY};
typedef int status;
enum rpc_numbers {
invoke = 0x10001,
transferreq,
transferdonereq,
joinreq,
};
struct transferres {
std::string state;
viewstamp last;
};
struct joinres {
std::string log;
};
};
inline bool operator==(viewstamp a, viewstamp b) {
return a.vid == b.vid && a.seqno == b.seqno;
}
inline bool operator>(viewstamp a, viewstamp b) {
return (a.vid > b.vid) || ((a.vid == b.vid) && a.seqno > b.seqno);
}
inline bool operator!=(viewstamp a, viewstamp b) {
return a.vid != b.vid || a.seqno != b.seqno;
}
inline marshall& operator<<(marshall &m, viewstamp v)
{
m << v.vid;
m << v.seqno;
return m;
}
inline unmarshall& operator>>(unmarshall &u, viewstamp &v) {
u >> v.vid;
u >> v.seqno;
return u;
}
inline marshall &
operator<<(marshall &m, rsm_protocol::transferres r)
{
m << r.state;
m << r.last;
return m;
}
inline unmarshall &
operator>>(unmarshall &u, rsm_protocol::transferres &r)
{
u >> r.state;
u >> r.last;
return u;
}
inline marshall &
operator<<(marshall &m, rsm_protocol::joinres r)
{
m << r.log;
return m;
}
inline unmarshall &
operator>>(unmarshall &u, rsm_protocol::joinres &r)
{
u >> r.log;
return u;
}
class rsm_test_protocol {
public:
enum xxstatus { OK, ERR};
typedef int status;
enum rpc_numbers {
net_repair = 0x12001,
breakpoint = 0x12002,
};
};
#endif