Global names of hidden node

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


Hello,

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
below:

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

    Eshell V5.7.5  (abort with ^G)
    ()1> global:registered_names().
    []
    ()2> net_kernel:connect_node().
    true
    ()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,
[]).
    [hm_router_foo,hm_config_if_foo,hm_stabilizer_foo,
     hm_name_server,hm_ds_foo,foo,hm_table_foo]
    ()5> Pid = rpc:call(, global,
whereis_name, [hm_router_foo]).
    <6351.53.0>
    ()6> global:register_name(hm_router_foo, Pid).
    yes
    ()7>
global:registered_names().
    [hm_router_foo]
    ()8> gen_server:call({global, hm_router_foo},
{find_successor, 38, nil}).
    {hm_router_foo,90}
    ()9>

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