diff options
| author | Marek Majkowski <majek@lshift.net> | 2009-11-11 06:25:21 -0500 |
|---|---|---|
| committer | Marek Majkowski <majek@lshift.net> | 2009-11-11 06:25:21 -0500 |
| commit | afcb6ae973b521f682d4e41ef64d59ca9abc41ad (patch) | |
| tree | 859d4a9c91731b07d48a28e0d7d4a3990b28db96 | |
| parent | cf418d2441594dea34f5321f68f48481ee9f9e76 (diff) | |
| download | rabbitmq-server-git-afcb6ae973b521f682d4e41ef64d59ca9abc41ad.tar.gz | |
QA: quoted atoms in specs, timer:now_diff
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 15 | ||||
| -rw-r--r-- | src/rabbit_memory_monitor.erl | 8 | ||||
| -rw-r--r-- | src/vm_memory_monitor.erl | 6 |
3 files changed, 11 insertions, 18 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index fad36f2c00..9b97fe8651 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -99,10 +99,6 @@ start_link(Q) -> gen_server2:start_link(?MODULE, Q, []). %%---------------------------------------------------------------------------- -now_us() -> - {Megaseconds,Seconds,Microseconds} = erlang:now(), - Megaseconds * 1000000 * 1000000 + Seconds * 1000000 + Microseconds. - init(Q) -> ?LOGDEBUG("Queue starting - ~p~n", [Q]), rabbit_memory_monitor:register(self()), @@ -117,7 +113,7 @@ init(Q) -> active_consumers = queue:new(), blocked_consumers = queue:new(), drain_ratio = #ratio{ratio = 0.0, - t0 = now_us(), + t0 = now(), next_msg_id = 1} }, hibernate, {backoff, ?HIBERNATE_AFTER_MIN, ?HIBERNATE_AFTER_MIN, ?DESIRED_HIBERNATE}}. @@ -825,10 +821,7 @@ handle_cast({limit, ChPid, LimiterPid}, State) -> handle_cast(send_memory_monitor_update, State) -> DrainRatio1 = update_ratio(State#q.drain_ratio, State#q.next_msg_id), MsgSec = DrainRatio1#ratio.ratio * 1000000, % msg/sec - QueueDuration = case MsgSec < 0.016 of %% less than 1 msg/1 minute - true -> infinity; - false -> queue:len(State#q.message_buffer) / MsgSec - end, + QueueDuration = queue:len(State#q.message_buffer) / MsgSec, % seconds DesiredQueueDuration = rabbit_memory_monitor:push_queue_duration( self(), QueueDuration), ?LOGDEBUG("~p Queue duration current/desired ~p/~p~n", @@ -854,8 +847,8 @@ calc_load(Load, Exp, N) -> Load*Exp + N*(1.0-Exp). update_ratio(_RatioRec = #ratio{ratio=Ratio, t0 = T0, next_msg_id = MsgCount0}, MsgCount1) -> - T1 = now_us(), - Td = T1 - T0, + T1 = now(), + Td = timer:now_diff(T1, T0), MsgCount = MsgCount1 - MsgCount0, MsgUSec = MsgCount / Td, % msg/usec %% Td is in usec. We're interested in "load average" from last 30 seconds. diff --git a/src/rabbit_memory_monitor.erl b/src/rabbit_memory_monitor.erl index 0629591ad7..ff7684bd16 100644 --- a/src/rabbit_memory_monitor.erl +++ b/src/rabbit_memory_monitor.erl @@ -108,11 +108,11 @@ memory_limit :: pos_integer(), memory_ratio :: float() }). --spec(start_link/0 :: () -> ignore | {error, _} | {ok, pid()}). --spec(register/1 :: (pid()) -> ok). --spec(push_queue_duration/2 :: (pid(), float() | infinity) -> ok). +-spec(start_link/0 :: () -> 'ignore' | {'error', _} | {'ok', pid()}). +-spec(register/1 :: (pid()) -> 'ok'). +-spec(push_queue_duration/2 :: (pid(), float() | 'infinity') -> 'ok'). --spec(init/1 :: ([]) -> {ok, state()}). +-spec(init/1 :: ([]) -> {'ok', state()}). -ifdef(debug). -spec(ftoa/1 :: (any()) -> string()). diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl index 6da6704d8d..65d4a45103 100644 --- a/src/vm_memory_monitor.erl +++ b/src/vm_memory_monitor.erl @@ -74,10 +74,10 @@ -ifdef(use_specs). --spec(start_link/1 :: (float()) -> ('ignore' | {error, any()} | {'ok', pid()})). +-spec(start_link/1 :: (float()) -> ('ignore' | {'error', any()} | {'ok', pid()})). -spec(update/0 :: () -> 'ok'). --spec(get_total_memory/0 :: () -> (non_neg_integer() | unknown)). --spec(get_memory_limit/0 :: () -> (non_neg_integer() | undefined)). +-spec(get_total_memory/0 :: () -> (non_neg_integer() | 'unknown')). +-spec(get_memory_limit/0 :: () -> (non_neg_integer() | 'undefined')). -spec(get_check_interval/0 :: () -> non_neg_integer()). -spec(set_check_interval/1 :: (non_neg_integer()) -> 'ok'). -spec(get_vm_memory_high_watermark/0 :: () -> float()). |
