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/Identity.ice>
15 #include <Ice/BuiltinSequences.ice>
17 #include <IceStorm/LLURecord.ice>
18 
19 module IceStormElection
20 {
21 
22 /** The contents of topic. */
24 {
25  /** The topic identity. */
27  /** The topic subscribers. */
29 }
30 
31 /** A sequence of topic content. */
32 sequence<TopicContent> TopicContentSeq;
33 
34 /** Thrown if an observer detects an inconsistency. */
36 {
37  /** The reason for the inconsistency. */
38  string reason;
39 }
40 
41 /** The replica observer. */
42 interface ReplicaObserver
43 {
44  /**
45  *
46  * Initialize the observer.
47  *
48  * @param llu The last log update seen by the master.
49  *
50  * @param content The topic content.
51  *
52  * @throws ObserverInconsistencyException Raised if an
53  * inconsisency was detected.
54  *
55  **/
56  void init(LogUpdate llu, TopicContentSeq content)
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)
73 
74  /**
75  *
76  * Destroy the topic with the given name.
77  *
78  * @param llu The log update token.
79  *
80  * @param name The topic name.
81  *
82  * @throws ObserverInconsistencyException Raised if an
83  * inconsisency was detected.
84  *
85  **/
86  void destroyTopic(LogUpdate llu, string name)
88 
89  /**
90  *
91  * Add a subscriber to a topic.
92  *
93  * @param llu The log update token.
94  *
95  * @param topic The topic name to which to add the subscriber.
96  *
97  * @param record The subscriber information.
98  *
99  * @throws ObserverInconsistencyException Raised if an
100  * inconsisency was detected.
101  *
102  **/
103  void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record)
105 
106  /**
107  *
108  * Remove a subscriber from a topic.
109  *
110  * @param llu The log update token.
111  *
112  * @param name The topic name.
113  *
114  * @param subscribers The identities of the subscribers to remove.
115  *
116  * @throws ObserverInconsistencyException Raised if an
117  * inconsisency was detected.
118  *
119  **/
120  void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers)
122 }
123 
124 /** Interface used to sync topics. */
126 {
127  /**
128  * Retrieve the topic content.
129  *
130  * @param llu The last log update token.
131  *
132  * @param content The topic content.
133  *
134  **/
135  void getContent(out LogUpdate llu, out TopicContentSeq content);
136 }
137 
138 /** The node state. */
140 {
141  /** The node is inactive and awaiting an election. */
143  /** The node is electing a leader. */
145  /** The replica group is reorganizing. */
147  /** The replica group is active & replicating. */
149 }
150 
151 /** Forward declaration. */
152 interface Node;
153 
154 /** All nodes in the replication group. */
155 struct NodeInfo
156 {
157  /** The identity of the node. */
158  int id;
159  /** The node proxy. */
160  Node* n;
161 }
162 
163 /** A sequence of node info. */
164 sequence<NodeInfo> NodeInfoSeq;
165 
166 /** The group info. */
167 struct GroupInfo
168 {
169  /** The identity of the node. */
170  int id;
171  /** The last known log update for this node. */
173 }
174 /** A sequence of group info. */
175 sequence<GroupInfo> 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  * Invite the node into a group with the given coordinator and
207  * group name.
208  *
209  * @param gn The group name.
210  *
211  * @param j The group coordinator.
212  *
213  **/
214  void invitation(int j, string gn);
215 
216  /**
217  *
218  * Call from the group coordinator to a node to inform the node
219  * that the replica group is active.
220  *
221  * @param j The group coordinator.
222  *
223  * @param gn The group name.
224  *
225  * @param coordinator The proxy to the coordinator.
226  *
227  * @param max The highest priority node seen by this replica
228  * group.
229  *
230  * @param generation The current generation count.
231  */
232  void ready(int j, string gn, Object* coordinator, int max, long generation);
233 
234  /**
235  *
236  * Called to accept an invitation into
237  * the given group.
238  *
239  * @param j The id of the node accepting the invitation.
240  *
241  * @param observer The observer.
242  *
243  * @param gn The group name.
244  *
245  * @param forwardedInvites The ids of the nodes to which
246  * invitations were forwarded.
247  *
248  * @param llu The last log update for the given node.
249  *
250  * @param max The highest priority node seen by this replica
251  * group.
252  *
253  **/
254  void accept(int j, string gn, Ice::IntSeq forwardedInvites, Object* observer, LogUpdate llu, int max);
255 
256  /**
257  *
258  * Determine if this node is a coordinator.
259  *
260  * @return True if the node is a coordinator, false otherwise.
261  **/
262  ["cpp:const"] idempotent bool areYouCoordinator();
263 
264  /**
265  *
266  * Determine if the node is a member of the given group with the
267  * given coordinator.
268  *
269  * @param gn The group name.
270  *
271  * @param j The group coordinator.
272  *
273  * @return True if the node is a member, false otherwise.
274  *
275  **/
276  ["cpp:const"] idempotent bool areYouThere(string gn, int j);
277 
278  /**
279  *
280  * Get the sync object for the replica hosted by this node.
281  *
282  * @return The sync object.
283  *
284  **/
285  ["cpp:const"] idempotent Object* sync();
286 
287  /**
288  *
289  * Get the replication group information.
290  *
291  * @return The set of configured nodes and the associated
292  * priority.
293  *
294  **/
295  ["cpp:const"] idempotent NodeInfoSeq nodes();
296 
297  /**
298  *
299  * Get the query information for the given node.
300  *
301  * @return The query information.
302  *
303  **/
304  ["cpp:const"] idempotent QueryInfo query();
305 }
306 
307 }
IceStorm::SubscriberRecordSeq
::std::vector< ::IceStorm::SubscriberRecord > SubscriberRecordSeq
Definition: SubscriberRecord.h:225
IceStormElection::TopicManagerSync
Interface used to sync topics.
Definition: Election.ice:125
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:172
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:100
IceStormElection::NodeStateElection
@ NodeStateElection
The node is electing a leader.
Definition: Election.ice:144
IceStormElection::ReplicaObserver
The replica observer.
Definition: Election.ice:42
IceStormElection::NodeInfo::n
Node * n
The node proxy.
Definition: Election.ice:160
IceStormElection::QueryInfo::id
int id
The node id.
Definition: Election.ice:180
IceStormElection::ObserverInconsistencyException
Thrown if an observer detects an inconsistency.
Definition: Election.ice:35
IceStorm::SubscriberRecord
Used to store persistent information for persistent subscribers.
Definition: SubscriberRecord.h:214
IceStormElection::ObserverInconsistencyException::reason
string reason
The reason for the inconsistency.
Definition: Election.ice:38
IceStormElection::TopicContentSeq
::std::vector< ::IceStormElection::TopicContent > TopicContentSeq
A sequence of topic content.
Definition: Election.h:819
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
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:142
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:139
IceStormElection
Definition: DBTypes.ice:17
IceStormElection::GroupInfoSeq
::std::vector< ::IceStormElection::GroupInfo > GroupInfoSeq
A sequence of group info.
Definition: Election.h:924
IceStormElection::QueryInfo::group
string group
The nodes group name.
Definition: Election.ice:186
IceStormElection::GroupInfo
The group info.
Definition: Election.ice:167
IceStormElection::NodeInfo
All nodes in the replication group.
Definition: Election.ice:155
IceStormElection::NodeStateReorganization
@ NodeStateReorganization
The replica group is reorganizing.
Definition: Election.ice:146
max
T max(T t1, T t2)
Definition: gdiam.h:48
IceStormElection::NodeStateNormal
@ NodeStateNormal
The replica group is active & replicating.
Definition: Election.ice:148
LLURecord.ice
IceStormElection::NodeInfo::id
int id
The identity of the node.
Definition: Election.ice:158
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:857
IceStormElection::GroupInfo::id
int id
The identity of the node.
Definition: Election.ice:170
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