summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@lshift.net>2008-12-04 22:16:17 +0000
committerEmile Joubert <emile@lshift.net>2008-12-04 22:16:17 +0000
commit4aff72c2ce9d15b76f36d96412aa794910a9487c (patch)
tree72d98efef662c7f11bcca5cc3b64d35a49bcbdb7
parent01edae376fe7394f8fb868e800e0fbe200278f5a (diff)
parent84030fb5c52543c9fa700c46cb18f7d6bce5f2a2 (diff)
downloadrabbitmq-server-4aff72c2ce9d15b76f36d96412aa794910a9487c.tar.gz
Merge bug18381 into bug19684
-rw-r--r--src/rabbit_amqqueue.erl23
-rw-r--r--src/rabbit_exchange.erl38
2 files changed, 29 insertions, 32 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index 694e525e..0dc87ab4 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, list/0, list_vhost_queues/1,
+-export([lookup/1, with/2, with_or_die/2,
stat/1, stat_all/0, deliver/5, redeliver/2, requeue/3, ack/4]).
--export([info/1, info/2, info_all/0, info_all/1]).
+-export([list/1, info/1, info/2, info_all/1, info_all/2]).
-export([claim_queue/2]).
-export([basic_get/3, basic_consume/7, basic_cancel/4]).
-export([notify_sent/2]).
@@ -63,12 +63,11 @@
-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/0 :: () -> [amqqueue()]).
--spec(list_vhost_queues/1 :: (vhost()) -> [amqqueue()]).
+-spec(list/1 :: (vhost()) -> [amqqueue()]).
-spec(info/1 :: (amqqueue()) -> [info()]).
-spec(info/2 :: (amqqueue(), [info_key()]) -> [info()]).
--spec(info_all/0 :: () -> [[info()]]).
--spec(info_all/1 :: ([info_key()]) -> [[info()]]).
+-spec(info_all/1 :: (vhost()) -> [[info()]]).
+-spec(info_all/2 :: (vhost(), [info_key()]) -> [[info()]]).
-spec(stat/1 :: (amqqueue()) -> qstats()).
-spec(stat_all/0 :: () -> [qstats()]).
-spec(delete/3 ::
@@ -185,14 +184,12 @@ with_or_die(Name, F) ->
not_found, "no ~s", [rabbit_misc:rs(Name)])
end).
-list() -> rabbit_misc:dirty_read_all(amqqueue).
-
-map(F) -> rabbit_misc:filter_exit_map(F, list()).
-
-list_vhost_queues(VHostPath) ->
+list(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).
@@ -202,9 +199,9 @@ info(#amqqueue{ pid = QPid }, Items) ->
{error, Error} -> throw(Error)
end.
-info_all() -> map(fun (Q) -> info(Q) end).
+info_all(VHostPath) -> map(VHostPath, fun (Q) -> info(Q) end).
-info_all(Items) -> map(fun (Q) -> info(Q, Items) end).
+info_all(VHostPath, Items) -> map(VHostPath, 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 9a3caad1..d71f0a5a 100644
--- a/src/rabbit_exchange.erl
+++ b/src/rabbit_exchange.erl
@@ -29,11 +29,10 @@
-include("rabbit_framing.hrl").
-export([recover/0, declare/5, lookup/1, lookup_or_die/1,
- list/0, list_vhost_exchanges/1,
- info/1, info/2, info_all/0, info_all/1,
+ list/1, info/1, info/2, info_all/1, info_all/2,
simple_publish/6, simple_publish/3,
route/2]).
--export([add_binding/4, delete_binding/4, list_bindings/0]).
+-export([add_binding/4, delete_binding/4, list_bindings/1]).
-export([delete/2]).
-export([delete_bindings_for_queue/1]).
-export([check_type/1, assert_type/2, topic_matches/2]).
@@ -63,12 +62,11 @@
-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/0 :: () -> [exchange()]).
--spec(list_vhost_exchanges/1 :: (vhost()) -> [exchange()]).
+-spec(list/1 :: (vhost()) -> [exchange()]).
-spec(info/1 :: (exchange()) -> [info()]).
-spec(info/2 :: (exchange(), [info_key()]) -> [info()]).
--spec(info_all/0 :: () -> [[info()]]).
--spec(info_all/1 :: ([info_key()]) -> [[info()]]).
+-spec(info_all/1 :: (vhost()) -> [[info()]]).
+-spec(info_all/2 :: (vhost(), [info_key()]) -> [[info()]]).
-spec(simple_publish/6 ::
(bool(), bool(), exchange_name(), routing_key(), binary(), binary()) ->
publish_res()).
@@ -80,7 +78,7 @@
-spec(delete_binding/4 ::
(exchange_name(), queue_name(), routing_key(), amqp_table()) ->
bind_res() | {'error', 'binding_not_found'}).
--spec(list_bindings/0 :: () ->
+-spec(list_bindings/1 :: (vhost()) ->
[{exchange_name(), queue_name(), routing_key(), amqp_table()}]).
-spec(delete_bindings_for_queue/1 :: (queue_name()) -> 'ok').
-spec(topic_matches/2 :: (binary(), binary()) -> bool()).
@@ -164,16 +162,14 @@ lookup_or_die(Name) ->
not_found, "no ~s", [rabbit_misc:rs(Name)])
end.
-list() -> rabbit_misc:dirty_read_all(exchange).
+list(VHostPath) ->
+ mnesia:dirty_match_object(
+ #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}).
-map(F) ->
+map(VHostPath, F) ->
%% TODO: there is scope for optimisation here, e.g. using a
%% cursor, parallelising the function invocation
- lists:map(F, list()).
-
-list_vhost_exchanges(VHostPath) ->
- mnesia:dirty_match_object(
- #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}).
+ lists:map(F, list(VHostPath)).
infos(Items, X) -> [{Item, i(Item, X)} || Item <- Items].
@@ -188,9 +184,9 @@ info(X = #exchange{}) -> infos(?INFO_KEYS, X).
info(X = #exchange{}, Items) -> infos(Items, X).
-info_all() -> map(fun (X) -> info(X) end).
+info_all(VHostPath) -> map(VHostPath, fun (X) -> info(X) end).
-info_all(Items) -> map(fun (X) -> info(X, Items) end).
+info_all(VHostPath, Items) -> map(VHostPath, fun (X) -> info(X, Items) end).
%% Usable by Erlang code that wants to publish messages.
simple_publish(Mandatory, Immediate, ExchangeName, RoutingKeyBin,
@@ -370,14 +366,18 @@ sync_binding(ExchangeName, QueueName, RoutingKey, Arguments, Durable, Fun) ->
R <- tuple_to_list(route_with_reverse(Binding))],
ok.
-list_bindings() ->
+list_bindings(VHostPath) ->
[{ExchangeName, QueueName, RoutingKey, Arguments} ||
#route{binding = #binding{
exchange_name = ExchangeName,
key = RoutingKey,
queue_name = QueueName,
args = Arguments}}
- <- rabbit_misc:dirty_read_all(route)].
+ <- mnesia:dirty_match_object(
+ #route{binding = #binding{
+ exchange_name = rabbit_misc:r(VHostPath, exchange),
+ _ = '_'},
+ _ = '_'})].
route_with_reverse(#route{binding = Binding}) ->
route_with_reverse(Binding);