summaryrefslogtreecommitdiff
path: root/src
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
commit68a0b3b3e3d72c537651ed0684f886a3def9ec5c (patch)
treea5b8aeb3929d58da314620629f655003a9a32de6 /src
parentcc0fc355a4fc589e3da4bd1b8ede8148f216bfd4 (diff)
downloadrabbitmq-server-git-68a0b3b3e3d72c537651ed0684f886a3def9ec5c.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')
-rw-r--r--src/rabbit.erl11
-rw-r--r--src/rabbit_node_monitor.erl13
2 files changed, 18 insertions, 6 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 9a938d1067..92bc8802f4 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -230,7 +230,16 @@ start(normal, []) ->
print_banner(),
[ok = run_boot_step(Step) || Step <- boot_steps()],
io:format("~nbroker running~n"),
-
+ io:format("informing other clustered brokers: ~p~n",
+ [rabbit_mnesia:running_clustered_nodes()]),
+ %% notify other rabbits of this rabbit
+ [ rpc:call(Node, rabbit_node_monitor, rabbit_running_on, [node()])
+ || Node <- rabbit_mnesia:running_clustered_nodes(),
+ Node =/= node() ],
+ %% register other active rabbits with this rabbit
+ [ rabbit_node_monitor:rabbit_running_on(Node)
+ || Node <- rabbit_mnesia:running_clustered_nodes(),
+ Node =/= node() ],
{ok, SupPid};
Error ->
Error
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl
index bce5ec12a1..c36a1dfb35 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}.
%%--------------------------------------------------------------------
-