diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-11-20 17:28:20 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-11-20 17:28:20 +0000 |
commit | f961f8245f1c15b9d884358f52c00929d532c9ab (patch) | |
tree | a5ae5f9b60e812d13e34909eb41cddc1df021c57 | |
parent | ee2823b168f8b8ef85245afd9fc2da60e34055a7 (diff) | |
parent | bed348597806dbd80cf42d6f9bdf68361a86faa5 (diff) | |
download | rabbitmq-server-f961f8245f1c15b9d884358f52c00929d532c9ab.tar.gz |
stable to default
-rw-r--r-- | src/rabbit_cli.erl | 19 | ||||
-rw-r--r-- | src/rabbit_control_main.erl | 5 | ||||
-rw-r--r-- | src/rabbit_plugins_main.erl | 4 |
3 files changed, 13 insertions, 15 deletions
diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 3fc32039..47505b3d 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 - {badrpc, _} = E -> throw(E); %% To be caught in main/3 - Time -> net_kernel:set_net_ticktime(Time, 0) +rpc_call(Node, Mod, Fun, Args) -> + case rpc:call(Node, net_kernel, get_net_ticktime, [], ?RPC_TIMEOUT) of + {badrpc, _} = E -> E; + 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 6e789e37..a931eef0 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 7fd10435..49f699c5 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, []} -> |