… | |
… | |
85 | |
85 | |
86 | A node is a single process containing at least one port - the node port, |
86 | A node is a single process containing at least one port - the node port, |
87 | which provides nodes to manage each other remotely, and to create new |
87 | which provides nodes to manage each other remotely, and to create new |
88 | ports. |
88 | ports. |
89 | |
89 | |
90 | Nodes are either private (single-process only), slaves (connected to a |
90 | Nodes are either private (single-process only), slaves (can only talk to |
91 | master node only) or public nodes (connectable from unrelated nodes). |
91 | public nodes, but do not need an open port) or public nodes (connectable |
|
|
92 | from any other node). |
92 | |
93 | |
93 | =item noderef - C<host:port,host:port...>, C<id@noderef>, C<id> |
94 | =item noderef - C<host:port,host:port...>, C<id@noderef>, C<id> |
94 | |
95 | |
95 | A node reference is a string that either simply identifies the node (for |
96 | A node reference is a string that either simply identifies the node (for |
96 | private and slave nodes), or contains a recipe on how to reach a given |
97 | private and slave nodes), or contains a recipe on how to reach a given |
… | |
… | |
128 | our $VERSION = $AnyEvent::MP::Kernel::VERSION; |
129 | our $VERSION = $AnyEvent::MP::Kernel::VERSION; |
129 | |
130 | |
130 | our @EXPORT = qw( |
131 | our @EXPORT = qw( |
131 | NODE $NODE *SELF node_of after |
132 | NODE $NODE *SELF node_of after |
132 | resolve_node initialise_node |
133 | resolve_node initialise_node |
133 | snd rcv mon kil reg psub spawn |
134 | snd rcv mon mon_guard kil reg psub spawn |
134 | port |
135 | port |
135 | ); |
136 | ); |
136 | |
137 | |
137 | our $SELF; |
138 | our $SELF; |
138 | |
139 | |
… | |
… | |
180 | |
181 | |
181 | For public nodes, C<$noderef> (supplied either directly to |
182 | For public nodes, C<$noderef> (supplied either directly to |
182 | C<initialise_node> or indirectly via a profile or the nodename) must be a |
183 | C<initialise_node> or indirectly via a profile or the nodename) must be a |
183 | noderef (possibly unresolved, in which case it will be resolved). |
184 | noderef (possibly unresolved, in which case it will be resolved). |
184 | |
185 | |
185 | After resolving, the node will bind itself on all endpoints and try to |
186 | After resolving, the node will bind itself on all endpoints. |
186 | connect to all additional C<$seednodes> that are specified. Seednodes are |
187 | |
|
|
188 | =item slave nodes |
|
|
189 | |
|
|
190 | When the C<$noderef> (either as given or overriden by the config file) |
|
|
191 | is the special string C<slave/>, then the node will become a slave |
|
|
192 | node. Slave nodes cannot be contacted from outside, and cannot talk to |
|
|
193 | each other (at least in this version of AnyEvent::MP). |
|
|
194 | |
|
|
195 | Slave nodes work by creating connections to all public nodes, using the |
|
|
196 | L<AnyEvent::MP::Global> service. |
|
|
197 | |
|
|
198 | =back |
|
|
199 | |
|
|
200 | After initialising itself, the node will connect to all additional |
|
|
201 | C<$seednodes> that are specified diretcly or via a profile. Seednodes are |
187 | optional and can be used to quickly bootstrap the node into an existing |
202 | optional and can be used to quickly bootstrap the node into an existing |
188 | network. |
203 | network. |
189 | |
204 | |
190 | =item slave nodes |
|
|
191 | |
|
|
192 | When the C<$noderef> (either as given or overriden by the config file) |
|
|
193 | is the special string C<slave/>, then the node will become a slave |
|
|
194 | node. Slave nodes cannot be contacted from outside and will route most of |
|
|
195 | their traffic to the master node that they attach to. |
|
|
196 | |
|
|
197 | At least one additional noderef is required (either by specifying it |
|
|
198 | directly or because it is part of the configuration profile): The node |
|
|
199 | will try to connect to all of them and will become a slave attached to the |
|
|
200 | first node it can successfully connect to. |
|
|
201 | |
|
|
202 | Note that slave nodes cannot change their name, and consequently, their |
|
|
203 | master, so if the master goes down, the slave node will not function well |
|
|
204 | anymore until it can re-establish conenciton to its master. This makes |
|
|
205 | slave nodes unsuitable for long-term nodes or fault-tolerant networks. |
|
|
206 | |
|
|
207 | =back |
|
|
208 | |
|
|
209 | This function will block until all nodes have been resolved and, for slave |
|
|
210 | nodes, until it has successfully established a connection to a master |
|
|
211 | server. |
|
|
212 | |
|
|
213 | All the seednodes will also be specially marked to automatically retry |
205 | All the seednodes will also be specially marked to automatically retry |
214 | connecting to them infinitely. |
206 | connecting to them indefinitely, so make sure that seednodes are really |
|
|
207 | reliable and up (this might also change in the future). |
215 | |
208 | |
216 | Example: become a public node listening on the guessed noderef, or the one |
209 | Example: become a public node listening on the guessed noderef, or the one |
217 | specified via C<aemp> for the current node. This should be the most common |
210 | specified via C<aemp> for the current node. This should be the most common |
218 | form of invocation for "daemon"-type nodes. |
211 | form of invocation for "daemon"-type nodes. |
219 | |
212 | |
… | |
… | |
221 | |
214 | |
222 | Example: become a slave node to any of the the seednodes specified via |
215 | Example: become a slave node to any of the the seednodes specified via |
223 | C<aemp>. This form is often used for commandline clients. |
216 | C<aemp>. This form is often used for commandline clients. |
224 | |
217 | |
225 | initialise_node "slave/"; |
218 | initialise_node "slave/"; |
226 | |
|
|
227 | Example: become a slave node to any of the specified master servers. This |
|
|
228 | form is also often used for commandline clients. |
|
|
229 | |
|
|
230 | initialise_node "slave/", "master1", "192.168.13.17", "mp.example.net"; |
|
|
231 | |
219 | |
232 | Example: become a public node, and try to contact some well-known master |
220 | Example: become a public node, and try to contact some well-known master |
233 | servers to become part of the network. |
221 | servers to become part of the network. |
234 | |
222 | |
235 | initialise_node undef, "master1", "master2"; |
223 | initialise_node undef, "master1", "master2"; |