summaryrefslogtreecommitdiff
path: root/src/rabbit_node_monitor.erl
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-01-31 10:59:45 +0000
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-01-31 10:59:45 +0000
commitfb7cd81fef32fbb0e18fa6e8ec6bff0c5d03b880 (patch)
treea5b8aeb3929d58da314620629f655003a9a32de6 /src/rabbit_node_monitor.erl
parent9f354ec05ce5e37a214e4d1caca1d003bc964bda (diff)
downloadrabbitmq-server-fb7cd81fef32fbb0e18fa6e8ec6bff0c5d03b880.tar.gz
monitor rabbits on clustered nodes
When a rabbit starts, it, * informs every other running node in the cluster that it has started, and * registers every other running node in the cluster as running. This should handle every possible case of nodes joining clusters, since every join should be followed by that node starting. We can't just monitor 'rabbit' on node ups, since those come in when mnesia joins the cluster. The rabbit process starts up a bit later.
Diffstat (limited to 'src/rabbit_node_monitor.erl')
-rw-r--r--src/rabbit_node_monitor.erl13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl
index bce5ec12..c36a1dfb 100644
--- a/src/rabbit_node_monitor.erl
+++ b/src/rabbit_node_monitor.erl
@@ -22,6 +22,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
+-export([rabbit_running_on/1]).
-define(SERVER, ?MODULE).
@@ -30,6 +31,9 @@
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
+rabbit_running_on(Node) ->
+ gen_server:cast(rabbit_node_monitor, {rabbit_running_on, Node}).
+
%%--------------------------------------------------------------------
init([]) ->
@@ -39,14 +43,14 @@ init([]) ->
handle_call(_Request, _From, State) ->
{noreply, State}.
-handle_cast(_Msg, State) ->
- {noreply, State}.
-
-handle_info({nodeup, Node}, State) ->
+handle_cast({rabbit_running_on, Node}, State) ->
rabbit_log:info("node ~p up", [Node]),
erlang:monitor(process, {rabbit, Node}),
io:format("monitored 'rabbit' on ~p~n", [Node]),
{noreply, State};
+handle_cast(_Msg, State) ->
+ {noreply, 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
@@ -68,4 +72,3 @@ code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%%--------------------------------------------------------------------
-