diff options
author | Mike Wallace <mikewallace1979@googlemail.com> | 2014-08-27 23:07:58 +0100 |
---|---|---|
committer | Jay Doane <jaydoane@apache.org> | 2021-04-19 00:35:19 -0700 |
commit | 9231c1165b6f05515ed47cb142114bfd57b38cc8 (patch) | |
tree | b3f053634dca7381cdf14eaba43c08ceb6e38a7b | |
parent | aeee603ebee1de7548219c093687bf0444430459 (diff) | |
download | couchdb-9231c1165b6f05515ed47cb142114bfd57b38cc8.tar.gz |
Remove redundant rpc calls
The initial design of Riaknostic (and hence WeatherReport) was
that checks ran in the script and made RPC calls to the local
cluster node when needed. Due to a requirement to allow checks
to run on multiple cluster nodes without guarantees of SSH
connectivity, the design has changed such that each check is
now run entirely on the cluster node.
This means it is no longer necessary to use
weatherreport_node:local_command/3 to interact with the cluster,
the calls can just be made directly.
This commit removes the redundant calls to
weatherreport_node:local_command/3 which makes the intent of the
code a bit clearer.
BugzID: 34016
8 files changed, 17 insertions, 25 deletions
diff --git a/src/weatherreport/src/weatherreport_check_custodian.erl b/src/weatherreport/src/weatherreport_check_custodian.erl index 168fa9a52..6749c274e 100644 --- a/src/weatherreport/src/weatherreport_check_custodian.erl +++ b/src/weatherreport/src/weatherreport_check_custodian.erl @@ -60,8 +60,8 @@ report_to_message({DbName, ShardRange, {Type, N}}, NodeName) -> -spec check(list()) -> [{atom(), term()}]. check(_Opts) -> - NodeName = weatherreport_node:nodename(), - case weatherreport_node:local_command(custodian, report, []) of + NodeName = node(), + case custodian:report() of [] -> [{info, {ok, NodeName}}]; Report -> diff --git a/src/weatherreport/src/weatherreport_check_ioq.erl b/src/weatherreport/src/weatherreport_check_ioq.erl index 610d4e2e1..de0d8b155 100644 --- a/src/weatherreport/src/weatherreport_check_ioq.erl +++ b/src/weatherreport/src/weatherreport_check_ioq.erl @@ -63,7 +63,7 @@ sum_queues([{_Name, Value} | Rest], Acc) -> -spec check(list()) -> [{atom(), term()}]. check(_Opts) -> - case weatherreport_node:local_command(ioq, get_disk_queues, []) of + case ioq:get_disk_queues() of Queues when is_list(Queues) -> Total = sum_queues(Queues, 0), [{total_to_level(Total), {ioq_requests, Total, Queues}}]; diff --git a/src/weatherreport/src/weatherreport_check_mem3_sync.erl b/src/weatherreport/src/weatherreport_check_mem3_sync.erl index e143dc21b..0fb0d70e5 100644 --- a/src/weatherreport/src/weatherreport_check_mem3_sync.erl +++ b/src/weatherreport/src/weatherreport_check_mem3_sync.erl @@ -41,8 +41,8 @@ valid() -> -spec check(list()) -> [{atom(), term()}]. check(_Opts) -> - NodeName = weatherreport_node:nodename(), - case weatherreport_node:local_command(erlang, whereis, [mem3_sync]) of + NodeName = node(), + case erlang:whereis(mem3_sync) of undefined -> [{warning, {mem3_sync_not_found, NodeName}}]; Pid -> diff --git a/src/weatherreport/src/weatherreport_check_membership.erl b/src/weatherreport/src/weatherreport_check_membership.erl index f60bf1b01..c3b865174 100644 --- a/src/weatherreport/src/weatherreport_check_membership.erl +++ b/src/weatherreport/src/weatherreport_check_membership.erl @@ -51,8 +51,8 @@ valid() -> -spec check(list()) -> [{atom(), term()}]. check(_Opts) -> - NodeName = weatherreport_node:nodename(), - Members = weatherreport_node:local_command(mem3, nodes, []), + NodeName = node(), + Members = mem3:nodes(), case lists:member(NodeName, Members) of true -> []; diff --git a/src/weatherreport/src/weatherreport_check_nodes_connected.erl b/src/weatherreport/src/weatherreport_check_nodes_connected.erl index a68655666..136b5d069 100644 --- a/src/weatherreport/src/weatherreport_check_nodes_connected.erl +++ b/src/weatherreport/src/weatherreport_check_nodes_connected.erl @@ -47,9 +47,9 @@ valid() -> -spec check(list()) -> [{atom(), term()}]. check(_Opts) -> - NodeName = weatherreport_node:nodename(), - ConnectedNodes = [NodeName | weatherreport_node:local_command(erlang, nodes, [])], - Members = weatherreport_node:local_command(mem3, nodes, []), + NodeName = node(), + ConnectedNodes = [NodeName | erlang:nodes()], + Members = mem3:nodes(), [{warning, {node_disconnected, N}} || N <- Members, N =/= NodeName, lists:member(N, ConnectedNodes) == false]. diff --git a/src/weatherreport/src/weatherreport_check_process_calls.erl b/src/weatherreport/src/weatherreport_check_process_calls.erl index 750ab237e..854570a7b 100644 --- a/src/weatherreport/src/weatherreport_check_process_calls.erl +++ b/src/weatherreport/src/weatherreport_check_process_calls.erl @@ -59,9 +59,9 @@ fold_processes([{Count, {M, F, A}} | T], Acc, Lim, CallType, Opts) -> Message = case proplists:get_value(expert, Opts) of true -> PidFun = list_to_atom("find_by_" ++ CallType ++ "_call"), - Pids = weatherreport_node:local_command(recon, PidFun, [M, F]), + Pids = erlang:apply(recon, PidFun, [M, F]), Pinfos = lists:map(fun(Pid) -> - Pinfo = weatherreport_node:local_command(recon, info, [Pid]), + Pinfo = recon:info(Pid), {Pid, Pinfo} end, lists:sublist(Pids, 10)), {Level, {process_count, {CallType, Count, M, F, A, Pinfos}}}; @@ -72,11 +72,7 @@ fold_processes([{Count, {M, F, A}} | T], Acc, Lim, CallType, Opts) -> -spec check(list()) -> [{atom(), term()}]. check(Opts) -> - CurrentCallCounts = weatherreport_node:local_command( - recon, - show_current_call_counts, - [] - ), + CurrentCallCounts = recon:show_current_call_counts(), CurrentCallMessages = fold_processes( CurrentCallCounts, [], @@ -84,11 +80,7 @@ check(Opts) -> "current", Opts ), - FirstCallCounts = weatherreport_node:local_command( - recon, - show_first_call_counts, - [] - ), + FirstCallCounts = recon:show_first_call_counts(), lists:reverse(fold_processes( FirstCallCounts, CurrentCallMessages, diff --git a/src/weatherreport/src/weatherreport_check_search.erl b/src/weatherreport/src/weatherreport_check_search.erl index 6237d0d4d..29fe05029 100644 --- a/src/weatherreport/src/weatherreport_check_search.erl +++ b/src/weatherreport/src/weatherreport_check_search.erl @@ -43,7 +43,7 @@ valid() -> -spec check(list()) -> [{atom(), term()}]. check(_Opts) -> SearchNode = 'clouseau@127.0.0.1', - case weatherreport_node:local_command(net_adm, ping, [SearchNode]) of + case net_adm:ping(SearchNode) of pong -> [{info, {clouseau_ok, SearchNode}}]; Error -> diff --git a/src/weatherreport/src/weatherreport_util.erl b/src/weatherreport/src/weatherreport_util.erl index 7e8eade03..e5202fa9e 100644 --- a/src/weatherreport/src/weatherreport_util.erl +++ b/src/weatherreport/src/weatherreport_util.erl @@ -86,7 +86,7 @@ flush_stdout() -> %% by recon:proc_count/2. -spec check_proc_count(atom(), integer(), list()) -> [{atom(), term()}]. check_proc_count(Key, Threshold, Opts) -> - Processes = weatherreport_node:local_command(recon, proc_count, [Key, 10]), + Processes = recon:proc_count(Key, 10), procs_to_messages(Processes, Threshold, [], Opts). %% @doc Utility function to convert the list of process info returned by @@ -101,7 +101,7 @@ procs_to_messages([{Pid, Value, Info} | T], Threshold, Acc, Opts) -> end, Message = case {Level, proplists:get_value(expert, Opts)} of {warning, true} -> - Pinfo = weatherreport_node:local_command(recon, info, [Pid]), + Pinfo = recon:info(Pid), {warning, {high, {Pid, Value, Info, Pinfo}}}; {warning, _} -> {warning, {high, {Pid, Value, Info}}}; |