summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Klishin <michael@clojurewerkz.org>2015-11-02 10:39:41 +0300
committerMichael Klishin <michael@clojurewerkz.org>2015-11-02 10:39:41 +0300
commit0368d6bc50ae6cf7e513439ddf2c46f46df254d6 (patch)
tree3cb92d11084472c431ce99171bc76c3ac4c6ae86 /src
parent03c28ed96e16d05b12d8019969eb3ac8854b242b (diff)
parent412cb9c8197e778182418519a8a1d445319d90a4 (diff)
downloadrabbitmq-server-git-0368d6bc50ae6cf7e513439ddf2c46f46df254d6.tar.gz
Merge branch 'master' into rabbitmq-server-379
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_disk_monitor.erl15
-rw-r--r--src/rabbit_queue_location_validator.erl17
-rw-r--r--src/rabbit_queue_master_location_misc.erl39
3 files changed, 40 insertions, 31 deletions
diff --git a/src/rabbit_disk_monitor.erl b/src/rabbit_disk_monitor.erl
index 68f6095176..3e9171b79a 100644
--- a/src/rabbit_disk_monitor.erl
+++ b/src/rabbit_disk_monitor.erl
@@ -61,7 +61,10 @@
%% timer that drives periodic checks
timer,
%% is free disk space alarm currently in effect?
- alarmed
+ alarmed,
+ %% is monitoring enabled? false on unsupported
+ %% platforms
+ enabled
}).
%%----------------------------------------------------------------------------
@@ -117,7 +120,8 @@ init([Limit]) ->
State = #state{dir = Dir,
min_interval = ?DEFAULT_MIN_DISK_CHECK_INTERVAL,
max_interval = ?DEFAULT_MAX_DISK_CHECK_INTERVAL,
- alarmed = false},
+ alarmed = false,
+ enabled = true},
case {catch get_disk_free(Dir),
vm_memory_monitor:get_total_memory()} of
{N1, N2} when is_integer(N1), is_integer(N2) ->
@@ -125,12 +129,17 @@ init([Limit]) ->
Err ->
rabbit_log:info("Disabling disk free space monitoring "
"on unsupported platform:~n~p~n", [Err]),
- {stop, unsupported_platform}
+ {ok, State#state{enabled = false}}
end.
handle_call(get_disk_free_limit, _From, State = #state{limit = Limit}) ->
{reply, Limit, State};
+handle_call({set_disk_free_limit, _}, _From, #state{enabled = false} = State) ->
+ rabbit_log:info("Cannot set disk free limit: "
+ "disabled disk free space monitoring", []),
+ {reply, ok, State};
+
handle_call({set_disk_free_limit, Limit}, _From, State) ->
{reply, ok, set_disk_limits(State, Limit)};
diff --git a/src/rabbit_queue_location_validator.erl b/src/rabbit_queue_location_validator.erl
index 4eab52855a..00bea44e29 100644
--- a/src/rabbit_queue_location_validator.erl
+++ b/src/rabbit_queue_location_validator.erl
@@ -25,20 +25,20 @@
[{description, "Queue location policy validation"},
{mfa, {rabbit_registry, register,
[policy_validator,
- <<"x-queue-master-locator">>,
+ <<"queue-master-locator">>,
?MODULE]}}]}).
validate_policy(KeyList) ->
- case proplists:lookup(<<"x-queue-master-locator">> , KeyList) of
+ case proplists:lookup(<<"queue-master-locator">> , KeyList) of
{_, Strategy} -> validate_strategy(Strategy);
- _ -> {error, "x-queue-master-locator undefined"}
+ _ -> {error, "queue-master-locator undefined"}
end.
validate_strategy(Strategy) ->
case module(Strategy) of
- R={ok, _M} -> R;
- _ ->
- {error, "~p invalid x-queue-master-locator value", [Strategy]}
+ R = {ok, _M} -> R;
+ _ ->
+ {error, "~p invalid queue-master-locator value", [Strategy]}
end.
policy(Policy, Q) ->
@@ -48,7 +48,7 @@ policy(Policy, Q) ->
end.
module(#amqqueue{} = Q) ->
- case policy(<<"x-queue-master-locator">>, Q) of
+ case policy(<<"queue-master-locator">>, Q) of
undefined -> no_location_strategy;
Mode -> module(Mode)
end;
@@ -63,6 +63,7 @@ module(Strategy) when is_binary(Strategy) ->
non_existing -> no_location_strategy;
_ -> {ok, Module}
end;
- _ -> no_location_strategy
+ _ ->
+ no_location_strategy
end
end.
diff --git a/src/rabbit_queue_master_location_misc.erl b/src/rabbit_queue_master_location_misc.erl
index 279869d054..17f5512f95 100644
--- a/src/rabbit_queue_master_location_misc.erl
+++ b/src/rabbit_queue_master_location_misc.erl
@@ -30,7 +30,7 @@ lookup_master(QueueNameBin, VHostPath) when is_binary(QueueNameBin),
is_binary(VHostPath) ->
Queue = rabbit_misc:r(VHostPath, queue, QueueNameBin),
case rabbit_amqqueue:lookup(Queue) of
- {ok, #amqqueue{pid=Pid}} when is_pid(Pid) ->
+ {ok, #amqqueue{pid = Pid}} when is_pid(Pid) ->
{ok, node(Pid)};
Error -> Error
end.
@@ -45,16 +45,16 @@ lookup_queue(QueueNameBin, VHostPath) when is_binary(QueueNameBin),
get_location(Queue=#amqqueue{})->
Reply1 = case get_location_mod_by_args(Queue) of
- _Err1={error, _} ->
- case get_location_mod_by_policy(Queue) of
- _Err2={error, _} ->
- case get_location_mod_by_config(Queue) of
- Err3={error, _} -> Err3;
- Reply0={ok, _Module} -> Reply0
- end;
- Reply0={ok, _Module} -> Reply0
- end;
- Reply0={ok, _Module} -> Reply0
+ _Err1 = {error, _} ->
+ case get_location_mod_by_policy(Queue) of
+ _Err2 = {error, _} ->
+ case get_location_mod_by_config(Queue) of
+ Err3 = {error, _} -> Err3;
+ Reply0 = {ok, _Module} -> Reply0
+ end;
+ Reply0 = {ok, _Module} -> Reply0
+ end;
+ Reply0 = {ok, _Module} -> Reply0
end,
case Reply1 of
@@ -66,19 +66,19 @@ get_location_mod_by_args(#amqqueue{arguments=Args}) ->
case proplists:lookup(<<"x-queue-master-locator">> , Args) of
{<<"x-queue-master-locator">> , Strategy} ->
case rabbit_queue_location_validator:validate_strategy(Strategy) of
- Reply={ok, _CB} -> Reply;
- Error -> Error
+ Reply = {ok, _CB} -> Reply;
+ Error -> Error
end;
_ -> {error, "x-queue-master-locator undefined"}
end.
get_location_mod_by_policy(Queue=#amqqueue{}) ->
- case rabbit_policy:get(<<"x-queue-master-locator">> , Queue) of
- undefined -> {error, "x-queue-master-locator policy undefined"};
+ case rabbit_policy:get(<<"queue-master-locator">> , Queue) of
+ undefined -> {error, "queue-master-locator policy undefined"};
Strategy ->
case rabbit_queue_location_validator:validate_strategy(Strategy) of
- Reply={ok, _CB} -> Reply;
- Error -> Error
+ Reply = {ok, _CB} -> Reply;
+ Error -> Error
end
end.
@@ -86,11 +86,10 @@ get_location_mod_by_config(#amqqueue{}) ->
case application:get_env(rabbit, queue_master_locator) of
{ok, Strategy} ->
case rabbit_queue_location_validator:validate_strategy(Strategy) of
- Reply={ok, _CB} -> Reply;
- Error -> Error
+ Reply = {ok, _CB} -> Reply;
+ Error -> Error
end;
_ -> {error, "queue_master_locator undefined"}
end.
all_nodes() -> rabbit_mnesia:cluster_nodes(running).
-