diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-01-31 11:34:18 +0000 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-01-31 11:34:18 +0000 |
| commit | a814f2e0e8e1ae7490e2b4d51034990bb8eafc76 (patch) | |
| tree | 9d75219add7c11a0e4c1e04c791673429f87966e | |
| parent | 68a0b3b3e3d72c537651ed0684f886a3def9ec5c (diff) | |
| download | rabbitmq-server-git-a814f2e0e8e1ae7490e2b4d51034990bb8eafc76.tar.gz | |
cleanup after rabbit goes down on a clustered node
| -rw-r--r-- | src/rabbit_node_monitor.erl | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl index c36a1dfb35..78bbe9015a 100644 --- a/src/rabbit_node_monitor.erl +++ b/src/rabbit_node_monitor.erl @@ -53,14 +53,11 @@ handle_cast(_Msg, State) -> handle_info({nodedown, Node}, State) -> rabbit_log:info("node ~p down", [Node]), - %% TODO: This may turn out to be a performance hog when there are - %% lots of nodes. We really only need to execute this code on - %% *one* node, rather than all of them. - ok = rabbit_networking:on_node_down(Node), - ok = rabbit_amqqueue:on_node_down(Node), - {noreply, State}; + ok = handle_dead_rabbit(Node, true), + {noreply, State}; handle_info({'DOWN', _MRef, process, {rabbit, Node}, _Reason}, State) -> io:format("node ~p lost 'rabbit'~n", [Node]), + ok = handle_dead_rabbit(Node, false), {noreply, State}; handle_info(_Info, State) -> {noreply, State}. @@ -72,3 +69,12 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}. %%-------------------------------------------------------------------- + +%% TODO: This may turn out to be a performance hog when there are +%% lots of nodes. We really only need to execute this code on +%% *one* node, rather than all of them. +handle_dead_rabbit(Node, true = _TakeDownNetworking) -> + ok = rabbit_networking:on_node_down(Node), + handle_dead_rabbit(Node, false); +handle_dead_rabbit(Node, false) -> + ok = rabbit_amqqueue:on_node_down(Node). |
