[erlang-questions] once again gen_leader question patched vs non-patched version
Hans Svensson
hanssv@REDACTED
Wed May 7 15:07:01 CEST 2008
Given that we use 'gdict' (the global dictionary example, usually
distributed together with gen_leader) the following sequence of commands
establishes a global dictionary with a configuration similar to yours
(my candidates are node1 and node2, and the workers are node3 and node4)
all commands are run on a separate node named test:
(test@REDACTED)6> nodes().
[node1@REDACTED,node2@REDACTED,node3@REDACTED,node4@REDACTED]
(test@REDACTED)7>
spawn('node1@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]).
<5145.56.0>
(test@REDACTED)8>
spawn('node2@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]).
<5237.55.0>
(test@REDACTED)9>
spawn('node3@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]).
<5238.55.0>
(test@REDACTED)10>
spawn('node4@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]).
<5239.59.0>
(test@REDACTED)11> gdict:append(key,value,{test_ldr,'node1@REDACTED'}).
ok
(test@REDACTED)12> gdict:find(key,{test_ldr,'node2@REDACTED'}).
{ok,[value]}
(test@REDACTED)13> gdict:find(key,{test_ldr,'node3@REDACTED'}).
{ok,[value]}
There are some (perhaps not so intuitive) differences between gen_server
(where only one process is involved and its global name could be used)
and gen_leader (with one process on each candidate/worker that is
addressed {name,node}). Also the preferred way of using gen_leader is do
define a callback-module, and not call for example
gen_leader:leader_call() directly!
Hope this helps,
/Hans
--
Hans Svensson hanssv@REDACTED
Computer Science and Engineering,
Chalmers University of Technology, Gothenburg, Sweden
http://www.cs.chalmers.se/~hanssv
db wrote:
> I am currently running gen_leader instances only on candidate nodes.
> My worker and candidate nodes are follows:
>
> Candidate Nodes: [a@REDACTED,b@REDACTED]
> Worker Nodes: [wa@REDACTED,wb@REDACTED]
>
> Call is made from node c@REDACTED, which is neither candidate/worker,
> causes noproc error. See below. If a node wants to call
> gen_leader:leader_call, does it have to run a gen_leader instance? I
> tried running gen_leader instance on the workers also, but it crashed
> both the gen_leader instances on node a@REDACTED and b@REDACTED I ran both
> versions of gen_leader, patched version and non-patched version. On
> patched version, I couldn't run gen_leader instance on worker nodes
> (this crashed all instances of gen_leader on all nodes), but was able
> to run it on non-patched version. Which is the desired behavior, in
> regards to gen_leader instance running on worker nodes?
>
> Also, what is the actual steps to run the gen_leader, so that the
> remote nodes (neither worker/candidate) can communicate with elected
> leader to send task, which then pushed down to the worker nodes?
>
> (c@REDACTED)3> gen_leader:leader_call(leader_boo, {lookup, "dummy"}).
> ** exception exit: {{gen_leader,leader_call,2},
> {line,246},
> {noproc,
> {gen_leader,leader_call,
> [leader_boo,{lookup,"dummy"}]}}}
> in function gen_leader:leader_call/2
>
>
> Thank you,
More information about the erlang-questions
mailing list