From 6634f355d99ede5ad6cd6149324d028e455c6eee Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sun, 22 Feb 2015 12:12:26 +0200 Subject: Allow node to be removed while collecting Closes #68 (hopefully at least) Further, our TODO to refactor/redesign the code to move state from memory to disk should help. --- lib/oxidized/worker.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 8fe7ab5..99fc8b8 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -3,12 +3,14 @@ module Oxidized require 'oxidized/jobs' class Worker MAX_INTER_JOB_GAP = 300 + def initialize nodes @nodes = nodes @jobs = Jobs.new CFG.threads, CFG.interval, @nodes @last = Time.now.utc Thread.abort_on_exception = true end + def work ended = [] @jobs.delete_if { |job| ended << job if not job.alive? } @@ -28,6 +30,7 @@ module Oxidized @jobs.push Job.new node end end + def process job node = job.node node.last = job @@ -53,6 +56,9 @@ module Oxidized end Log.warn msg end + rescue NodeNotFound + Log.warn "#{node.name} not found, removed while collecting?" end + end end -- cgit v1.2.1