summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-03-22 16:31:42 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit68ce086e6b57f67998c52073109e0cca0aee7002 (patch)
tree80d50162710c6ce9b553b1e44183667426adf2e1 /lib
parent9919b14f262c994a58eb202cda408f1b90d728e0 (diff)
downloadpuppet-68ce086e6b57f67998c52073109e0cca0aee7002.tar.gz
puppet-68ce086e6b57f67998c52073109e0cca0aee7002.tar.xz
puppet-68ce086e6b57f67998c52073109e0cca0aee7002.zip
Changing the method profile of EventManager#queue_event
It now takes multiple events instead of just one. This will help simplify a bunch of performance optimizations. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/transaction.rb4
-rw-r--r--lib/puppet/transaction/event_manager.rb36
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 1b0c470e1..e7d8f63fd 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -42,9 +42,7 @@ class Puppet::Transaction
def apply(resource)
status = resource_harness.evaluate(resource)
add_resource_status(status)
- status.events.each do |event|
- event_manager.queue_event(resource, event)
- end
+ event_manager.queue_events(resource, status.events)
rescue => detail
resource.err "Could not evaluate: #{detail}"
end
diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb
index aacd17a95..f74927b3c 100644
--- a/lib/puppet/transaction/event_manager.rb
+++ b/lib/puppet/transaction/event_manager.rb
@@ -22,7 +22,7 @@ class Puppet::Transaction::EventManager
end
if restarted
- queue_event(resource, resource.event(:name => :restarted, :status => "success"))
+ queue_events(resource, [resource.event(:name => :restarted, :status => "success")])
transaction.resource_status(resource).restarted = true
end
@@ -30,21 +30,23 @@ class Puppet::Transaction::EventManager
# Queue events for other resources to respond to. All of these events have
# to be from the same resource.
- def queue_event(resource, event)
- @events << event
-
- # Collect the targets of any subscriptions to those events. We pass
- # the parent resource in so it will override the source in the events,
- # since eval_generated children can't have direct relationships.
- relationship_graph.matching_edges(event, resource).each do |edge|
- next unless method = edge.callback
- next unless edge.target.respond_to?(method)
-
- queue_event_for_resource(resource, edge.target, method, event)
- end
-
- if resource.self_refresh? and ! resource.deleting?
- queue_event_for_resource(resource, resource, :refresh, event)
+ def queue_events(resource, events)
+ @events += events
+
+ events.each do |event|
+ # Collect the targets of any subscriptions to those events. We pass
+ # the parent resource in so it will override the source in the events,
+ # since eval_generated children can't have direct relationships.
+ relationship_graph.matching_edges(event, resource).each do |edge|
+ next unless method = edge.callback
+ next unless edge.target.respond_to?(method)
+
+ queue_event_for_resource(resource, edge.target, method, event)
+ end
+
+ if resource.self_refresh? and ! resource.deleting?
+ queue_event_for_resource(resource, resource, :refresh, event)
+ end
end
end
@@ -83,7 +85,7 @@ class Puppet::Transaction::EventManager
resource.notice "Would have triggered '#{callback}' from #{events.length} events"
# And then add an event for it.
- queue_event(resource, resource.event(:status => "noop", :name => :noop_restart))
+ queue_events(resource, [resource.event(:status => "noop", :name => :noop_restart)])
true # so the 'and if' works
end
end