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>
16 #include <IceStorm/LLURecord.ice>
18 
19  module IceStormElection
20 {
21 
22  /** The contents of topic. */
23  struct TopicContent
24  {
25  /** The topic identity. */
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. */
43  interface ReplicaObserver
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  **/
57  void init(LogUpdate llu, TopicContentSeq content) throws ObserverInconsistencyException;
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  **/
71  void createTopic(LogUpdate llu, string name) throws ObserverInconsistencyException;
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  **/
85  void destroyTopic(LogUpdate llu, string name) throws ObserverInconsistencyException;
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. */
158  Node* n;
159  }
160 
161  /** A sequence of node info. */
162  sequence<NodeInfo>
163  NodeInfoSeq;
164 
165  /** The group info. */
166  struct GroupInfo
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>
175  GroupInfoSeq;
176 
177  struct QueryInfo
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 }
IceStorm::SubscriberRecordSeq
::std::vector<::IceStorm::SubscriberRecord > SubscriberRecordSeq
Definition: SubscriberRecord.h:244
IceStormElection::TopicManagerSync
Interface used to sync topics.
Definition: Election.ice:123
IceStormElection::QueryInfo::coord
int coord
The nodes coordinator.
Definition: Election.ice:183
IceStormElection::GroupInfo::llu
LogUpdate llu
The last known log update for this node.
Definition: Election.ice:171
IceStormElection::QueryInfo
Definition: Election.ice:177
IceStormElection::QueryInfo::up
GroupInfoSeq up
The sequence of nodes in this nodes group.
Definition: Election.ice:195
IceStormElection::LogUpdate
A struct used for marking the last log update.
Definition: LLURecord.h:102
IceStormElection::NodeStateElection
@ NodeStateElection
The node is electing a leader.
Definition: Election.ice:142
IceStormElection::ReplicaObserver
The replica observer.
Definition: Election.ice:43
IceStormElection::NodeInfo::n
Node * n
The node proxy.
Definition: Election.ice:158
IceStormElection::QueryInfo::id
int id
The node id.
Definition: Election.ice:180
IceStormElection::ObserverInconsistencyException
Thrown if an observer detects an inconsistency.
Definition: Election.ice:36
IceStorm::SubscriberRecord
Used to store persistent information for persistent subscribers.
Definition: SubscriberRecord.h:233
IceStormElection::ObserverInconsistencyException::reason
string reason
The reason for the inconsistency.
Definition: Election.ice:39
IceStormElection::TopicContentSeq
::std::vector<::IceStormElection::TopicContent > TopicContentSeq
A sequence of topic content.
Definition: Election.h:1225
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
IceStormElection::TopicContent::id
Ice::Identity id
The topic identity.
Definition: Election.ice:26
IceStormElection::NodeStateInactive
@ NodeStateInactive
The node is inactive and awaiting an election.
Definition: Election.ice:140
IceStormElection::TopicContent
The contents of topic.
Definition: Election.ice:23
IceStormElection::Node
A replica node.
Definition: Election.ice:202
IceStormElection::QueryInfo::max
int max
The highest priority node that this node has seen.
Definition: Election.ice:198
IceStormElection::NodeState
NodeState
The node state.
Definition: Election.ice:137
IceStormElection
Definition: DBTypes.ice:17
IceStormElection::GroupInfoSeq
::std::vector<::IceStormElection::GroupInfo > GroupInfoSeq
A sequence of group info.
Definition: Election.h:1340
IceStormElection::QueryInfo::group
string group
The nodes group name.
Definition: Election.ice:186
IceStormElection::GroupInfo
The group info.
Definition: Election.ice:166
IceStormElection::NodeInfo
All nodes in the replication group.
Definition: Election.ice:153
IceStormElection::NodeStateReorganization
@ NodeStateReorganization
The replica group is reorganizing.
Definition: Election.ice:144
max
T max(T t1, T t2)
Definition: gdiam.h:51
IceStormElection::NodeStateNormal
@ NodeStateNormal
The replica group is active & replicating.
Definition: Election.ice:146
LLURecord.ice
IceStormElection::NodeInfo::id
int id
The identity of the node.
Definition: Election.ice:156
SubscriberRecord.ice
IceStormElection::QueryInfo::state
NodeState state
The node state.
Definition: Election.ice:192
IceStormElection::NodeInfoSeq
::std::vector<::IceStormElection::NodeInfo > NodeInfoSeq
A sequence of node info.
Definition: Election.h:1264
IceStormElection::GroupInfo::id
int id
The identity of the node.
Definition: Election.ice:169
IceStormElection::QueryInfo::replica
Object * replica
The replica the node is managing.
Definition: Election.ice:189
IceStormElection::TopicContent::records
IceStorm::SubscriberRecordSeq records
The topic subscribers.
Definition: Election.ice:28