diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-08-11 18:18:36 +0200 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-08-11 18:18:36 +0200 |
| commit | 3863a9d07ce7c8e3e9e12260cbe8cbe1bba144aa (patch) | |
| tree | 27c00653f8dd8e45abd70b8c0e17a5de1bfd7e0b | |
| parent | 9b0752685d65bb73a19912a494efbb70cbcd8e6f (diff) | |
| parent | fc84a3fe8d5ebba37909f8c1e02418956b4351c1 (diff) | |
| download | rabbitmq-server-git-3863a9d07ce7c8e3e9e12260cbe8cbe1bba144aa.tar.gz | |
Merge branch 'rabbitmq-server-233'
| -rw-r--r-- | src/rabbit_queue_consumers.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_queue_location_random.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_variable_queue.erl | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/rabbit_queue_consumers.erl b/src/rabbit_queue_consumers.erl index 34e447ccd3..3ba9f89205 100644 --- a/src/rabbit_queue_consumers.erl +++ b/src/rabbit_queue_consumers.erl @@ -463,6 +463,8 @@ update_use({inactive, Since, Active, Avg}, active) -> Now = time_compat:monotonic_time(micro_seconds), {active, Now, use_avg(Active, Now - Since, Avg)}. +use_avg(0, 0, Avg) -> + Avg; use_avg(Active, Inactive, Avg) -> Time = Inactive + Active, rabbit_misc:moving_average(Time, ?USE_AVG_HALF_LIFE, Active / Time, Avg). diff --git a/src/rabbit_queue_location_random.erl b/src/rabbit_queue_location_random.erl index 6a3d1fea67..6a6f1bd913 100644 --- a/src/rabbit_queue_location_random.erl +++ b/src/rabbit_queue_location_random.erl @@ -40,5 +40,5 @@ description() -> queue_master_location(#amqqueue{}) -> Cluster = rabbit_queue_master_location_misc:all_nodes(), RandomPos = erlang:phash2(time_compat:monotonic_time(), length(Cluster)), - MasterNode = lists:nth(RandomPos, Cluster), + MasterNode = lists:nth(RandomPos + 1, Cluster), {ok, MasterNode}. diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 99ea33b973..f66ba21605 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -809,7 +809,11 @@ update_rates(State = #vqstate{ in_counter = InCount, update_rate(Now, TS, Count, Rate) -> Time = time_compat:convert_time_unit(Now - TS, native, micro_seconds) / ?MICROS_PER_SECOND, - rabbit_misc:moving_average(Time, ?RATE_AVG_HALF_LIFE, Count / Time, Rate). + if + Time == 0 -> Rate; + true -> rabbit_misc:moving_average(Time, ?RATE_AVG_HALF_LIFE, + Count / Time, Rate) + end. ram_duration(State) -> State1 = #vqstate { rates = #rates { in = AvgIngressRate, |
