rcp:cast/4 example?
Ulf Wiger
etxuwig@REDACTED
Wed Mar 28 10:01:15 CEST 2001
Two things that might confuse the results:
- rpc sets the "group leader" of the process executing the
function to the group leader of the process requesting the
call. If there is IO, it should appear on the node from where
the rpc:cast() originated.
- The ?SYS_DBG macro only prints if a debug compiled version of
mlgCpt.erl is loaded on the node where the function is executed
(i.e. the remote node) AND debug:filter(mlgCpt, Tag) returns
true on the same node. Otherwise, no printout will be generated.
That is, you have to call debug:on(mlgCpt) on both nodes, and look for
the output on the node executing call_ch_nodes_to_get_data/1.
Have you tried calling rpc:cast(node(), mlgCpt, trace_call, [...])
from the shell?
It should give the same behaviour as calling the function directly
from the shell.
/Uffe
On Tue, 27 Mar 2001, andy allen wrote:
>Hi, all.
>
>I'm looking for advice on a simple example of rpc:cast/4.
>
>-=-=-
>
>I am trying to get the following code to execute:
>
>call_ch_nodes_to_get_data(DataToPassWithCall) ->
> ?SYS_DBG(int_if, "mlgAmsCpt:call_ch_nodes_to_Get_data(~w)~n",
> [DataToPassWithCall]),
>
> ChNodes = get_ch_nodes(),
> ?SYS_DBG(int_if, "Found the following nodes: ~w ~n", [ChNodes]),
>
> Module = mlgCpt,
> Function = trace_cast,
>
> [ChNode | Rest] = ChNodes, % Temporary hack for one node
> ?SYS_DBG(int_if, "Will cast to the node ~w, module ~w, function
> ~w with the parameters ~w ~n",
> [ChNode, Module, Function, [DataToPassWithCall]]),
>
> X = rpc:cast(ChNode, Module, Function, [DataToPassWithCall]),
> ?SYS_DBG(int_if, "Result of cast: ~w ~n", [X]),
>
> nnn.
>
>-=-=-
>
>SYS_DBG {mlgAmsCpt,680,int_if}, <0.20019.3> 27-Mar-2001 15:13:37.022072:
>-- mlgAmsCpt:call_ch_nodes_to_Get_data ({{switch_dev_id, 1}, {channel,
>all}})
>
>ChNodes = get_ch_nodes(), SYS_DBG {mlgAmsCpt,691,int_if}, <0.20019.3>
>27-Mar-2001 15:13:37.046248:
>-- Found the following nodes: ['cp1-19@REDACTED']
>
>SYS_DBG {mlgAmsCpt,697,int_if}, <0.20019.3> 27-Mar-2001 15:13:37.048843:
>-- Will cast to the node 'cp1-19@REDACTED', module mlgCpt, function trace_call
>with the parameters [{{switch_dev_id,1},{channel,all}}]
>
>SYS_DBG {mlgAmsCpt,701,int_if}, <0.20019.3> 27-Mar-2001 15:13:37.052683:
>-- Result of cast: true
>
>-=-=-
>
>To make certain that the function I am casting to works, I can call it with
>the following line from an Erlang shell:
>
>mlgCpt:trace_call({{switch_dev_id, 1}, {channel, all}}).
>
>It executes past a "SYS_DBG" statement, then crashes. But when I cast to it,
>it should at least execute the "SYS_DBG" statement, right?
>
>-=-=-
>
>For the uninitiated:
>1. rpc is a library in the standard Erlang distribution,
>2. ?SYS_DBG is a macro that works like a printf.
>
>-=-=-
>
>Thanks for ANY help you can give me!
>
>Andy Allen
>Ericsson, EUS/SA/BA
>
>P.S. Has anyone considered expanding the MAN pages with simple hello-world
>examples of each library call?
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
--
Ulf Wiger tfn: +46 8 719 81 95
Senior System Architect mob: +46 70 519 81 95
Strategic Product & System Management ATM Multiservice Networks
Data Backbone & Optical Services Division Ericsson Telecom AB
More information about the erlang-questions
mailing list