Global names of hidden node

Yoshi <>
Sun Sep 5 08:02:43 CEST 2010


Is there any way to make global registered names of hidden node
visible after I connect to the hidden node from other hidden node?

In my distributed Erlang network, I don't want nodes connect
transitively and using -hidden flag, but this leads to the situation I
cannot use globally registered names on other nodes even after I
connect to those nodes using net_kernel:connect_node/1.

For example, when I start a node, with -hidden flag, I cannot see the
global registered names on '' even after I connect to it

    :~$ erl -pa ebin -hidden -setcookie harmonia_cookie -sname
    Erlang R13B04 (erts-5.7.5) [source] [rq:1] [async-threads:0]

    Eshell V5.7.5  (abort with ^G)
    ()1> global:registered_names().
    ()2> net_kernel:connect_node().
    ()3> global:registered_names().

It seems I can use rpc:call/4 and global:register_name/2 in order to
do what I want:

    ()4> rpc:call(, global, registered_names,
    ()5> Pid = rpc:call(, global,
whereis_name, [hm_router_foo]).
    ()6> global:register_name(hm_router_foo, Pid).
    ()8> gen_server:call({global, hm_router_foo},
{find_successor, 38, nil}).

But is this a proper way and is there a better way? Or I should not
consider to do this in the first place?

Thank you

More information about the erlang-questions mailing list