diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2011-07-21 18:08:49 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2011-07-21 18:08:49 +0100 |
| commit | b1929763fbcec8108ce02ef372806176c09b03ca (patch) | |
| tree | 7a05d5d68061d7bc71a9606f81874a28ff4ad17d /src | |
| parent | 57076e95920128cbd425e3e252cd4948aa6c0dd4 (diff) | |
| download | rabbitmq-server-git-b1929763fbcec8108ce02ef372806176c09b03ca.tar.gz | |
Support optionally formatting the priority queue mailbox, and do so on the queue.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gen_server2.erl | 23 | ||||
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 13 |
2 files changed, 27 insertions, 9 deletions
diff --git a/src/gen_server2.erl b/src/gen_server2.erl index 43e0a8f5df..d1b24714be 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -1161,17 +1161,22 @@ format_status(Opt, StatusData) -> end, Header = lists:concat(["Status for generic server ", NameTag]), Log = sys:get_debug(log, Debug, []), - Specfic = - case erlang:function_exported(Mod, format_status, 2) of - true -> case catch Mod:format_status(Opt, [PDict, State]) of - {'EXIT', _} -> [{data, [{"State", State}]}]; - Else -> Else - end; - _ -> [{data, [{"State", State}]}] - end, + Specfic = callback_format_status(Opt, Mod, format_status, [PDict, State], + [{data, [{"State", State}]}]), + Messages = callback_format_status(Opt, Mod, format_priority_mailbox, Queue, + priority_queue:to_list(Queue)), [{header, Header}, {data, [{"Status", SysState}, {"Parent", Parent}, {"Logged events", Log}, - {"Queued messages", priority_queue:to_list(Queue)}]} | + {"Queued messages", Messages}]} | Specfic]. + +callback_format_status(Opt, Mod, FunName, Args, Default) -> + case erlang:function_exported(Mod, FunName, 2) of + true -> case catch Mod:FunName(Opt, Args) of + {'EXIT', _} -> Default; + Else -> Else + end; + _ -> Default + end. diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index fcd6cc24e2..60c1135e01 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -35,6 +35,8 @@ -export([init_with_backing_queue_state/7]). +-export([format_priority_mailbox/2]). + %% Queue's state -record(q, {q, exclusive_consumer, @@ -1162,3 +1164,14 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, State1 = State#q{stats_timer = rabbit_event:stop_stats_timer(StatsTimer), backing_queue_state = BQS3}, {hibernate, stop_rate_timer(State1)}. + +format_priority_mailbox(_Opt, Mailbox) -> + Len = priority_queue:len(Mailbox), + case Len > 100 of + false -> {Len, priority_queue:to_list(Mailbox)}; + true -> {Len, {dict:to_list( + lists:foldl( + fun ({P, _V}, Counts) -> + dict:update_counter(P, 1, Counts) + end, dict:new(), priority_queue:to_list(Mailbox)))}} + end. |
