Legend:
Library
Module
Module type
Parameter
Class
Class type
Set up networks involving large amount of nodes.
The applications of this module range from running small cliques to complex network topologies involving as many nodes as your computer can handle.
The general approach is to create some nodes, then declare connections using functions such as connect, clique, ring or star, and finally start all nodes with start.
For instance, here is how to create a star topology, with a center node connected to 5 other nodes:
let center = Node.create [] in
let other_star_nodes = Cluster.create 5 [] in
Cluster.star center other_star_nodes;
Here is how to connect the center node of this star to a clique of 4 other nodes:
let clique_nodes = Cluster.create 4 [] in
Cluster.clique clique_nodes;
Cluster.connect [center] clique_nodes;
Finally, here is how to start the network:
Cluster.start (clique_nodes @ center :: other_star_nodes)
Batch Node Creation
val create :
?path:string ->?name:string ->int ->?rpc_local:bool ->Node.argument list->Node.t list
Create several nodes.
Usage: create count ?rpc_local arguments
Create count nodes (using Node.create) sharing the same ?rpc_local and arguments. Each node is named name ^ "." ^ i where i is the index of the node in the resulting list, starting from 1.
Connect all nodes of a cluster to all nodes of another cluster.
Usage: connect a b
Add all nodes of b as --peer arguments to all nodes of a, and all nodes of a as --peer arguments to all nodes of b. This is a generalization of symmetric_add_peer for lists.
Add all other_nodes as --peers to center and vice-versa.
Meta-Topologies
The following functions are similar to the above functions that create topologies, except that they are parameterized by:
'a, the type of nodes (usually Node.t);
a connection function to create arrows in the graph.
All non-meta functions are actually instances of their corresponding meta functions with 'a = Node.t and symmetric_add_peer as the connection function. For instance, clique is the same as meta_clique symmetric_add_peer.
Here are examples of other useful instantiations:
use Node.add_peer as the connection function, to create one-way arrows instead of summetry ones (not very useful if nodes are in private mode);
use connect as the connection function to connect clusters together ('a is then Node.t list).
val meta_connect : ('a->'a-> unit)->'a list->'a list-> unit
This runs Node.identity_generate, Node.config_init, Node.run and Node.wait_for_ready for all nodes. This is similar to iterating Node.init except that the node are already created.
If public is false (which is the default), nodes are started with --private_mode. Set public to true to allow the topology to change over time. If you need some nodes to be in private mode, and some nodes not to, set public to true, and give the Private_mode argument to Cluster.create and/or Node.create.
If ?wait_connections is set, the function will return only after all nodes in the topology are connected to their expected number of neighbors.