Skip to content

Commit eb99746

Browse files
author
Vlad Ionescu
committed
merging from default
2 parents 16f9019 + 46bb73b commit eb99746

File tree

11 files changed

+99
-133
lines changed

11 files changed

+99
-133
lines changed

.hgignore

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ erl_crash.dump
88
syntax: regexp
99
^cover/
1010
^dist/
11-
^include/rabbit_framing.hrl$
12-
^src/rabbit_framing.erl$
13-
^rabbit.plt$
14-
^ebin/rabbit.app$
15-
^ebin/rabbit.rel$
16-
^ebin/rabbit.boot$
17-
^ebin/rabbit.script$
11+
^include/rabbit_framing\.hrl$
12+
^src/rabbit_framing\.erl$
13+
^rabbit\.plt$
14+
^ebin/rabbit\.(app|rel|boot|script)$
1815
^plugins/
1916
^priv/plugins/
2017

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,12 @@ $(INCLUDE_DIR)/rabbit_framing.hrl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.p
6565
$(SOURCE_DIR)/rabbit_framing.erl: codegen.py $(AMQP_CODEGEN_DIR)/amqp_codegen.py $(AMQP_SPEC_JSON_PATH)
6666
$(PYTHON) codegen.py body $(AMQP_SPEC_JSON_PATH) $@
6767

68-
$(EBIN_DIR)/rabbit.boot $(EBIN_DIR)/rabbit.script: $(EBIN_DIR)/rabbit.app $(EBIN_DIR)/rabbit.rel $(TARGETS)
69-
erl -noshell -eval 'systools:make_script("ebin/rabbit", [{path, ["ebin"]}]), halt().'
70-
7168
dialyze: $(BEAM_TARGETS)
7269
dialyzer -c $?
7370

7471
clean:
7572
rm -f $(EBIN_DIR)/*.beam
76-
rm -f $(EBIN_DIR)/rabbit.app $(EBIN_DIR)/rabbit.boot $(EBIN_DIR)/rabbit.script
73+
rm -f $(EBIN_DIR)/rabbit.app $(EBIN_DIR)/rabbit.boot $(EBIN_DIR)/rabbit.script $(EBIN_DIR)/rabbit.rel
7774
rm -f $(INCLUDE_DIR)/rabbit_framing.hrl $(SOURCE_DIR)/rabbit_framing.erl codegen.pyc
7875
rm -f docs/*.[0-9].gz
7976

@@ -90,13 +87,14 @@ BASIC_SCRIPT_ENVIRONMENT_SETTINGS=\
9087

9188
run: all
9289
$(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \
93-
RABBITMQ_NODE_ONLY=true \
90+
RABBITMQ_ALLOW_INPUT=true \
9491
RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS) -s rabbit" \
9592
./scripts/rabbitmq-server
9693

9794
run-node: all
9895
$(BASIC_SCRIPT_ENVIRONMENT_SETTINGS) \
9996
RABBITMQ_NODE_ONLY=true \
97+
RABBITMQ_ALLOW_INPUT=true \
10098
RABBITMQ_SERVER_START_ARGS="$(RABBITMQ_SERVER_START_ARGS)" \
10199
./scripts/rabbitmq-server
102100

docs/rabbitmqctl.1.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ separated by tab characters.
287287
List queue information by virtual host. Each line printed describes an
288288
connection, with the requested I<connectioninfoitem> values separated
289289
by tab characters. If no I<connectioninfoitem>s are specified then
290-
I<user>, I<peer_address> and I<peer_port> are assumed.
290+
I<user>, I<peer_address>, I<peer_port> and I<state> are assumed.
291291

292292
=back
293293

ebin/rabbit_app.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
{env, [{tcp_listeners, [{"0.0.0.0", 5672}]},
1818
{ssl_listeners, []},
1919
{ssl_options, []},
20-
{extra_startup_steps, []},
2120
{default_user, <<"guest">>},
2221
{default_pass, <<"guest">>},
2322
{default_vhost, <<"/">>},

packaging/common/rabbitmq-script-wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
## The contents of this file are subject to the Mozilla Public License
33
## Version 1.1 (the "License"); you may not use this file except in
44
## compliance with the License. You may obtain a copy of the License at

scripts/rabbitmq-server

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ else
7373
fi
7474

7575
RABBITMQ_START_RABBIT=
76-
[ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT='-noinput -s rabbit'
76+
[ "x" = "x$RABBITMQ_ALLOW_INPUT" ] && RABBITMQ_START_RABBIT='-noinput'
77+
[ "x" = "x$RABBITMQ_NODE_ONLY" ] && RABBITMQ_START_RABBIT="${RABBITMQ_START_RABBIT} -s rabbit"
7778

7879
RABBITMQ_EBIN_ROOT="${RABBITMQ_HOME}/ebin"
79-
if [ -f "${RABBITMQ_EBIN_ROOT}/rabbit.boot" ]; then
80+
if [ -f "${RABBITMQ_EBIN_ROOT}/rabbit.boot" ] && [ "x" = "x$RABBITMQ_NODE_ONLY" ]; then
8081
RABBITMQ_BOOT_FILE="${RABBITMQ_EBIN_ROOT}/rabbit"
8182
RABBITMQ_EBIN_PATH=""
8283
else

src/rabbit_control.erl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ exchange name, routing key, queue name and arguments, in that order.
164164
<ConnectionInfoItem> must be a member of the list [node, address, port,
165165
peer_address, peer_port, state, channels, user, vhost, timeout, frame_max,
166166
recv_oct, recv_cnt, send_oct, send_cnt, send_pend]. The default is to display
167-
user, peer_address and peer_port.
167+
user, peer_address, peer_port and state.
168168
169169
"),
170170
halt(1).
@@ -270,8 +270,9 @@ action(list_bindings, Node, Args, Inform) ->
270270

271271
action(list_connections, Node, Args, Inform) ->
272272
Inform("Listing connections", []),
273-
ArgAtoms = list_replace(node, pid,
274-
default_if_empty(Args, [user, peer_address, peer_port])),
273+
ArgAtoms = list_replace(node, pid,
274+
default_if_empty(Args, [user, peer_address,
275+
peer_port, state])),
275276
display_info_list(rpc_call(Node, rabbit_networking, connection_info_all,
276277
[ArgAtoms]),
277278
ArgAtoms);
@@ -314,7 +315,7 @@ default_if_empty(List, Default) when is_list(List) ->
314315
end.
315316

316317
display_info_list(Results, InfoItemKeys) when is_list(Results) ->
317-
lists:foreach(fun (Result) -> display_row([format_info_item(Result, X) ||
318+
lists:foreach(fun (Result) -> display_row([format_info_item(X, Result) ||
318319
X <- InfoItemKeys])
319320
end, Results),
320321
ok;
@@ -325,18 +326,20 @@ display_row(Row) ->
325326
io:fwrite(lists:flatten(rabbit_misc:intersperse("\t", Row))),
326327
io:nl().
327328

328-
format_info_item(Items, Key) ->
329-
{value, Info = {Key, Value}} = lists:keysearch(Key, 1, Items),
330-
case Info of
331-
{_, #resource{name = Name}} ->
329+
format_info_item(Key, Items) ->
330+
case proplists:get_value(Key, Items) of
331+
#resource{name = Name} ->
332332
escape(Name);
333-
_ when Key =:= address; Key =:= peer_address andalso is_tuple(Value) ->
333+
Value when Key =:= address; Key =:= peer_address andalso
334+
is_tuple(Value) ->
334335
inet_parse:ntoa(Value);
335-
_ when is_pid(Value) ->
336+
Value when is_pid(Value) ->
336337
atom_to_list(node(Value));
337-
_ when is_binary(Value) ->
338+
Value when is_binary(Value) ->
338339
escape(Value);
339-
_ ->
340+
Value when is_atom(Value) ->
341+
escape(atom_to_list(Value));
342+
Value ->
340343
io_lib:format("~w", [Value])
341344
end.
342345

@@ -362,7 +365,9 @@ rpc_call(Node, Mod, Fun, Args) ->
362365
%% form part of UTF-8 strings.
363366

364367
escape(Bin) when binary(Bin) ->
365-
escape_char(lists:reverse(binary_to_list(Bin)), []).
368+
escape(binary_to_list(Bin));
369+
escape(L) when is_list(L) ->
370+
escape_char(lists:reverse(L), []).
366371

367372
escape_char([$\\ | T], Acc) ->
368373
escape_char(T, [$\\, $\\ | Acc]);

src/rabbit_load.erl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
-ifdef(use_specs).
4242

4343
-type(erlang_node() :: atom()).
44-
-type(load() :: {{non_neg_integer(), float()}, erlang_node()}).
44+
-type(load() :: {{non_neg_integer(), integer() | 'unknown'}, erlang_node()}).
4545
-spec(local_load/0 :: () -> load()).
4646
-spec(remote_loads/0 :: () -> [load()]).
4747
-spec(pick/0 :: () -> erlang_node()).
@@ -52,8 +52,11 @@
5252

5353
local_load() ->
5454
LoadAvg = case whereis(cpu_sup) of
55-
undefined -> 0.0;
56-
_Other -> cpu_sup:avg1()
55+
undefined -> unknown;
56+
_ -> case cpu_sup:avg1() of
57+
L when is_integer(L) -> L;
58+
{error, timeout} -> unknown
59+
end
5760
end,
5861
{{statistics(run_queue), LoadAvg}, node()}.
5962

@@ -65,8 +68,12 @@ remote_loads() ->
6568
pick() ->
6669
RemoteLoads = remote_loads(),
6770
{{RunQ, LoadAvg}, Node} = local_load(),
68-
%% add bias towards current node
69-
AdjustedLoadAvg = LoadAvg * ?FUDGE_FACTOR,
71+
%% add bias towards current node; we rely on Erlang's term order
72+
%% of SomeFloat < local_unknown < unknown.
73+
AdjustedLoadAvg = case LoadAvg of
74+
unknown -> local_unknown;
75+
_ -> LoadAvg * ?FUDGE_FACTOR
76+
end,
7077
Loads = [{{RunQ, AdjustedLoadAvg}, Node} | RemoteLoads],
7178
{_, SelectedNode} = lists:min(Loads),
7279
SelectedNode.

src/rabbit_multi.erl

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ action(status, [], RpcTimeout) ->
114114
io:format("Status of all running nodes...~n", []),
115115
call_all_nodes(
116116
fun({Node, Pid}) ->
117-
Status = rpc:call(Node, rabbit, status, [], RpcTimeout),
117+
RabbitRunning =
118+
case is_rabbit_running(Node, RpcTimeout) of
119+
false -> not_running;
120+
true -> running
121+
end,
118122
io:format("Node '~p' with Pid ~p: ~p~n",
119-
[Node, Pid, case parse_status(Status) of
120-
false -> not_running;
121-
true -> running
122-
end])
123+
[Node, Pid, RabbitRunning])
123124
end);
124125

125126
action(stop_all, [], RpcTimeout) ->
@@ -197,7 +198,7 @@ start_node(NodeName, NodePort, RpcTimeout) ->
197198
wait_for_rabbit_to_start(_ , RpcTimeout, _) when RpcTimeout < 0 ->
198199
false;
199200
wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
200-
case parse_status(rpc:call(Node, rabbit, status, [])) of
201+
case is_rabbit_running(Node, RpcTimeout) of
201202
true -> true;
202203
false -> receive
203204
{'EXIT', Port, PosixCode} ->
@@ -211,22 +212,20 @@ wait_for_rabbit_to_start(Node, RpcTimeout, Port) ->
211212
run_cmd(FullPath) ->
212213
erlang:open_port({spawn, FullPath}, [nouse_stdio]).
213214

214-
parse_status({badrpc, _}) ->
215-
false;
216-
217-
parse_status(Status) ->
218-
case lists:keysearch(running_applications, 1, Status) of
219-
{value, {running_applications, Apps}} ->
220-
lists:keymember(rabbit, 1, Apps);
221-
_ ->
222-
false
215+
is_rabbit_running(Node, RpcTimeout) ->
216+
case rpc:call(Node, rabbit, status, [], RpcTimeout) of
217+
{badrpc, _} -> false;
218+
Status -> case proplists:get_value(running_applications, Status) of
219+
undefined -> false;
220+
Apps -> lists:keymember(rabbit, 1, Apps)
221+
end
223222
end.
224223

225224
with_os(Handlers) ->
226225
{OsFamily, _} = os:type(),
227-
case lists:keysearch(OsFamily, 1, Handlers) of
228-
{value, {_, Handler}} -> Handler();
229-
false -> throw({unsupported_os, OsFamily})
226+
case proplists:get_value(OsFamily, Handlers) of
227+
undefined -> throw({unsupported_os, OsFamily});
228+
Handler -> Handler()
230229
end.
231230

232231
script_filename() ->

src/rabbit_plugin_activator.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ start() ->
6868
AppList
6969
end,
7070
AppVersions = [determine_version(App) || App <- AllApps],
71-
{value, {rabbit, RabbitVersion}} = lists:keysearch(rabbit, 1, AppVersions),
71+
{rabbit, RabbitVersion} = proplists:lookup(rabbit, AppVersions),
7272

7373
%% Build the overall release descriptor
7474
RDesc = {release,

0 commit comments

Comments
 (0)