summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Aksola <anton.aksola@nebula.fi>2014-03-13 17:38:49 +0200
committerAnton Aksola <anton.aksola@nebula.fi>2014-03-13 17:38:49 +0200
commitc045382479da3ec369e54bab678056cad804a343 (patch)
tree5b2f4a4a0a92e32d81d858a9e320b9a033a583fc
parent07b534e541a69f2e90f8924e1dbe3303cdd7d2f2 (diff)
modified worker to work on a node only once per interval
-rw-r--r--lib/oxidized/nodes.rb2
-rw-r--r--lib/oxidized/worker.rb6
2 files changed, 8 insertions, 0 deletions
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