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

Comparing AnyEvent-MP/MP/Intro.pod (file contents):
Revision 1.43 by root, Thu Mar 11 19:20:47 2010 UTC vs.
Revision 1.44 by root, Tue Feb 28 18:37:24 2012 UTC

251have a few database backends, a few web front-ends and some processing 251have a few database backends, a few web front-ends and some processing
252distributed over a number of hosts: all of these would simply register 252distributed over a number of hosts: all of these would simply register
253themselves in the appropriate group, and your web front-ends can start to 253themselves in the appropriate group, and your web front-ends can start to
254find some database backend. 254find some database backend.
255 255
256=head3 C<configure> and the Network 256=head3 C<configure> and Joining and Maintaining the Network
257 257
258Now, let's have a look at the new function, C<configure>: 258Now, let's have a look at the new function, C<configure>:
259 259
260 configure nodeid => "eg_receiver", binds => ["*:4040"]; 260 configure nodeid => "eg_receiver", binds => ["*:4040"];
261 261
277any string - if you don't care, you can specify a node ID of C<anon/> 277any string - if you don't care, you can specify a node ID of C<anon/>
278which will then be replaced by a random node name. 278which will then be replaced by a random node name.
279 279
280The second parameter, C<binds>, specifies a list of C<address:port> pairs 280The second parameter, C<binds>, specifies a list of C<address:port> pairs
281to bind TCP listeners on. The special "address" of C<*> means to bind on 281to bind TCP listeners on. The special "address" of C<*> means to bind on
282every local IP address. 282every local IP address (this might not work on every OS, so it should not
283be used unless you know it works).
283 284
284The reason to bind on a TCP port is not just that other nodes can connect 285The reason to bind on a TCP port is not just that other nodes can connect
285to us: if no binds are specified, the node will still bind on a dynamic 286to us: if no binds are specified, the node will still bind on a dynamic
286port on all local addresses - but in this case we won't know the port, and 287port on all local addresses - but in this case we won't know the port, and
287cannot tell other nodes to connect to it as seed node. 288cannot tell other nodes to connect to it as seed node.
323 N3--N4--- | 324 N3--N4--- |
324 \________/ 325 \________/
325 326
326All done: C<N5> is now happily connected to the rest of the network. 327All done: C<N5> is now happily connected to the rest of the network.
327 328
328Of course, this process takes time, during which the node is already 329Apart form the obvious function - joining the network - seed nodes fulfill
330another very important function: the connections created by connecting
331to seed nodes are used to keep the network together - by trying to keep
332connections to all seed nodes active, the network ensures that it will not
333split into multiple networks without connection to each other.
334
335This means that the graph created by all seed node connections must span
336the whole network, in some way.
337
338There are many ways of doing this - the most simple is probably to use
339a single set of one or more seednodes as seednodes for all nodes in the
340network - this creates a "hub" of seednodes that connect to each other,
341and "leaf" nodes that connect to the nodes in the hub, keeping everything
342together.
343
344The process of joining a network takes time, during which the node is
329running. This also means it takes time until the node is fully connected, 345already running. This also means it takes time until the node is fully
330and global groups and other information is available. The best way to deal 346connected, and global groups and other information is available. The best
331with this is to either retry regularly until you found the resource you 347way to deal with this is to either retry regularly until you found the
332were looking for, or to only start services on demand after a node has 348resource you were looking for, or to only start services on demand after a
333become available. 349node has become available.
334 350
335=head3 Registering the Receiver 351=head3 Registering the Receiver
336 352
337Coming back to our example, we have now introduced the basic purpose of 353Coming back to our example, we have now introduced the basic purpose of
338L<AnyEvent::MP::Global> and C<configure> and its use of profiles. We 354L<AnyEvent::MP::Global> and C<configure> and its use of profiles. We

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines