summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-11-20 16:51:26 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-11-20 16:51:26 +0000
commitba22dac7b2b5584ab40b5bfc1213511cc118a388 (patch)
tree5492d757136f1582c7c074ebb10064adf24ee96c /src
parent782e0131b670f991b821f1ce1871c603b14c06f4 (diff)
downloadrabbitmq-server-git-ba22dac7b2b5584ab40b5bfc1213511cc118a388.tar.gz
Be a bit more sensible with syncing the ticktime; only do it when RPCing into the node (since there are plenty of commands where we do not expect the node to be up, which the previous changeset breaks...)
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_cli.erl17
-rw-r--r--src/rabbit_control_main.erl5
-rw-r--r--src/rabbit_plugins_main.erl4
3 files changed, 12 insertions, 14 deletions
diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl
index 3fc32039a9..ff345c6d84 100644
--- a/src/rabbit_cli.erl
+++ b/src/rabbit_cli.erl
@@ -17,7 +17,7 @@
-module(rabbit_cli).
-include("rabbit_cli.hrl").
--export([main/3, parse_arguments/4]).
+-export([main/3, parse_arguments/4, rpc_call/4]).
%%----------------------------------------------------------------------------
@@ -35,6 +35,7 @@
-spec(parse_arguments/4 ::
([{atom(), [{string(), optdef()}]} | atom()],
[{string(), optdef()}], string(), [string()]) -> parse_result()).
+-spec(rpc_call/4 :: (node(), atom(), atom(), [any()]) -> any()).
-endif.
@@ -57,10 +58,7 @@ main(ParseFun, DoFun, UsageMod) ->
%% The reason we don't use a try/catch here is that rpc:call turns
%% thrown errors into normal return values
- case catch begin
- sync_ticktime(Node),
- DoFun(Command, Node, Args, Opts)
- end of
+ case catch DoFun(Command, Node, Args, Opts) of
ok ->
rabbit_misc:quit(0);
{'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> %% < R15
@@ -189,11 +187,12 @@ print_badrpc_diagnostics(Nodes) ->
fmt_stderr(rabbit_nodes:diagnostics(Nodes), []).
%% If the server we are talking to has non-standard net_ticktime, and
-%% our conncetion lasts a while, we could get disconnected because of
+%% our connection lasts a while, we could get disconnected because of
%% a timeout unless we set our ticktime to be the same. So let's do
%% that.
-sync_ticktime(Node) ->
- case rpc:call(Node, net_kernel, get_net_ticktime, []) of
+rpc_call(Node, Mod, Fun, Args) ->
+ case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of
{badrpc, _} = E -> throw(E); %% To be caught in main/3
- Time -> net_kernel:set_net_ticktime(Time, 0)
+ Time -> net_kernel:set_net_ticktime(Time, 0),
+ rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT)
end.
diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl
index 6e789e3756..a931eef009 100644
--- a/src/rabbit_control_main.erl
+++ b/src/rabbit_control_main.erl
@@ -21,6 +21,8 @@
-export([start/0, stop/0, parse_arguments/2, action/5,
sync_queue/1, cancel_sync_queue/1]).
+-import(rabbit_cli, [rpc_call/4]).
+
-define(EXTERNAL_CHECK_INTERVAL, 1000).
-define(GLOBAL_DEFS(Node), [?QUIET_DEF, ?NODE_DEF(Node)]).
@@ -692,9 +694,6 @@ list_to_binary_utf8(L) ->
error -> throw({error, {not_utf_8, L}})
end.
-rpc_call(Node, Mod, Fun, Args) ->
- rpc:call(Node, Mod, Fun, Args, ?RPC_TIMEOUT).
-
%% escape does C-style backslash escaping of non-printable ASCII
%% characters. We don't escape characters above 127, since they may
%% form part of UTF-8 strings.
diff --git a/src/rabbit_plugins_main.erl b/src/rabbit_plugins_main.erl
index 7fd104352d..49f699c58b 100644
--- a/src/rabbit_plugins_main.erl
+++ b/src/rabbit_plugins_main.erl
@@ -169,7 +169,7 @@ format_plugins(Node, Pattern, Opts, #cli{all = All,
EnabledImplicitly = Implicit -- Enabled,
{StatusMsg, Running} =
- case rpc:call(Node, rabbit_plugins, active, [], ?RPC_TIMEOUT) of
+ case rabbit_cli:rpc_call(Node, rabbit_plugins, active, []) of
{badrpc, _} -> {"[failed to contact ~s - status not shown]", []};
Active -> {"* = running on ~s", Active}
end,
@@ -275,7 +275,7 @@ sync(Node, ForceOnline, #cli{file = File}) ->
rpc_call(Node, Online, Mod, Fun, Args) ->
io:format("~nApplying plugin configuration to ~s...", [Node]),
- case rpc:call(Node, Mod, Fun, Args) of
+ case rabbit_cli:rpc_call(Node, Mod, Fun, Args) of
{ok, [], []} ->
io:format(" nothing to do.~n", []);
{ok, Start, []} ->