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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#pragma once
[["ice-prefix", "cpp:header-ext:h"]]
#include <Ice/Identity.ice>
#include <Ice/BuiltinSequences.ice>
#include <IceStorm/SubscriberRecord.ice>
#include <IceStorm/LLURecord.ice>
module IceStormElection
{
/** The contents of topic. */
struct TopicContent
{
/** The topic identity. */
Ice::Identity id;
/** The topic subscribers. */
IceStorm::SubscriberRecordSeq records;
};
/** A sequence of topic content. */
sequence<TopicContent> TopicContentSeq;
/** Thrown if an observer detects an inconsistency. */
exception ObserverInconsistencyException
{
/** The reason for the inconsistency. */
string reason;
};
/** The replica observer. */
interface ReplicaObserver
{
/**
*
* Initialize the observer.
*
* @param llu The last log update seen by the master.
*
* @param content The topic content.
*
* @throws ObserverInconsistencyException Raised if an
* inconsisency was detected.
*
**/
void init(LogUpdate llu, TopicContentSeq content)
throws ObserverInconsistencyException;
/**
*
* Create the topic with the given name.
*
* @param llu The log update token.
*
* @param name The topic name.
*
* @throws ObserverInconsistencyException Raised if an
* inconsisency was detected.
*
**/
void createTopic(LogUpdate llu, string name)
throws ObserverInconsistencyException;
/**
*
* Destroy the topic with the given name.
*
* @param llu The log update token.
*
* @param name The topic name.
*
* @throws ObserverInconsistencyException Raised if an
* inconsisency was detected.
*
**/
void destroyTopic(LogUpdate llu, string name)
throws ObserverInconsistencyException;
/**
*
* Add a subscriber to a topic.
*
* @param llu The log update token.
*
* @param topic The topic name to which to add the subscriber.
*
* @param record The subscriber information.
*
* @throws ObserverInconsistencyException Raised if an
* inconsisency was detected.
*
**/
void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record)
throws ObserverInconsistencyException;
/**
*
* Remove a subscriber from a topic.
*
* @param llu The log update token.
*
* @param name The topic name.
*
* @param subscribers The identities of the subscribers to remove.
*
* @throws ObserverInconsistencyException Raised if an
* inconsisency was detected.
*
**/
void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers)
throws ObserverInconsistencyException;
};
/** Interface used to sync topics. */
interface TopicManagerSync
{
/**
* Retrieve the topic content.
*
* @param llu The last log update token.
*
* @param content The topic content.
*
**/
void getContent(out LogUpdate llu, out TopicContentSeq content);
};
/** The node state. */
enum NodeState
{
/** The node is inactive and awaiting an election. */
NodeStateInactive,
/** The node is electing a leader. */
NodeStateElection,
/** The replica group is reorganizing. */
NodeStateReorganization,
/** The replica group is active & replicating. */
NodeStateNormal
};
/** Forward declaration. */
interface Node;
/** All nodes in the replication group. */
struct NodeInfo
{
/** The identity of the node. */
int id;
/** The node proxy. */
Node* n;
};
/** A sequence of node info. */
sequence<NodeInfo> NodeInfoSeq;
/** The group info. */
struct GroupInfo
{
/** The identity of the node. */
int id;
/** The last known log update for this node. */
LogUpdate llu;
};
/** A sequence of group info. */
sequence<GroupInfo> GroupInfoSeq;
struct QueryInfo
{
/** The node id. */
int id;
/** The nodes coordinator. */
int coord;
/** The nodes group name. */
string group;
/** The replica the node is managing. */
Object* replica;
/** The node state. */
NodeState state;
/** The sequence of nodes in this nodes group. */
GroupInfoSeq up;
/** The highest priority node that this node has seen. */
int max;
};
/** A replica node. */
interface Node
{
/**
*
* Invite the node into a group with the given coordinator and
* group name.
*
* @param gn The group name.
*
* @param j The group coordinator.
*
**/
void invitation(int j, string gn);
/**
*
* Call from the group coordinator to a node to inform the node
* that the replica group is active.
*
* @param j The group coordinator.
*
* @param gn The group name.
*
* @param coordinator The proxy to the coordinator.
*
* @param max The highest priority node seen by this replica
* group.
*
* @param generation The current generation count.
*/
void ready(int j, string gn, Object* coordinator, int max, long generation);
/**
*
* Called to accept an invitation into
* the given group.
*
* @param j The id of the node accepting the invitation.
*
* @param observer The observer.
*
* @param gn The group name.
*
* @param forwardedInvites The ids of the nodes to which
* invitations were forwarded.
*
* @param llu The last log update for the given node.
*
* @param max The highest priority node seen by this replica
* group.
*
**/
void accept(int j, string gn, Ice::IntSeq forwardedInvites, Object* observer, LogUpdate llu, int max);
/**
*
* Determine if this node is a coordinator.
*
* @return True if the node is a coordinator, false otherwise.
**/
["cpp:const"] idempotent bool areYouCoordinator();
/**
*
* Determine if the node is a member of the given group with the
* given coordinator.
*
* @param gn The group name.
*
* @param j The group coordinator.
*
* @return True if the node is a member, false otherwise.
*
**/
["cpp:const"] idempotent bool areYouThere(string gn, int j);
/**
*
* Get the sync object for the replica hosted by this node.
*
* @return The sync object.
*
**/
["cpp:const"] idempotent Object* sync();
/**
*
* Get the replication group information.
*
* @return The set of configured nodes and the associated
* priority.
*
**/
["cpp:const"] idempotent NodeInfoSeq nodes();
/**
*
* Get the query information for the given node.
*
* @return The query information.
*
**/
["cpp:const"] idempotent QueryInfo query();
};
};
|