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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.2 -->
<HTML>
<HEAD>
<TITLE>pool</TITLE>
<SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
<STYLE TYPE="text/css">
<!--
.REFBODY { margin-left: 13mm }
.REFTYPES { margin-left: 8mm }
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
<IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>pool</H1>
</CENTER>
<H3>MODULE</H3>
<DIV CLASS=REFBODY>
pool
</DIV>
<H3>MODULE SUMMARY</H3>
<DIV CLASS=REFBODY>
Load Distribution Facility
</DIV>
<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>
<P><CODE>pool</CODE> 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:
<P>
<UL>
<LI>
The slave nodes send regular reports to the master about their current load.
</LI>
<LI>
Queries can be sent to the master to determine which node will have the least load.
</LI>
</UL>
<P>The BIF <CODE>statistics(run_queue)</CODE> is used for estimating future loads. It returns the length of the queue of ready to run processes in the Erlang runtime system.
<P>The slave nodes are started with the <CODE>slave</CODE> module.
This effects, tty IO, file IO, and code loading.
<P>If the master node fails, the entire pool will exit.
</DIV>
<H3>EXPORTS</H3>
<P><A NAME="start/1"><STRONG><CODE>start(Name)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a new pool. The file <CODE>.hosts.erlang</CODE> is read to find host names where the pool nodes can be started. The current working directory is searched first, then the home
directory, and finally the root directory of the Erlang runtime system. The start-up procedure fails if the file is not found.
<P><CODE>Name</CODE> is sent to all pool nodes. This is used as the first part of the node name in the
<CODE>alive/3</CODE> statements for the nodes.
<P>The function <CODE>net_adm:host_file()</CODE> reads the file <CODE>.hosts.erlang</CODE> for host names. The slave nodes are started with <CODE>slave:start</CODE>. See slave(3).
<P><CODE>start/1</CODE> is synchronous and all the nodes, as well as all the system servers, are running when it returns a value. Access rights must also be set so that all nodes in the pool have the authority to access each other.
</DIV>
<P><A NAME="start/2"><STRONG><CODE>start(Name, Args)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>This function is the same as <CODE>start/1</CODE>, except that the
environment <CODE>Args</CODE> is passed to the pool nodes.
See slave(3).
<P>
</DIV>
<P><A NAME="attach/1"><STRONG><CODE>attach(Node)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>This function ensures that a pool master is running and includes <CODE>Node</CODE>
in the pool master's pool of nodes.
<P>
</DIV>
<P><A NAME="stop/0"><STRONG><CODE>stop()
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Stops the pool and kills all the slave nodes.
</DIV>
<P><A NAME="get_nodes/0"><STRONG><CODE>get_nodes()
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Returns a list of the current member nodes of the pool.
</DIV>
<P><A NAME="pspawn/3"><STRONG><CODE>pspawn(Mod, Fun, Args)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Spawns a process on the pool node which is
expected to have the lowest future load.
<P>
</DIV>
<P><A NAME="pspawn_link/3"><STRONG><CODE>pspawn_link(Mod, Fun, Args)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Spawn links a process on the pool node which is
expected to have the lowest future load.
<P>
</DIV>
<P><A NAME="get_node/0"><STRONG><CODE>get_node()
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Returns the node ID of the node with the expected lowest future
load.
</DIV>
<P><A NAME="new_node/2"><STRONG><CODE>new_node(Host, Name)
</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>Starts a new node and attaches it to an already existing pool
If there is no existing pool, it starts a pool with two nodes,
the current node and <CODE>Node</CODE>. This function can also be used as
a convenient way of starting new nodes, even if the load
distribution facilities of <CODE>pool</CODE> are of no interest.
<P>
</DIV>
<H3>Files</H3>
<DIV CLASS=REFBODY>
<P>$HOME/.hosts.erlang is used to pick hosts where nodes can
be started.
<P>$HOME/.erlang.slave.out.HOST 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.
</DIV>
<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
Claes Wikstrom - support@erlang.ericsson.se<BR>
</DIV>
<CENTER>
<HR>
<SMALL>stdlib 1.13.2<BR>
Copyright © 1991-2004
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>
|