diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-06-18 13:29:14 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-06-18 13:29:14 +0100 |
| commit | 9f61337d1a4cd6f2d371f32c4db821d67362f620 (patch) | |
| tree | a4c6d435e4340ffe4af7fc82bda1fdde2e5965e3 | |
| parent | 0e01ca40fab1b62eb55687c42b9a2ab35903ee0d (diff) | |
| download | rabbitmq-server-git-9f61337d1a4cd6f2d371f32c4db821d67362f620.tar.gz | |
sanitise ram_duration and target_duration_count so they don't have to both cope with being all of infinity, undefined and a number.
| -rw-r--r-- | src/rabbit_tests.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_variable_queue.erl | 19 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index dce4d46e7c..38b01b2c8e 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -1797,7 +1797,7 @@ test_variable_queue_dynamic_duration_change_f(Len, VQ0) -> end, {ok, _TRef} = timer:send_after(1000, {duration, N1, Fun1}), {_Duration, VQ4} = rabbit_variable_queue:ram_duration(VQ3), - VQ5 = %% /37 otherwise the duration is just to high to stress things + VQ5 = %% /37 otherwise the duration is just too 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)]), test_variable_queue_dynamic_duration_change_f(Len, VQ5) diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 34fc8cfdc7..7c5e527fdd 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -261,8 +261,8 @@ persistent_count :: non_neg_integer(), transient_threshold :: non_neg_integer(), - duration_target :: non_neg_integer(), - target_ram_msg_count :: non_neg_integer(), + duration_target :: number() | 'infinity', + target_ram_msg_count :: non_neg_integer() | 'infinity', ram_msg_count :: non_neg_integer(), ram_msg_count_prev :: non_neg_integer(), ram_index_count :: non_neg_integer(), @@ -357,8 +357,8 @@ init(QueueName, IsDurable, _Recover) -> len = DeltaCount1, persistent_count = DeltaCount1, - duration_target = undefined, - target_ram_msg_count = undefined, + duration_target = infinity, + target_ram_msg_count = infinity, ram_msg_count = 0, ram_msg_count_prev = 0, ram_index_count = 0, @@ -585,13 +585,12 @@ set_ram_duration_target(DurationTarget, Rate = AvgEgressRate + AvgIngressRate, TargetRamMsgCount1 = case DurationTarget of - infinity -> undefined; - undefined -> undefined; + infinity -> infinity; _ -> trunc(DurationTarget * Rate) %% msgs = sec * msgs/sec end, State1 = State #vqstate { target_ram_msg_count = TargetRamMsgCount1, duration_target = DurationTarget }, - a(case TargetRamMsgCount1 == undefined orelse + a(case TargetRamMsgCount1 == infinity orelse TargetRamMsgCount1 >= TargetRamMsgCount of true -> State1; false -> reduce_memory_use(State1) @@ -1038,7 +1037,7 @@ fetch_from_q3_to_q4(State = #vqstate { reduce_memory_use(State = #vqstate { ram_msg_count = RamMsgCount, target_ram_msg_count = TargetRamMsgCount }) - when TargetRamMsgCount == undefined orelse TargetRamMsgCount >= RamMsgCount -> + when TargetRamMsgCount =:= infinity orelse TargetRamMsgCount >= RamMsgCount -> State; reduce_memory_use(State = #vqstate { target_ram_msg_count = TargetRamMsgCount }) -> @@ -1054,7 +1053,7 @@ reduce_memory_use(State = #vqstate { msg_storage_type(_SeqId, #vqstate { target_ram_msg_count = TargetRamMsgCount, ram_msg_count = RamMsgCount }) - when TargetRamMsgCount == undefined orelse TargetRamMsgCount > RamMsgCount -> + when TargetRamMsgCount =:= infinity orelse TargetRamMsgCount > RamMsgCount -> msg; msg_storage_type( SeqId, #vqstate { target_ram_msg_count = 0, q3 = Q3 }) -> case bpqueue:out(Q3) of @@ -1324,7 +1323,7 @@ maybe_push_alphas_to_betas(_Generator, _Consumer, _Q, State = #vqstate { ram_msg_count = RamMsgCount, target_ram_msg_count = TargetRamMsgCount }) - when TargetRamMsgCount == undefined orelse TargetRamMsgCount >= RamMsgCount -> + when TargetRamMsgCount =:= infinity orelse TargetRamMsgCount >= RamMsgCount -> State; maybe_push_alphas_to_betas(Generator, Consumer, Q, State) -> case Generator(Q) of |
