summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-01-31 11:34:18 +0000
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-01-31 11:34:18 +0000
commitb6ac47ef55c6ebb60e257415a2ffeaa0c22c45ee (patch)
tree9d75219add7c11a0e4c1e04c791673429f87966e
parentfb7cd81fef32fbb0e18fa6e8ec6bff0c5d03b880 (diff)
downloadrabbitmq-server-b6ac47ef55c6ebb60e257415a2ffeaa0c22c45ee.tar.gz
cleanup after rabbit goes down on a clustered node
-rw-r--r--src/rabbit_node_monitor.erl18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl
index c36a1dfb..78bbe901 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).