summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2010-04-12 12:40:20 +0100
committerMatthew Sackman <matthew@lshift.net>2010-04-12 12:40:20 +0100
commit0c30a3f63b84644a8ebd4f11e7b02a497c9379e8 (patch)
treee11778262081f8b6cad86e7c3411e0d346ef2ef5
parent834f532f059b894f401ef385907fab5c8db29621 (diff)
downloadrabbitmq-server-git-0c30a3f63b84644a8ebd4f11e7b02a497c9379e8.tar.gz
s/(rabbit_variable_queue:)update_/\1/g. Also, fix in amqqueue_process where the result tuple was the wrong way around
-rw-r--r--include/rabbit_backing_queue_type_spec.hrl2
-rw-r--r--src/rabbit_amqqueue_process.erl2
-rw-r--r--src/rabbit_backing_queue_type.erl9
-rw-r--r--src/rabbit_tests.erl6
-rw-r--r--src/rabbit_variable_queue.erl18
5 files changed, 19 insertions, 18 deletions
diff --git a/include/rabbit_backing_queue_type_spec.hrl b/include/rabbit_backing_queue_type_spec.hrl
index ec6db21847..afb549187e 100644
--- a/include/rabbit_backing_queue_type_spec.hrl
+++ b/include/rabbit_backing_queue_type_spec.hrl
@@ -49,7 +49,7 @@
-spec(is_empty/1 :: (state()) -> boolean()).
-spec(set_ram_duration_target/2 ::
(('undefined' | 'infinity' | number()), state()) -> state()).
--spec(update_ram_duration/1 :: (state()) -> {number(), state()}).
+-spec(ram_duration/1 :: (state()) -> {number(), state()}).
-spec(sync_callback/1 :: (state()) ->
('undefined' | (fun ((A) -> {boolean(), A})))).
-spec(handle_pre_hibernate/1 :: (state()) -> state()).
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 81bd37aeac..9697cc1347 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -932,7 +932,7 @@ handle_cast({flush, ChPid}, State) ->
handle_cast(update_ram_duration, State = #q{backing_queue_state = BQS,
backing_queue = BQ}) ->
- {BQS1, RamDuration} = BQ:update_ram_duration(BQS),
+ {RamDuration, BQS1} = BQ:ram_duration(BQS),
DesiredDuration =
rabbit_memory_monitor:report_ram_duration(self(), RamDuration),
BQS2 = BQ:set_ram_duration_target(DesiredDuration, BQS1),
diff --git a/src/rabbit_backing_queue_type.erl b/src/rabbit_backing_queue_type.erl
index 8f77d5b185..8e3cce147a 100644
--- a/src/rabbit_backing_queue_type.erl
+++ b/src/rabbit_backing_queue_type.erl
@@ -104,10 +104,11 @@ behaviour_info(callbacks) ->
%% by the duration and the current queue rates.
{set_ram_duration_target, 2},
- %% Recalculate the duration internally (likely to be just update
- %% your internal rates), and report how many seconds the messages
- %% in RAM represent given the current rates of the queue.
- {update_ram_duration, 1},
+ %% Optionally recalculate the duration internally (likely to be
+ %% just update your internal rates), and report how many seconds
+ %% the messages in RAM represent given the current rates of the
+ %% queue.
+ {ram_duration, 1},
%% Can return 'undefined' or a thunk which will receive the
%% state, and must return the state, as soon as the queue process
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 2903a69bcd..b186538ba1 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1384,7 +1384,7 @@ test_variable_queue_dynamic_duration_change() ->
%% start by sending in a couple of segments worth
Len1 = 2*SegmentSize,
VQ1 = variable_queue_publish(false, Len1, VQ0),
- {_Duration, VQ2} = rabbit_variable_queue:update_ram_duration(VQ1),
+ {_Duration, VQ2} = rabbit_variable_queue:ram_duration(VQ1),
{ok, _TRef} = timer:send_after(1000, {duration, 60,
fun (V) -> (V*0.75)-1 end}),
VQ3 = test_variable_queue_dynamic_duration_change_f(Len1, VQ2),
@@ -1420,7 +1420,7 @@ test_variable_queue_dynamic_duration_change_f(Len, VQ0) ->
_ -> Fun
end,
{ok, _TRef} = timer:send_after(1000, {duration, N1, Fun1}),
- {_Duration, VQ4} = rabbit_variable_queue:update_ram_duration(VQ3),
+ {_Duration, VQ4} = rabbit_variable_queue:ram_duration(VQ3),
VQ5 = %% /37 otherwise the duration is just to high to stress things
rabbit_variable_queue:set_ram_duration_target(N/37, VQ4),
io:format("~p:~n~p~n~n", [N, rabbit_variable_queue:status(VQ5)]),
@@ -1434,7 +1434,7 @@ test_variable_queue_partial_segments_delta_thing() ->
HalfSegment = SegmentSize div 2,
VQ0 = fresh_variable_queue(),
VQ1 = variable_queue_publish(true, SegmentSize + HalfSegment, VQ0),
- {_Duration, VQ2} = rabbit_variable_queue:update_ram_duration(VQ1),
+ {_Duration, VQ2} = rabbit_variable_queue:ram_duration(VQ1),
VQ3 = rabbit_variable_queue:set_ram_duration_target(0, VQ2),
%% one segment in q3 as betas, and half a segment in delta
S3 = rabbit_variable_queue:status(VQ3),
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index e929694ff0..bbf78bb7e9 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -32,7 +32,7 @@
-module(rabbit_variable_queue).
-export([init/2, terminate/1, publish/2, publish_delivered/2,
- set_ram_duration_target/2, update_ram_duration/1,
+ set_ram_duration_target/2, ram_duration/1,
fetch/1, ack/2, len/1, is_empty/1, purge/1,
delete_and_terminate/1, requeue/2, tx_publish/2, tx_rollback/2,
tx_commit/4, sync_callback/1, handle_pre_hibernate/1, status/1]).
@@ -372,14 +372,14 @@ set_ram_duration_target(
false -> reduce_memory_use(State1)
end.
-update_ram_duration(State = #vqstate { egress_rate = Egress,
- ingress_rate = Ingress,
- rate_timestamp = Timestamp,
- in_counter = InCount,
- out_counter = OutCount,
- ram_msg_count = RamMsgCount,
- duration_target = DurationTarget,
- ram_msg_count_prev = RamMsgCountPrev }) ->
+ram_duration(State = #vqstate { egress_rate = Egress,
+ ingress_rate = Ingress,
+ rate_timestamp = Timestamp,
+ in_counter = InCount,
+ out_counter = OutCount,
+ ram_msg_count = RamMsgCount,
+ duration_target = DurationTarget,
+ ram_msg_count_prev = RamMsgCountPrev }) ->
Now = now(),
{AvgEgressRate, Egress1} = update_rate(Now, Timestamp, OutCount, Egress),
{AvgIngressRate, Ingress1} = update_rate(Now, Timestamp, InCount, Ingress),