1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
.TH pool 3 "stdlib 1.15.3" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
pool \- Load Distribution Facility
.SH DESCRIPTION
.LP
\fIpool\fR can be used to run a set of Erlang nodes as a pool of computational processors\&. It is organized as a master and a set of slave nodes and includes the following features:
.RS 2
.TP 2
*
The slave nodes send regular reports to the master about their current load\&.
.TP 2
*
Queries can be sent to the master to determine which node will have the least load\&.
.RE
.LP
The BIF \fIstatistics(run_queue)\fR is used for estimating future loads\&. It returns the length of the queue of ready to run processes in the Erlang runtime system\&.
.LP
The slave nodes are started with the \fIslave\fR module\&. This effects, tty IO, file IO, and code loading\&.
.LP
If the master node fails, the entire pool will exit\&.
.SH EXPORTS
.LP
.B
start(Name) ->
.br
.B
start(Name, Args) -> Nodes
.br
.RS
.TP
Types
Name = atom()
.br
Args = string()
.br
Nodes = [node()]
.br
.RE
.RS
.LP
Starts a new pool\&. The file \fI\&.hosts\&.erlang\fR is read to find host names where the pool nodes can be started\&. See section Files below\&. The start-up procedure fails if the file is not found\&.
.LP
The slave nodes are started with \fIslave:start/2, 3\fR, passing along \fIName\fR and, if provided, \fIArgs\fR\&. \fIName\fR is used as the first part of the node names, \fIArgs\fR is used to specify command line arguments\&. See slave(3)\&.
.LP
Access rights must be set so that all nodes in the pool have the authority to access each other\&.
.LP
The function is synchronous and all the nodes, as well as all the system servers, are running when it returns a value\&.
.RE
.LP
.B
attach(Node) -> allready_attached | attached
.br
.RS
.TP
Types
Node = node()
.br
.RE
.RS
.LP
This function ensures that a pool master is running and includes \fINode\fR in the pool master\&'s pool of nodes\&.
.RE
.LP
.B
stop() -> stopped
.br
.RS
.LP
Stops the pool and kills all the slave nodes\&.
.RE
.LP
.B
get_nodes() -> Nodes
.br
.RS
.TP
Types
Nodes = [node()]
.br
.RE
.RS
.LP
Returns a list of the current member nodes of the pool\&.
.RE
.LP
.B
pspawn(Mod, Fun, Args) -> pid()
.br
.RS
.TP
Types
Mod = Fun = atom()
.br
Args = [term()]
.br
.RE
.RS
.LP
Spawns a process on the pool node which is expected to have the lowest future load\&.
.RE
.LP
.B
pspawn_link(Mod, Fun, Args) -> pid()
.br
.RS
.TP
Types
Mod = Fun = atom()
.br
Args = [term()]
.br
.RE
.RS
.LP
Spawn links a process on the pool node which is expected to have the lowest future load\&.
.RE
.LP
.B
get_node() -> node()
.br
.RS
.LP
Returns the node with the expected lowest future load\&.
.RE
.SH FILES
.LP
\fI\&.hosts\&.erlang\fR is used to pick hosts where nodes can be started\&. See net_adm(3) for information about format and location of this file\&.
.LP
\fI$HOME/\&.erlang\&.slave\&.out\&.HOST\fR is used for all additional IO that may come from the slave nodes on standard IO\&. If the start-up procedure does not work, this file may indicate the reason\&.
|