summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Majkowski <marek@rabbitmq.com>2011-02-18 15:51:53 +0000
committerMarek Majkowski <marek@rabbitmq.com>2011-02-18 15:51:53 +0000
commitb15c279b847aaebe2e43b0af31cd8f69e00e6ab4 (patch)
treed271881a2ade894356e65a107408e4b381174cc9
parent65b14d2a0624956a10d80adc7bccc4f98bf2b633 (diff)
downloadrabbitmq-server-bug23533.tar.gz
:info instead of :get_xbug23533
-rw-r--r--src/file_handle_cache.erl33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/file_handle_cache.erl b/src/file_handle_cache.erl
index ed6394de..fc1cc3f3 100644
--- a/src/file_handle_cache.erl
+++ b/src/file_handle_cache.erl
@@ -146,8 +146,8 @@
-export([open/3, close/1, read/2, append/2, sync/1, position/2, truncate/1,
last_sync_offset/1, current_virtual_offset/1, current_raw_offset/1,
flush/1, copy/3, set_maximum_since_use/1, delete/1, clear/1]).
--export([obtain/0, transfer/1, set_limit/1, get_limit/0, get_obtain_count/0,
- get_obtain_limit/0]).
+-export([obtain/0, transfer/1, set_limit/1, get_limit/0, info_keys/0, info/0,
+ info/1]).
-export([ulimit/0]).
-export([start_link/0, init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -260,13 +260,17 @@
-spec(transfer/1 :: (pid()) -> 'ok').
-spec(set_limit/1 :: (non_neg_integer()) -> 'ok').
-spec(get_limit/0 :: () -> non_neg_integer()).
--spec(get_obtain_count/0 :: () -> non_neg_integer()).
--spec(get_obtain_limit/0 :: () -> 'infinity' | non_neg_integer()).
+-spec(info_keys/0 :: () -> rabbit_types:info_keys()).
+-spec(info/0 :: () -> rabbit_types:infos()).
+-spec(info/1 :: (rabbit_types:info_keys()) -> rabbit_types:infos()).
-spec(ulimit/0 :: () -> 'infinity' | 'unknown' | non_neg_integer()).
-endif.
%%----------------------------------------------------------------------------
+-define(INFO_KEYS, [obtain_count, obtain_limit]).
+
+%%----------------------------------------------------------------------------
%% Public API
%%----------------------------------------------------------------------------
@@ -497,11 +501,10 @@ set_limit(Limit) ->
get_limit() ->
gen_server:call(?SERVER, get_limit, infinity).
-get_obtain_count() ->
- gen_server:call(?SERVER, get_obtain_count, infinity).
+info_keys() -> ?INFO_KEYS.
-get_obtain_limit() ->
- gen_server:call(?SERVER, get_obtain_limit, infinity).
+info() -> info(?INFO_KEYS).
+info(Items) -> gen_server:call(?SERVER, {info, Items}, infinity).
%%----------------------------------------------------------------------------
%% Internal functions
@@ -798,6 +801,12 @@ write_buffer(Handle = #handle { hdl = Hdl, offset = Offset,
{Error, Handle}
end.
+infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items].
+
+i(obtain_count, #fhc_state{obtain_count = Count}) -> Count;
+i(obtain_limit, #fhc_state{obtain_limit = Limit}) -> Limit;
+i(Item, _) -> throw({bad_argument, Item}).
+
%%----------------------------------------------------------------------------
%% gen_server callbacks
%%----------------------------------------------------------------------------
@@ -887,12 +896,8 @@ handle_call({set_limit, Limit}, _From, State) ->
obtain_limit = obtain_limit(Limit) }))};
handle_call(get_limit, _From, State = #fhc_state { limit = Limit }) ->
{reply, Limit, State};
-handle_call(get_obtain_count, _From,
- State = #fhc_state { obtain_count = Count }) ->
- {reply, Count, State};
-handle_call(get_obtain_limit, _From,
- State = #fhc_state { obtain_limit = Limit }) ->
- {reply, Limit, State}.
+handle_call({info, Items}, _From, State) ->
+ {reply, infos(Items, State), State}.
handle_cast({register_callback, Pid, MFA},
State = #fhc_state { clients = Clients }) ->