Global names of hidden node

Yoshi hirotnkg@REDACTED
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 'node_foo@REDACTED' even after I connect to it
below:

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

    Eshell V5.7.5  (abort with ^G)
    (bar_node@REDACTED)1> global:registered_names().
    []
    (bar_node@REDACTED)2> net_kernel:connect_node(node_foo@REDACTED).
    true
    (bar_node@REDACTED)3> global:registered_names().
    []

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

    (bar_node@REDACTED)4> rpc:call(node_foo@REDACTED, global, registered_names,
[]).
    [hm_router_foo,hm_config_if_foo,hm_stabilizer_foo,
     hm_name_server,hm_ds_foo,foo,hm_table_foo]
    (bar_node@REDACTED)5> Pid = rpc:call(node_foo@REDACTED, global,
whereis_name, [hm_router_foo]).
    <6351.53.0>
    (bar_node@REDACTED)6> global:register_name(hm_router_foo, Pid).
    yes
    (bar_node@REDACTED)7>
global:registered_names().
    [hm_router_foo]
    (bar_node@REDACTED)8> gen_server:call({global, hm_router_foo},
{find_successor, 38, nil}).
    {hm_router_foo,90}
    (bar_node@REDACTED)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