[erlang-questions] noob gen_leader question

db masterofquestions@REDACTED
Fri Apr 18 20:45:23 CEST 2008


Here is the module used to run gdict and it's corresponding output:

-module(gen_leader_for_dummies).
-export([main/0]).

-define(DUMP(X), io:format("~p:~p - ~p = ~p~n", [?MODULE, ?
LINE, ??X, X])).

main() ->

    ?DUMP(node()),
    ?DUMP(nodes()),

    %CandidateNodes and WorkerNodes are disjoint set of nodes	
    CandidateNodes = [a@REDACTED,b@REDACTED],
    WorkerNodes = [wa@REDACTED,wb@REDACTED],

    ?DUMP(CandidateNodes),
    ?DUMP(WorkerNodes),
    {ok, D} = gdict:new(dummy, CandidateNodes, WorkerNodes),
    ?DUMP(D),
    ?DUMP(gdict:append(a, 1, D)),
    ?DUMP(gdict:append(b, 2, D)),
    ?DUMP(gdict:append(c, 3, D)),
    ?DUMP(gdict:find(a, D)),
    ?DUMP(gdict:find(b, D)),
    ?DUMP(gdict:find(c, D)).

(a@REDACTED)1> gen_leader_for_dummies:main().
gen_leader_for_dummies:9 - "node ( )" = a@REDACTED
gen_leader_for_dummies:10 - "nodes ( )" = [wb@REDACTED,wa@REDACTED,b@REDACTED]
gen_leader_for_dummies:15 - "CandidateNodes" = [a@REDACTED,b@REDACTED]
gen_leader_for_dummies:16 - "WorkerNodes" = [wa@REDACTED,wb@REDACTED]
init({dict,0,16,16,8,80,48,
           {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
           {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}})
gen_leader_for_dummies:18 - "D" = <0.72.0>
elected([], {election,<0.72.0>,global,dummy,a@REDACTED,
                      [a@REDACTED,b@REDACTED],
                      [wa@REDACTED,wb@REDACTED],
                      [],
                      {[],1},
                      [b@REDACTED],
                      [{#Ref<0.0.0.197>,wb@REDACTED},{#Ref<0.0.0.196>,wa@REDACTED}],
                      []})
gen_leader_for_dummies:19 - "gdict : append ( a , 1 , D )" = ok
gen_leader_for_dummies:20 - "gdict : append ( b , 2 , D )" = ok
gen_leader_for_dummies:21 - "gdict : append ( c , 3 , D )" = ok
gen_leader_for_dummies:22 - "gdict : find ( a , D )" = {ok,[1]}
gen_leader_for_dummies:23 - "gdict : find ( b , D )" = {ok,[2]}
gen_leader_for_dummies:24 - "gdict : find ( c , D )" = {ok,[3]}
ok


On Fri, Apr 18, 2008 at 1:13 PM, db <masterofquestions@REDACTED> wrote:
> I reran the gdict example and election record shows b@REDACTED as down.
>  Even though this is not the case, but simply b@REDACTED is not the
>  current leader.  There is no distinction made between node being down
>  and nodes that aren't elected leader in actual election record/tuple.
>
>  Also, what is buffered field in the election record definition?
-
rk

That which we persist in doing becomes easier for us to do; not that
the nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson



More information about the erlang-questions mailing list