ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP.pm
(Generate patch)

Comparing AnyEvent-MP/MP.pm (file contents):
Revision 1.48 by root, Thu Aug 13 02:59:42 2009 UTC vs.
Revision 1.49 by root, Thu Aug 13 15:29:58 2009 UTC

168it should know the noderefs of some other nodes in the network. 168it should know the noderefs of some other nodes in the network.
169 169
170This function initialises a node - it must be called exactly once (or 170This function initialises a node - it must be called exactly once (or
171never) before calling other AnyEvent::MP functions. 171never) before calling other AnyEvent::MP functions.
172 172
173All arguments are noderefs, which can be either resolved or unresolved. 173All arguments (optionally except for the first) are noderefs, which can be
174either resolved or unresolved.
175
176The first argument will be looked up in the configuration database first
177(if it is C<undef> then the current nodename will be used instead) to find
178the relevant configuration profile (see L<aemp>). If none is found then
179the default configuration is used. The configuration supplies additional
180seed/master nodes and can override the actual noderef.
174 181
175There are two types of networked nodes, public nodes and slave nodes: 182There are two types of networked nodes, public nodes and slave nodes:
176 183
177=over 4 184=over 4
178 185
179=item public nodes 186=item public nodes
180 187
181For public nodes, C<$noderef> must either be a (possibly unresolved) 188For public nodes, C<$noderef> (supplied either directly to
182noderef, in which case it will be resolved, or C<undef> (or missing), in 189C<initialise_node> or indirectly via a profile or the nodename) must be a
183which case the noderef will be guessed. 190noderef (possibly unresolved, in which case it will be resolved).
184 191
185Afterwards, the node will bind itself on all endpoints and try to connect 192After resolving, the node will bind itself on all endpoints and try to
186to all additional C<$seednodes> that are specified. Seednodes are optional 193connect to all additional C<$seednodes> that are specified. Seednodes are
187and can be used to quickly bootstrap the node into an existing network. 194optional and can be used to quickly bootstrap the node into an existing
195network.
188 196
189=item slave nodes 197=item slave nodes
190 198
191When the C<$noderef> is the special string C<slave/>, then the node will 199When the C<$noderef> (either as given or overriden by the config file)
200is the special string C<slave/>, then the node will become a slave
192become a slave node. Slave nodes cannot be contacted from outside and will 201node. Slave nodes cannot be contacted from outside and will route most of
193route most of their traffic to the master node that they attach to. 202their traffic to the master node that they attach to.
194 203
195At least one additional noderef is required: The node will try to connect 204At least one additional noderef is required (either by specifying it
196to all of them and will become a slave attached to the first node it can 205directly or because it is part of the configuration profile): The node
197successfully connect to. 206will try to connect to all of them and will become a slave attached to the
207first node it can successfully connect to.
198 208
199=back 209=back
200 210
201This function will block until all nodes have been resolved and, for slave 211This function will block until all nodes have been resolved and, for slave
202nodes, until it has successfully established a connection to a master 212nodes, until it has successfully established a connection to a master
203server. 213server.
204 214
205Example: become a public node listening on the default node. 215Example: become a public node listening on the guessed noderef, or the one
216specified via C<aemp> for the current node. This should be the most common
217form of invocation for "daemon"-type nodes.
206 218
207 initialise_node; 219 initialise_node;
220
221Example: become a slave node to any of the the seednodes specified via
222C<aemp>. This form is often used for commandline clients.
223
224 initialise_node "slave/";
225
226Example: become a slave node to any of the specified master servers. This
227form is also often used for commandline clients.
228
229 initialise_node "slave/", "master1", "192.168.13.17", "mp.example.net";
208 230
209Example: become a public node, and try to contact some well-known master 231Example: become a public node, and try to contact some well-known master
210servers to become part of the network. 232servers to become part of the network.
211 233
212 initialise_node undef, "master1", "master2"; 234 initialise_node undef, "master1", "master2";
215 237
216 initialise_node 4041; 238 initialise_node 4041;
217 239
218Example: become a public node, only visible on localhost port 4044. 240Example: become a public node, only visible on localhost port 4044.
219 241
220 initialise_node "locahost:4044"; 242 initialise_node "localhost:4044";
221
222Example: become a slave node to any of the specified master servers.
223
224 initialise_node "slave/", "master1", "192.168.13.17", "mp.example.net";
225 243
226=item $cv = resolve_node $noderef 244=item $cv = resolve_node $noderef
227 245
228Takes an unresolved node reference that may contain hostnames and 246Takes an unresolved node reference that may contain hostnames and
229abbreviated IDs, resolves all of them and returns a resolved node 247abbreviated IDs, resolves all of them and returns a resolved node

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines