summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2016-01-27 18:09:40 +0200
committerytti <saku@ytti.fi>2016-01-27 18:09:40 +0200
commit4fbf00dbd1e295664717f0d963e3aadee3935a19 (patch)
tree74d414aaf24073f95d9dd36a547ad0b40805c7b4
parent3bacf05ab4a21c4f97c59b0fddce7191fa910959 (diff)
parent071ba09110fccd845995a9eecdf35e544662daf1 (diff)
Merge pull request #289 from ocadotechnology/improve-job-durations
Improve job queuing
-rw-r--r--lib/oxidized/jobs.rb7
-rw-r--r--lib/oxidized/nodes.rb1
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb
index ff7f92b..2c656f6 100644
--- a/lib/oxidized/jobs.rb
+++ b/lib/oxidized/jobs.rb
@@ -20,13 +20,18 @@ module Oxidized
end
def duration last
+ if @durations.size > @nodes.size
+ @durations.slice! @nodes.size...@durations.size
+ elsif @durations.size < @nodes.size
+ @durations.fill AVERAGE_DURATION, @durations.size...@nodes.size
+ end
@durations.push(last).shift
@duration = @durations.inject(:+).to_f / @nodes.size #rolling average
new_count
end
def new_count
- @want = ((@nodes.size * @duration) / @interval).to_i
+ @want = ((@nodes.size * @duration) / @interval).ceil
@want = 1 if @want < 1
@want = @nodes.size if @want > @nodes.size
@want = @max if @want > @max
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 0c02d7a..61d2d44 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -147,6 +147,7 @@ module Oxidized
rescue Oxidized::NodeNotFound
end
end
+ sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end }
end
public