diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oxidized/jobs.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/oxidized/jobs.rb b/lib/oxidized/jobs.rb index 6476744..0511b49 100644 --- a/lib/oxidized/jobs.rb +++ b/lib/oxidized/jobs.rb @@ -1,17 +1,17 @@ module Oxidized class Jobs < Array - attr_accessor :interval, :duration, :max, :want + attr_accessor :interval, :max, :want def initialize max, interval, nodes @max = max - #@interval = interval * 60 @interval = interval @nodes = nodes - @duration = 4 + @durations = Array.new(@nodes.size, 5) # guess that nodes take 5s new_count super() end def duration last - @duration = (@duration + last) / 2 + @durations.push(last).shift + @duration = @durations.inject(:+).to_f / @nodes.size #rolling average new_count end def new_count @@ -20,5 +20,8 @@ module Oxidized @want = @nodes.size if @want > @nodes.size @want = @max if @want > @max end + def add_job + @want += 1 + end end end |