diff options
author | Matthias Radestock <matthias@lshift.net> | 2008-12-03 17:19:58 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2008-12-03 17:19:58 +0000 |
commit | 692ed4bdb667ea174584d0bbc7f813eb5eaeef44 (patch) | |
tree | 7517e5d173fd84ea8adc2faf375d1d4b51f34a9c | |
parent | 256164958a1b1a45bd2850cdf8eab95bd83cac87 (diff) | |
download | rabbitmq-server-692ed4bdb667ea174584d0bbc7f813eb5eaeef44.tar.gz |
Backed out changeset 6ad1a9e059d0
committed on wrong branch
-rw-r--r-- | src/rabbit_access_control.erl | 4 | ||||
-rw-r--r-- | src/rabbit_amqqueue.erl | 23 | ||||
-rw-r--r-- | src/rabbit_exchange.erl | 38 |
3 files changed, 34 insertions, 31 deletions
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl index 0b39c53e..4342e15b 100644 --- a/src/rabbit_access_control.erl +++ b/src/rabbit_access_control.erl @@ -197,7 +197,7 @@ delete_vhost(VHostPath) -> lists:foreach(fun (Q) -> {ok,_} = rabbit_amqqueue:delete(Q, false, false) end, - rabbit_amqqueue:list(VHostPath)), + rabbit_amqqueue:list_vhost_queues(VHostPath)), R = rabbit_misc:execute_mnesia_transaction( rabbit_misc:with_vhost( VHostPath, @@ -211,7 +211,7 @@ internal_delete_vhost(VHostPath) -> lists:foreach(fun (#exchange{name=Name}) -> ok = rabbit_exchange:delete(Name, false) end, - rabbit_exchange:list(VHostPath)), + rabbit_exchange:list_vhost_exchanges(VHostPath)), lists:foreach(fun (Username) -> ok = unmap_user_vhost(Username, VHostPath) end, diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 0dc87ab4..694e525e 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -27,9 +27,9 @@ -export([start/0, recover/0, declare/4, delete/3, purge/1, internal_delete/1]). -export([pseudo_queue/2]). --export([lookup/1, with/2, with_or_die/2, +-export([lookup/1, with/2, with_or_die/2, list/0, list_vhost_queues/1, stat/1, stat_all/0, deliver/5, redeliver/2, requeue/3, ack/4]). --export([list/1, info/1, info/2, info_all/1, info_all/2]). +-export([info/1, info/2, info_all/0, info_all/1]). -export([claim_queue/2]). -export([basic_get/3, basic_consume/7, basic_cancel/4]). -export([notify_sent/2]). @@ -63,11 +63,12 @@ -spec(lookup/1 :: (queue_name()) -> {'ok', amqqueue()} | not_found()). -spec(with/2 :: (queue_name(), qfun(A)) -> A | not_found()). -spec(with_or_die/2 :: (queue_name(), qfun(A)) -> A). --spec(list/1 :: (vhost()) -> [amqqueue()]). +-spec(list/0 :: () -> [amqqueue()]). +-spec(list_vhost_queues/1 :: (vhost()) -> [amqqueue()]). -spec(info/1 :: (amqqueue()) -> [info()]). -spec(info/2 :: (amqqueue(), [info_key()]) -> [info()]). --spec(info_all/1 :: (vhost()) -> [[info()]]). --spec(info_all/2 :: (vhost(), [info_key()]) -> [[info()]]). +-spec(info_all/0 :: () -> [[info()]]). +-spec(info_all/1 :: ([info_key()]) -> [[info()]]). -spec(stat/1 :: (amqqueue()) -> qstats()). -spec(stat_all/0 :: () -> [qstats()]). -spec(delete/3 :: @@ -184,12 +185,14 @@ with_or_die(Name, F) -> not_found, "no ~s", [rabbit_misc:rs(Name)]) end). -list(VHostPath) -> +list() -> rabbit_misc:dirty_read_all(amqqueue). + +map(F) -> rabbit_misc:filter_exit_map(F, list()). + +list_vhost_queues(VHostPath) -> mnesia:dirty_match_object( #amqqueue{name = rabbit_misc:r(VHostPath, queue), _ = '_'}). -map(VHostPath, F) -> rabbit_misc:filter_exit_map(F, list(VHostPath)). - info(#amqqueue{ pid = QPid }) -> gen_server:call(QPid, info). @@ -199,9 +202,9 @@ info(#amqqueue{ pid = QPid }, Items) -> {error, Error} -> throw(Error) end. -info_all(VHostPath) -> map(VHostPath, fun (Q) -> info(Q) end). +info_all() -> map(fun (Q) -> info(Q) end). -info_all(VHostPath, Items) -> map(VHostPath, fun (Q) -> info(Q, Items) end). +info_all(Items) -> map(fun (Q) -> info(Q, Items) end). stat(#amqqueue{pid = QPid}) -> gen_server:call(QPid, stat). diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index d71f0a5a..9a3caad1 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -29,10 +29,11 @@ -include("rabbit_framing.hrl"). -export([recover/0, declare/5, lookup/1, lookup_or_die/1, - list/1, info/1, info/2, info_all/1, info_all/2, + list/0, list_vhost_exchanges/1, + info/1, info/2, info_all/0, info_all/1, simple_publish/6, simple_publish/3, route/2]). --export([add_binding/4, delete_binding/4, list_bindings/1]). +-export([add_binding/4, delete_binding/4, list_bindings/0]). -export([delete/2]). -export([delete_bindings_for_queue/1]). -export([check_type/1, assert_type/2, topic_matches/2]). @@ -62,11 +63,12 @@ -spec(assert_type/2 :: (exchange(), atom()) -> 'ok'). -spec(lookup/1 :: (exchange_name()) -> {'ok', exchange()} | not_found()). -spec(lookup_or_die/1 :: (exchange_name()) -> exchange()). --spec(list/1 :: (vhost()) -> [exchange()]). +-spec(list/0 :: () -> [exchange()]). +-spec(list_vhost_exchanges/1 :: (vhost()) -> [exchange()]). -spec(info/1 :: (exchange()) -> [info()]). -spec(info/2 :: (exchange(), [info_key()]) -> [info()]). --spec(info_all/1 :: (vhost()) -> [[info()]]). --spec(info_all/2 :: (vhost(), [info_key()]) -> [[info()]]). +-spec(info_all/0 :: () -> [[info()]]). +-spec(info_all/1 :: ([info_key()]) -> [[info()]]). -spec(simple_publish/6 :: (bool(), bool(), exchange_name(), routing_key(), binary(), binary()) -> publish_res()). @@ -78,7 +80,7 @@ -spec(delete_binding/4 :: (exchange_name(), queue_name(), routing_key(), amqp_table()) -> bind_res() | {'error', 'binding_not_found'}). --spec(list_bindings/1 :: (vhost()) -> +-spec(list_bindings/0 :: () -> [{exchange_name(), queue_name(), routing_key(), amqp_table()}]). -spec(delete_bindings_for_queue/1 :: (queue_name()) -> 'ok'). -spec(topic_matches/2 :: (binary(), binary()) -> bool()). @@ -162,14 +164,16 @@ lookup_or_die(Name) -> not_found, "no ~s", [rabbit_misc:rs(Name)]) end. -list(VHostPath) -> - mnesia:dirty_match_object( - #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}). +list() -> rabbit_misc:dirty_read_all(exchange). -map(VHostPath, F) -> +map(F) -> %% TODO: there is scope for optimisation here, e.g. using a %% cursor, parallelising the function invocation - lists:map(F, list(VHostPath)). + lists:map(F, list()). + +list_vhost_exchanges(VHostPath) -> + mnesia:dirty_match_object( + #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}). infos(Items, X) -> [{Item, i(Item, X)} || Item <- Items]. @@ -184,9 +188,9 @@ info(X = #exchange{}) -> infos(?INFO_KEYS, X). info(X = #exchange{}, Items) -> infos(Items, X). -info_all(VHostPath) -> map(VHostPath, fun (X) -> info(X) end). +info_all() -> map(fun (X) -> info(X) end). -info_all(VHostPath, Items) -> map(VHostPath, fun (X) -> info(X, Items) end). +info_all(Items) -> map(fun (X) -> info(X, Items) end). %% Usable by Erlang code that wants to publish messages. simple_publish(Mandatory, Immediate, ExchangeName, RoutingKeyBin, @@ -366,18 +370,14 @@ sync_binding(ExchangeName, QueueName, RoutingKey, Arguments, Durable, Fun) -> R <- tuple_to_list(route_with_reverse(Binding))], ok. -list_bindings(VHostPath) -> +list_bindings() -> [{ExchangeName, QueueName, RoutingKey, Arguments} || #route{binding = #binding{ exchange_name = ExchangeName, key = RoutingKey, queue_name = QueueName, args = Arguments}} - <- mnesia:dirty_match_object( - #route{binding = #binding{ - exchange_name = rabbit_misc:r(VHostPath, exchange), - _ = '_'}, - _ = '_'})]. + <- rabbit_misc:dirty_read_all(route)]. route_with_reverse(#route{binding = Binding}) -> route_with_reverse(Binding); |