Election.ice
Go to the documentation of this file.
1// **********************************************************************
2//
3// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
4//
5// This copy of Ice is licensed to you under the terms described in the
6// ICE_LICENSE file included in this distribution.
7//
8// **********************************************************************
9
10#pragma once
11
12[[ "ice-prefix", "cpp:header-ext:h" ]]
13
14#include <Ice/BuiltinSequences.ice>
15#include <Ice/Identity.ice>
18
19 module IceStormElection
20{
21
22 /** The contents of topic. */
24 {
25 /** The topic identity. */
26 Ice::Identity id;
27 /** The topic subscribers. */
29 }
30
31 /** A sequence of topic content. */
32 sequence<TopicContent>
34
35 /** Thrown if an observer detects an inconsistency. */
37 {
38 /** The reason for the inconsistency. */
39 string reason;
40 }
41
42 /** The replica observer. */
44 {
45 /**
46 *
47 * Initialize the observer.
48 *
49 * @param llu The last log update seen by the master.
50 *
51 * @param content The topic content.
52 *
53 * @throws ObserverInconsistencyException Raised if an
54 * inconsisency was detected.
55 *
56 **/
58
59 /**
60 *
61 * Create the topic with the given name.
62 *
63 * @param llu The log update token.
64 *
65 * @param name The topic name.
66 *
67 * @throws ObserverInconsistencyException Raised if an
68 * inconsisency was detected.
69 *
70 **/
72
73 /**
74 *
75 * Destroy the topic with the given name.
76 *
77 * @param llu The log update token.
78 *
79 * @param name The topic name.
80 *
81 * @throws ObserverInconsistencyException Raised if an
82 * inconsisency was detected.
83 *
84 **/
86
87 /**
88 *
89 * Add a subscriber to a topic.
90 *
91 * @param llu The log update token.
92 *
93 * @param topic The topic name to which to add the subscriber.
94 *
95 * @param record The subscriber information.
96 *
97 * @throws ObserverInconsistencyException Raised if an
98 * inconsisency was detected.
99 *
100 **/
101 void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record)
103
104 /**
105 *
106 * Remove a subscriber from a topic.
107 *
108 * @param llu The log update token.
109 *
110 * @param name The topic name.
111 *
112 * @param subscribers The identities of the subscribers to remove.
113 *
114 * @throws ObserverInconsistencyException Raised if an
115 * inconsisency was detected.
116 *
117 **/
118 void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers)
120 }
121
122 /** Interface used to sync topics. */
124 {
125 /**
126 * Retrieve the topic content.
127 *
128 * @param llu The last log update token.
129 *
130 * @param content The topic content.
131 *
132 **/
133 void getContent(out LogUpdate llu, out TopicContentSeq content);
134 }
135
136 /** The node state. */
138 {
139 /** The node is inactive and awaiting an election. */
141 /** The node is electing a leader. */
143 /** The replica group is reorganizing. */
145 /** The replica group is active & replicating. */
147 }
148
149 /** Forward declaration. */
150 interface Node;
151
152 /** All nodes in the replication group. */
153 struct NodeInfo
154 {
155 /** The identity of the node. */
156 int id;
157 /** The node proxy. */
159 }
160
161 /** A sequence of node info. */
162 sequence<NodeInfo>
164
165 /** The group info. */
167 {
168 /** The identity of the node. */
169 int id;
170 /** The last known log update for this node. */
172 }
173 /** A sequence of group info. */
174 sequence<GroupInfo>
176
178 {
179 /** The node id. */
180 int id;
181
182 /** The nodes coordinator. */
183 int coord;
184
185 /** The nodes group name. */
186 string group;
187
188 /** The replica the node is managing. */
189 Object* replica;
190
191 /** The node state. */
193
194 /** The sequence of nodes in this nodes group. */
196
197 /** The highest priority node that this node has seen. */
198 int max;
199 }
200
201 /** A replica node. */
202 interface Node
203
204 {
205 /**
206 *
207 * Invite the node into a group with the given coordinator and
208 * group name.
209 *
210 * @param gn The group name.
211 *
212 * @param j The group coordinator.
213 *
214 **/
215 void invitation(int j, string gn);
216
217 /**
218 *
219 * Call from the group coordinator to a node to inform the node
220 * that the replica group is active.
221 *
222 * @param j The group coordinator.
223 *
224 * @param gn The group name.
225 *
226 * @param coordinator The proxy to the coordinator.
227 *
228 * @param max The highest priority node seen by this replica
229 * group.
230 *
231 * @param generation The current generation count.
232 */
233 void ready(int j, string gn, Object* coordinator, int max, long generation);
234
235 /**
236 *
237 * Called to accept an invitation into
238 * the given group.
239 *
240 * @param j The id of the node accepting the invitation.
241 *
242 * @param observer The observer.
243 *
244 * @param gn The group name.
245 *
246 * @param forwardedInvites The ids of the nodes to which
247 * invitations were forwarded.
248 *
249 * @param llu The last log update for the given node.
250 *
251 * @param max The highest priority node seen by this replica
252 * group.
253 *
254 **/
255 void accept(int j,
256 string gn,
257 Ice::IntSeq forwardedInvites,
258 Object* observer,
259 LogUpdate llu,
260 int max);
261
262 /**
263 *
264 * Determine if this node is a coordinator.
265 *
266 * @return True if the node is a coordinator, false otherwise.
267 **/
268 ["cpp:const"] idempotent bool areYouCoordinator();
269
270 /**
271 *
272 * Determine if the node is a member of the given group with the
273 * given coordinator.
274 *
275 * @param gn The group name.
276 *
277 * @param j The group coordinator.
278 *
279 * @return True if the node is a member, false otherwise.
280 *
281 **/
282 ["cpp:const"] idempotent bool areYouThere(string gn, int j);
283
284 /**
285 *
286 * Get the sync object for the replica hosted by this node.
287 *
288 * @return The sync object.
289 *
290 **/
291 ["cpp:const"] idempotent Object* sync();
292
293 /**
294 *
295 * Get the replication group information.
296 *
297 * @return The set of configured nodes and the associated
298 * priority.
299 *
300 **/
301 ["cpp:const"] idempotent NodeInfoSeq nodes();
302
303 /**
304 *
305 * Get the query information for the given node.
306 *
307 * @return The query information.
308 *
309 **/
310 ["cpp:const"] idempotent QueryInfo query();
311 }
312}
Thrown if an observer detects an inconsistency.
Definition Election.ice:37
string reason
The reason for the inconsistency.
Definition Election.ice:39
T max(T t1, T t2)
Definition gdiam.h:51
A replica node.
Definition Election.ice:204
idempotent Object * sync()
Get the sync object for the replica hosted by this node.
idempotent QueryInfo query()
Get the query information for the given node.
idempotent NodeInfoSeq nodes()
Get the replication group information.
void invitation(int j, string gn)
Invite the node into a group with the given coordinator and group name.
void ready(int j, string gn, Object *coordinator, int max, long generation)
Call from the group coordinator to a node to inform the node that the replica group is active.
void accept(int j, string gn, Ice::IntSeq forwardedInvites, Object *observer, LogUpdate llu, int max)
Called to accept an invitation into the given group.
idempotent bool areYouThere(string gn, int j)
Determine if the node is a member of the given group with the given coordinator.
idempotent bool areYouCoordinator()
Determine if this node is a coordinator.
The replica observer.
Definition Election.ice:44
void destroyTopic(LogUpdate llu, string name)
Destroy the topic with the given name.
void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers)
Remove a subscriber from a topic.
void init(LogUpdate llu, TopicContentSeq content)
Initialize the observer.
void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record)
Add a subscriber to a topic.
void createTopic(LogUpdate llu, string name)
Create the topic with the given name.
Interface used to sync topics.
Definition Election.ice:124
void getContent(out LogUpdate llu, out TopicContentSeq content)
Retrieve the topic content.
::std::vector<::IceStormElection::GroupInfo > GroupInfoSeq
A sequence of group info.
Definition Election.h:1340
NodeState
The node state.
Definition Election.ice:138
@ NodeStateElection
The node is electing a leader.
Definition Election.ice:142
@ NodeStateNormal
The replica group is active & replicating.
Definition Election.ice:146
@ NodeStateInactive
The node is inactive and awaiting an election.
Definition Election.ice:140
@ NodeStateReorganization
The replica group is reorganizing.
Definition Election.ice:144
::std::vector<::IceStormElection::NodeInfo > NodeInfoSeq
A sequence of node info.
Definition Election.h:1264
::std::vector<::IceStormElection::TopicContent > TopicContentSeq
A sequence of topic content.
Definition Election.h:1225
::std::vector<::IceStorm::SubscriberRecord > SubscriberRecordSeq
LogUpdate llu
The last known log update for this node.
Definition Election.ice:171
int id
The identity of the node.
Definition Election.ice:169
A struct used for marking the last log update.
Definition LLURecord.h:103
All nodes in the replication group.
Definition Election.ice:154
Node * n
The node proxy.
Definition Election.ice:158
int id
The identity of the node.
Definition Election.ice:156
NodeState state
The node state.
Definition Election.ice:192
Object * replica
The replica the node is managing.
Definition Election.ice:189
string group
The nodes group name.
Definition Election.ice:186
GroupInfoSeq up
The sequence of nodes in this nodes group.
Definition Election.ice:195
int coord
The nodes coordinator.
Definition Election.ice:183
int max
The highest priority node that this node has seen.
Definition Election.ice:198
The contents of topic.
Definition Election.ice:24
IceStorm::SubscriberRecordSeq records
The topic subscribers.
Definition Election.ice:28
Ice::Identity id
The topic identity.
Definition Election.ice:26
Used to store persistent information for persistent subscribers.