diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-02-09 20:00:35 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-02-09 20:00:35 +0000 |
| commit | d97749514dafa8889431bb723bfbadc254060feb (patch) | |
| tree | 18069bd5a81395324f9f31f025d9b649269a53cb /src | |
| parent | 7a1c79945a5b0c7e08cd19fd2881da81783583c6 (diff) | |
| download | rabbitmq-server-git-d97749514dafa8889431bb723bfbadc254060feb.tar.gz | |
monitor nodes just once
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_node_monitor.erl | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index 54a7add2e6..323cf0ce9e 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -61,23 +61,26 @@ notify_cluster() -> %%-------------------------------------------------------------------- init([]) -> - {ok, no_state}. + {ok, ordsets:new()}. handle_call(_Request, _From, State) -> {noreply, State}. -handle_cast({rabbit_running_on, Node}, State) -> - rabbit_log:info("rabbit on ~p up~n", [Node]), - erlang:monitor(process, {rabbit, Node}), - ok = handle_live_rabbit(Node), - {noreply, State}; +handle_cast({rabbit_running_on, Node}, Nodes) -> + case ordsets:is_element(Node, Nodes) of + true -> {noreply, Nodes}; + false -> rabbit_log:info("rabbit on node ~p up~n", [Node]), + erlang:monitor(process, {rabbit, Node}), + ok = handle_live_rabbit(Node), + {noreply, ordsets:add_element(Node, Nodes)} + end; handle_cast(_Msg, State) -> {noreply, State}. -handle_info({'DOWN', _MRef, process, {rabbit, Node}, _Reason}, State) -> - rabbit_log:info("node ~p lost 'rabbit'~n", [Node]), +handle_info({'DOWN', _MRef, process, {rabbit, Node}, _Reason}, Nodes) -> + rabbit_log:info("rabbit on node ~p down~n", [Node]), ok = handle_dead_rabbit(Node), - {noreply, State}; + {noreply, ordsets:del_element(Node, Nodes)}; handle_info(_Info, State) -> {noreply, State}. |
