This does some normalization so we're not doing
duplicate queries for large event collections.

Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/transaction/event_manager.rb |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/transaction/event_manager.rb 
b/lib/puppet/transaction/event_manager.rb
index f74927b..24e5778 100644
--- a/lib/puppet/transaction/event_manager.rb
+++ b/lib/puppet/transaction/event_manager.rb
@@ -33,7 +33,17 @@ class Puppet::Transaction::EventManager
     def queue_events(resource, events)
         @events += events
 
-        events.each do |event|
+        # Do some basic normalization so we're not doing so many
+        # graph queries for large sets of events.
+        events.inject({}) do |collection, event|
+            collection[event.name] ||= []
+            collection[event.name] << event
+            collection
+        end.collect do |name, list|
+            # It doesn't matter which event we use - they all have the same 
source
+            # and name here.
+            event = list[0]
+
             # 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.
@@ -41,7 +51,9 @@ class Puppet::Transaction::EventManager
                 next unless method = edge.callback
                 next unless edge.target.respond_to?(method)
 
-                queue_event_for_resource(resource, edge.target, method, event)
+                list.each do |e|
+                    queue_event_for_resource(resource, edge.target, method, e)
+                end
             end
 
             if resource.self_refresh? and ! resource.deleting?
-- 
1.6.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to