summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2011-01-31 12:10:37 +0000
committerAlexandru Scvortov <alexandru@rabbitmq.com>2011-01-31 12:10:37 +0000
commitd42396d94bdeffa7e5b323df981e40d912b32341 (patch)
treeb6987a93818ed51c691b491790f57c1e7b2a3397
parentb6ac47ef55c6ebb60e257415a2ffeaa0c22c45ee (diff)
downloadrabbitmq-server-d42396d94bdeffa7e5b323df981e40d912b32341.tar.gz
make cluster nofitication a boot step; don't print to screen
-rw-r--r--src/rabbit.erl15
-rw-r--r--src/rabbit_node_monitor.erl31
2 files changed, 33 insertions, 13 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 92bc8802..db4ae624 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -153,6 +153,11 @@
[{mfa, {rabbit_networking, boot, []}},
{requires, log_relay}]}).
+-rabbit_boot_step({notify_cluster,
+ [{description, "notify cluster nodes"},
+ {mfa, {rabbit_node_monitor, notify_cluster, []}},
+ {requires, networking}]}).
+
%%---------------------------------------------------------------------------
-include("rabbit_framing.hrl").
@@ -230,16 +235,6 @@ 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 78bbe901..f372fbdd 100644
--- a/src/rabbit_node_monitor.erl
+++ b/src/rabbit_node_monitor.erl
@@ -22,9 +22,19 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
--export([rabbit_running_on/1]).
+-export([notify_cluster/0, rabbit_running_on/1]).
-define(SERVER, ?MODULE).
+-define(RABBIT_UP_RPC_TIMEOUT, 2000).
+
+%%----------------------------------------------------------------------------
+
+-ifdef(use_specs).
+
+-spec(rabbit_running_on/1 :: (node()) -> 'ok').
+-spec(notify_cluster/0 :: () -> 'ok').
+
+-endif.
%%--------------------------------------------------------------------
@@ -34,6 +44,22 @@ start_link() ->
rabbit_running_on(Node) ->
gen_server:cast(rabbit_node_monitor, {rabbit_running_on, Node}).
+notify_cluster() ->
+ %% notify other rabbits of this rabbit
+ {_, BadNodes} =
+ rpc:multicall(rabbit_mnesia:running_clustered_nodes() -- [node()],
+ rabbit_node_monitor, rabbit_running_on, [node()],
+ ?RABBIT_UP_RPC_TIMEOUT),
+ case BadNodes of
+ [] -> ok;
+ _ -> rabbit_log:warn("failed to contact nodes ~p", [BadNodes])
+ end,
+ %% register other active rabbits with this rabbit
+ [ rabbit_node_monitor:rabbit_running_on(Node)
+ || Node <- rabbit_mnesia:running_clustered_nodes(),
+ Node =/= node() ],
+ ok.
+
%%--------------------------------------------------------------------
init([]) ->
@@ -46,7 +72,6 @@ handle_call(_Request, _From, 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}.
@@ -56,7 +81,7 @@ handle_info({nodedown, Node}, 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]),
+ rabbit_log:info("node ~p lost 'rabbit'", [Node]),
ok = handle_dead_rabbit(Node, false),
{noreply, State};
handle_info(_Info, State) ->