diff options
author | KodApa85 <parsons151185@gmail.com> | 2018-04-27 13:48:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 13:48:47 +0100 |
commit | a40bb72e78755891ec84f5a4378c30114dae8316 (patch) | |
tree | 5e057527f163fa1bea10cbdc7318b035ff939200 /lib/oxidized/nodes.rb | |
parent | dbbe6af563072b62e373a9824c6a23482d20896e (diff) | |
parent | f530a50a949310aa9996d764eeaaba7458b7d6b6 (diff) |
Merge branch 'master' into xgs4600-cli
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r-- | lib/oxidized/nodes.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 3f84e15..a159b48 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -6,13 +6,14 @@ module Oxidized class Nodes < Array attr_accessor :source, :jobs alias :put :unshift - def load node_want=nil + def load node_want = nil with_lock do new = [] @source = Oxidized.config.source.default Oxidized.mgr.add_source @source Oxidized.logger.info "lib/oxidized/nodes.rb: Loading nodes" - Oxidized.mgr.source[@source].new.load.each do |node| + nodes = Oxidized.mgr.source[@source].new.load node_want + nodes.each do |node| # we want to load specific node(s), not all of them next unless node_want? node_want, node begin @@ -42,7 +43,6 @@ module Oxidized end end - def list with_lock do map { |e| e.serialize } @@ -63,7 +63,7 @@ module Oxidized end # @param node [String] name of the node moved into the head of array - def next node, opt={} + def next node, opt = {} if waiting.find_node_index(node) with_lock do n = del node @@ -113,10 +113,10 @@ module Oxidized private - def initialize opts={} + def initialize opts = {} super() node = opts.delete :node - @mutex= Mutex.new # we compete for the nodes with webapi thread + @mutex = Mutex.new # we compete for the nodes with webapi thread if nodes = opts.delete(:nodes) replace nodes else @@ -129,7 +129,7 @@ module Oxidized end def find_index node - index { |e| e.name == node or e.ip == node} + index { |e| e.name == node or e.ip == node } end # @param node node which is removed from nodes list @@ -162,7 +162,7 @@ module Oxidized node.stats = old[i].stats node.last = old[i].last end - rescue Oxidized::NodeNotFound + rescue Oxidized::NodeNotFound end end sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end } |