[erlang-questions] once again gen_leader question patched vs non-patched version

Hans Svensson <>
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:

()6> nodes().

()11> gdict:append(key,value,{test_ldr,''}).
()12> gdict:find(key,{test_ldr,''}).
()13> gdict:find(key,{test_ldr,''}).

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 Svensson                   
Computer Science and Engineering,
Chalmers University of Technology, Gothenburg, Sweden

db wrote:
> I am currently running gen_leader instances only on candidate nodes.
> My worker and candidate nodes are follows:
> Candidate Nodes:	[]
> Worker Nodes:           []
> Call is made from node , 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  and   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?
> ()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