diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-10-29 12:20:19 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-10-29 12:20:19 +0000 |
commit | 545e1d5c9eeb33d66ce3cc4cdeaafbae2869e6da (patch) | |
tree | 37753c5624758b63fc0a4af1391a7d14532659d9 | |
parent | 2a004a1006a960411f203cc3280592ef4a227bc0 (diff) | |
download | rabbitmq-server-545e1d5c9eeb33d66ce3cc4cdeaafbae2869e6da.tar.gz |
Eliminate list_tx variants since async_dirty is ignored in a tx.
-rw-r--r-- | src/rabbit_amqqueue.erl | 20 | ||||
-rw-r--r-- | src/rabbit_exchange.erl | 20 | ||||
-rw-r--r-- | src/rabbit_policy.erl | 19 | ||||
-rw-r--r-- | src/rabbit_runtime_parameters.erl | 29 |
4 files changed, 45 insertions, 43 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 96bf8f12..8306f134 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -23,8 +23,7 @@ assert_equivalence/5, check_exclusive_access/2, with_exclusive_access_or_die/3, stat/1, deliver/2, deliver_flow/2, requeue/3, ack/3, reject/4]). --export([list/0, list/1, list_tx/1, - info_keys/0, info/1, info/2, info_all/1, info_all/2]). +-export([list/0, list/1, info_keys/0, info/1, info/2, info_all/1, info_all/2]). -export([force_event_refresh/0, notify_policy_changed/1]). -export([consumers/1, consumers_all/1, consumer_info_keys/0]). -export([basic_get/4, basic_consume/10, basic_cancel/4, notify_decorators/1]). @@ -104,7 +103,6 @@ (name(), pid(), qfun(A)) -> A | rabbit_types:channel_exit()). -spec(list/0 :: () -> [rabbit_types:amqqueue()]). -spec(list/1 :: (rabbit_types:vhost()) -> [rabbit_types:amqqueue()]). --spec(list_tx/1 :: (rabbit_types:vhost()) -> [rabbit_types:amqqueue()]). -spec(info_keys/0 :: () -> rabbit_types:info_keys()). -spec(info/1 :: (rabbit_types:amqqueue()) -> rabbit_types:infos()). -spec(info/2 :: @@ -468,12 +466,16 @@ check_dlxrk_arg({Type, _}, _Args) -> list() -> mnesia:dirty_match_object(rabbit_queue, #amqqueue{_ = '_'}). -list(VHostPath) -> mnesia:async_dirty(fun () -> list_tx(VHostPath) end). - -list_tx(VHostPath) -> - mnesia:match_object( - rabbit_queue, - #amqqueue{name = rabbit_misc:r(VHostPath, queue), _ = '_'}, read). +%% Not dirty_match_object since that would not be transactional when used in a +%% tx context +list(VHostPath) -> + mnesia:async_dirty( + fun () -> + mnesia:match_object( + rabbit_queue, + #amqqueue{name = rabbit_misc:r(VHostPath, queue), _ = '_'}, + read) + end). info_keys() -> rabbit_amqqueue_process:info_keys(). diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 52d542df..bb5b63e9 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -20,8 +20,7 @@ -export([recover/0, policy_changed/2, callback/4, declare/6, assert_equivalence/6, assert_args_equivalence/2, check_type/1, - lookup/1, lookup_or_die/1, list/1, list_tx/1, - lookup_scratch/2, update_scratch/3, + lookup/1, lookup_or_die/1, list/1, lookup_scratch/2, update_scratch/3, info_keys/0, info/1, info/2, info_all/1, info_all/2, route/2, delete/2, validate_binding/2]). %% these must be run inside a mnesia tx @@ -63,7 +62,6 @@ (name()) -> rabbit_types:exchange() | rabbit_types:channel_exit()). -spec(list/1 :: (rabbit_types:vhost()) -> [rabbit_types:exchange()]). --spec(list_tx/1 :: (rabbit_types:vhost()) -> [rabbit_types:exchange()]). -spec(lookup_scratch/2 :: (name(), atom()) -> rabbit_types:ok(term()) | rabbit_types:error('not_found')). @@ -246,12 +244,16 @@ lookup_or_die(Name) -> {error, not_found} -> rabbit_misc:not_found(Name) end. -list(VHostPath) -> mnesia:async_dirty(fun () -> list_tx(VHostPath) end). - -list_tx(VHostPath) -> - mnesia:match_object( - rabbit_exchange, - #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}, read). +%% Not dirty_match_object since that would not be transactional when used in a +%% tx context +list(VHostPath) -> + mnesia:async_dirty( + fun () -> + mnesia:match_object( + rabbit_exchange, + #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}, + read) + end). lookup_scratch(Name, App) -> case lookup(Name) of diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl index 6e75792e..f4cab511 100644 --- a/src/rabbit_policy.erl +++ b/src/rabbit_policy.erl @@ -167,18 +167,15 @@ list() -> list(VHost) -> list0(VHost, fun ident/1). -list_tx(VHost) -> - list0_tx(VHost, fun ident/1). - list_formatted(VHost) -> order_policies(list0(VHost, fun format/1)). list0(VHost, DefnFun) -> - mnesia:async_dirty(fun () -> list0_tx(VHost, DefnFun) end). - -list0_tx(VHost, DefnFun) -> - [p(P, DefnFun) || - P <- rabbit_runtime_parameters:list_tx(VHost, <<"policy">>)]. + mnesia:async_dirty( + fun () -> + [p(P, DefnFun) || + P <- rabbit_runtime_parameters:list(VHost, <<"policy">>)] + end). order_policies(PropList) -> lists:sort(fun (A, B) -> pget(priority, A) < pget(priority, B) end, @@ -218,11 +215,11 @@ notify_clear(VHost, <<"policy">>, _Name) -> update_policies(VHost) -> {Xs, Qs} = rabbit_misc:execute_mnesia_transaction( fun() -> - Policies = list_tx(VHost), + Policies = list(VHost), {[update_exchange(X, Policies) || - X <- rabbit_exchange:list_tx(VHost)], + X <- rabbit_exchange:list(VHost)], [update_queue(Q, Policies) || - Q <- rabbit_amqqueue:list_tx(VHost)]} + Q <- rabbit_amqqueue:list(VHost)]} end), [catch notify(X) || X <- Xs], [catch notify(Q) || Q <- Qs], diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl index 4e4be6bc..bcde0078 100644 --- a/src/rabbit_runtime_parameters.erl +++ b/src/rabbit_runtime_parameters.erl @@ -19,7 +19,7 @@ -include("rabbit.hrl"). -export([parse_set/4, set/4, set_any/4, clear/3, clear_any/3, list/0, list/1, - list_component/1, list/2, list_tx/2, list_formatted/1, lookup/3, + list_component/1, list/2, list_formatted/1, lookup/3, value/3, value/4, info_keys/0]). %%---------------------------------------------------------------------------- @@ -43,8 +43,6 @@ -spec(list_component/1 :: (binary()) -> [rabbit_types:infos()]). -spec(list/2 :: (rabbit_types:vhost() | '_', binary() | '_') -> [rabbit_types:infos()]). --spec(list_tx/2 :: (rabbit_types:vhost() | '_', binary() | '_') - -> [rabbit_types:infos()]). -spec(list_formatted/1 :: (rabbit_types:vhost()) -> [rabbit_types:infos()]). -spec(lookup/3 :: (rabbit_types:vhost(), binary(), binary()) -> rabbit_types:infos() | 'not_found'). @@ -141,18 +139,21 @@ list() -> list(VHost) -> list(VHost, '_'). list_component(Component) -> list('_', Component). +%% Not dirty_match_object since that would not be transactional when used in a +%% tx context list(VHost, Component) -> - mnesia:async_dirty(fun () -> list_tx(VHost, Component) end). - -list_tx(VHost, Component) -> - case VHost of - '_' -> ok; - _ -> rabbit_vhost:assert(VHost) - end, - Match = #runtime_parameters{key = {VHost, Component, '_'}, _ = '_'}, - [p(P) || #runtime_parameters{key = {_VHost, Comp, _Name}} = P <- - mnesia:match_object(?TABLE, Match, read), - Comp =/= <<"policy">> orelse Component =:= <<"policy">>]. + mnesia:async_dirty( + fun () -> + case VHost of + '_' -> ok; + _ -> rabbit_vhost:assert(VHost) + end, + Match = #runtime_parameters{key = {VHost, Component, '_'}, + _ = '_'}, + [p(P) || #runtime_parameters{key = {_VHost, Comp, _Name}} = P <- + mnesia:match_object(?TABLE, Match, read), + Comp =/= <<"policy">> orelse Component =:= <<"policy">>] + end). list_formatted(VHost) -> [pset(value, format(pget(value, P)), P) || P <- list(VHost)]. |