From c045382479da3ec369e54bab678056cad804a343 Mon Sep 17 00:00:00 2001 From: Anton Aksola Date: Thu, 13 Mar 2014 17:38:49 +0200 Subject: modified worker to work on a node only once per interval --- lib/oxidized/nodes.rb | 2 ++ lib/oxidized/worker.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 0d9fb47..eab2b1d 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -52,6 +52,8 @@ module Oxidized n.user = opt['user'] n.msg = opt['msg'] n.from = opt['from'] + # set last job to nil so that the node is picked for immediate update + n.last = nil put n end end diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index fcdd6f0..a97e5da 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -13,6 +13,12 @@ module Oxidized ended.each { |job| process job } while @jobs.size < @jobs.want Log.debug "Jobs #{@jobs.size}, Want: #{@jobs.want}" + # ask for next node in queue non destructive way + nextnode = @nodes.first + unless nextnode.last.nil? + break if nextnode.last.end + CFG.interval > Time.now.utc + end + # shift nodes and get the next node node = @nodes.get node.running? ? next : node.running = true @jobs.push Job.new node -- cgit v1.2.1