summaryrefslogtreecommitdiff
path: root/lib/oxidized/nodes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r--lib/oxidized/nodes.rb54
1 files changed, 24 insertions, 30 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index cd67007..f5a1ad0 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -56,11 +56,8 @@ module Oxidized
end
end
- def fetch node, group
- with_lock do
- i = find_node_index node
- output = self[i].output.new
- raise Oxidized::NotSupported unless output.respond_to? :fetch
+ def fetch node_name, group
+ yield_node_output(node_name) do |node, output|
output.fetch node, group
end
end
@@ -94,6 +91,24 @@ module Oxidized
find_index node or raise Oxidized::NodeNotFound, "unable to find '#{node}'"
end
+ def version node_name, group
+ yield_node_output(node_name) do |node, output|
+ output.version node, group
+ end
+ end
+
+ def get_version node_name, group, oid
+ yield_node_output(node_name) do |node, output|
+ output.get_version node, group, oid
+ end
+ end
+
+ def get_diff node_name, group, oid1, oid2
+ yield_node_output(node_name) do |node, output|
+ output.get_diff node, group, oid1, oid2
+ end
+ end
+
private
def initialize opts={}
@@ -151,34 +166,13 @@ module Oxidized
sort_by! { |x| x.last.nil? ? Time.new(0) : x.last.end }
end
- public
-
- def version node, group
+ def yield_node_output(node_name)
with_lock do
- i = find_node_index node
- output = self[i].output.new
+ node = find { |n| n.name == node_name }
+ output = node.output.new
raise Oxidized::NotSupported unless output.respond_to? :fetch
- output.version node, group
- end
- end
-
- def get_version node, group, oid
- with_lock do
- i = find_node_index node
- output = self[i].output.new
- raise Oxidized::NotSupported unless output.respond_to? :fetch
- output.get_version node, group, oid
+ yield node, output
end
end
-
- def get_diff node, group, oid1, oid2
- with_lock do
- i = find_node_index node
- output = self[i].output.new
- raise Oxidized::NotSupported unless output.respond_to? :fetch
- output.get_diff node, group, oid1, oid2
- end
- end
-
end
end