summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Ionescu <vlad@lshift.net>2009-09-16 15:55:42 +0100
committerVlad Ionescu <vlad@lshift.net>2009-09-16 15:55:42 +0100
commit547ccadbe16baa714f8fdaa45cb0dcd21db93954 (patch)
treec799fba157bae1465f9f6d19f3e9f091cd027f07
parentead039b155010045861229aa27424d6c3d7c7197 (diff)
downloadrabbitmq-server-547ccadbe16baa714f8fdaa45cb0dcd21db93954.tar.gz
changing uses of lists:key* functions to proplists:*, where the key is of type atom(); changing parse_status to is_rabbit_running in rabbit_multi
-rw-r--r--src/rabbit_control.erl6
-rw-r--r--src/rabbit_misc.erl6
-rw-r--r--src/rabbit_multi.erl39
-rw-r--r--src/rabbit_plugin_activator.erl2
4 files changed, 28 insertions, 25 deletions
diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl
index cf20520e..e05b1886 100644
--- a/src/rabbit_control.erl
+++ b/src/rabbit_control.erl
@@ -314,7 +314,7 @@ default_if_empty(List, Default) when is_list(List) ->
end.
display_info_list(Results, InfoItemKeys) when is_list(Results) ->
- lists:foreach(fun (Result) -> display_row([format_info_item(Result, X) ||
+ lists:foreach(fun (Result) -> display_row([format_info_item(X, Result) ||
X <- InfoItemKeys])
end, Results),
ok;
@@ -325,8 +325,8 @@ display_row(Row) ->
io:fwrite(lists:flatten(rabbit_misc:intersperse("\t", Row))),
io:nl().
-format_info_item(Items, Key) ->
- {value, Info = {Key, Value}} = lists:keysearch(Key, 1, Items),
+format_info_item(Key, Items) ->
+ Info = {Key, Value} = proplists:lookup(Key, Items),
case Info of
{_, #resource{name = Name}} ->
escape(Name);
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 95a274e3..814e3c31 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -189,9 +189,9 @@ r(VHostPath, Kind) when is_binary(VHostPath) ->
r_arg(#resource{virtual_host = VHostPath}, Kind, Table, Key) ->
r_arg(VHostPath, Kind, Table, Key);
r_arg(VHostPath, Kind, Table, Key) ->
- case lists:keysearch(Key, 1, Table) of
- {value, {_, longstr, NameBin}} -> r(VHostPath, Kind, NameBin);
- false -> undefined
+ case proplists:lookup(Key, Table) of
+ {_, longstr, NameBin} -> r(VHostPath, Kind, NameBin);
+ none -> undefined
end.
rs(#resource{virtual_host = VHostPath, kind = Kind, name = Name}) ->
diff --git a/src/rabbit_multi.erl b/src/rabbit_multi.erl
index d9197535..6fc7bd67 100644
--- a/src/rabbit_multi.erl
+++ b/src/rabbit_multi.erl
@@ -114,12 +114,13 @@ action(status, [], RpcTimeout) ->
io:format("Status of all running nodes...~n", []),
call_all_nodes(
fun({Node, Pid}) ->
- Status = rpc:call(Node, rabbit, status, [], RpcTimeout),
+ RabbitRunning =
+ case is_rabbit_running(Node, RpcTimeout) of
+ false -> not_running;
+ true -> running
+ end,
io:format("Node '~p' with Pid ~p: ~p~n",
- [Node, Pid, case parse_status(Status) of
- false -> not_running;
- true -> running
- end])
+ [Node, Pid, RabbitRunning])
end);
action(stop_all, [], RpcTimeout) ->
@@ -197,7 +198,7 @@ start_node(NodeName, NodePort, RpcTimeout) ->
wait_for_rabbit_to_start(_ , RpcTimeout, _) when RpcTimeout < 0 ->
false;
wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
- case parse_status(rpc:call(Node, rabbit, status, [])) of
+ case is_rabbit_running(Node, RpcTimeout) of
true -> true;
false -> receive
{'EXIT', Port, PosixCode} ->
@@ -211,22 +212,24 @@ wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
run_cmd(FullPath) ->
erlang:open_port({spawn, FullPath}, [nouse_stdio]).
-parse_status({badrpc, _}) ->
- false;
-
-parse_status(Status) ->
- case lists:keysearch(running_applications, 1, Status) of
- {value, {running_applications, Apps}} ->
- lists:keymember(rabbit, 1, Apps);
- _ ->
- false
+is_rabbit_running(Node, RpcTimeout) ->
+ case rpc:call(Node, rabbit, status, [], RpcTimeout) of
+ {badrpc, _} ->
+ false;
+ Status ->
+ case proplists:lookup(running_applications, Status) of
+ {running_applications, Apps} ->
+ proplists:is_defined(rabbit, Apps);
+ none ->
+ false
+ end
end.
with_os(Handlers) ->
{OsFamily, _} = os:type(),
- case lists:keysearch(OsFamily, 1, Handlers) of
- {value, {_, Handler}} -> Handler();
- false -> throw({unsupported_os, OsFamily})
+ case proplists:lookup(OsFamily, Handlers) of
+ {_, Handler} -> Handler();
+ none -> throw({unsupported_os, OsFamily})
end.
script_filename() ->
diff --git a/src/rabbit_plugin_activator.erl b/src/rabbit_plugin_activator.erl
index 71278bfb..0206f73e 100644
--- a/src/rabbit_plugin_activator.erl
+++ b/src/rabbit_plugin_activator.erl
@@ -68,7 +68,7 @@ start() ->
AppList
end,
AppVersions = [determine_version(App) || App <- AllApps],
- {value, {rabbit, RabbitVersion}} = lists:keysearch(rabbit, 1, AppVersions),
+ {rabbit, RabbitVersion} = proplists:lookup(rabbit, AppVersions),
%% Build the overall release descriptor
RDesc = {release,