summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-05 19:43:23 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-05 19:43:23 +0000
commitbb60cabda8d9cf4bdc7d138eadfd19ca6d8e7249 (patch)
tree28d884d601b54e4c14fba8b038e2c099670f17db /lib/puppet
parent88c3f7c4795da36c161ee340b535725b826aded2 (diff)
downloadpuppet-bb60cabda8d9cf4bdc7d138eadfd19ca6d8e7249.tar.gz
puppet-bb60cabda8d9cf4bdc7d138eadfd19ca6d8e7249.tar.xz
puppet-bb60cabda8d9cf4bdc7d138eadfd19ca6d8e7249.zip
Making trigger logs much clearer -- you now get info logs indicating how many dependencies changed, and debug logs indicating what those dependencies are
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1178 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/event.rb2
-rw-r--r--lib/puppet/transaction.rb40
2 files changed, 34 insertions, 8 deletions
diff --git a/lib/puppet/event.rb b/lib/puppet/event.rb
index eb17750cc..79f01b65f 100644
--- a/lib/puppet/event.rb
+++ b/lib/puppet/event.rb
@@ -206,7 +206,7 @@ module Puppet
end
# Trigger a subscription, which basically calls the associated method
- # on the target object.
+ # on the target object. XXX This is currently unused.
def trigger(transaction)
event = nil
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 4dfa3913b..23d384b38 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -81,10 +81,13 @@ class Transaction
def collecttargets(events)
events.each do |event|
source = event.source
+ start = source
while source
Puppet::Event::Subscription.targets_of(event, source) do |sub|
- @targets[sub.target] << sub
+ start.info "Scheduling %s of %s[%s]" %
+ [sub.callback, sub.target.class.name, sub.target.name]
+ @targets[sub.target][event] = sub
end
source = source.parent
@@ -149,7 +152,7 @@ class Transaction
}
@targets = Hash.new do |hash, key|
- hash[key] = []
+ hash[key] = {}
end
# of course, this won't work on the second run
@@ -199,25 +202,48 @@ class Transaction
}.flatten.reject { |e| e.nil? }
end
- # Trigger any subscriptions to a child
+ # Trigger any subscriptions to a child. This does an upwardly recursive
+ # search -- it triggers the passed object, but also the object's parent
+ # and so on up the tree.
def trigger(child)
obj = child
+ callbacks = Hash.new { |hash, key| hash[key] = [] }
+ sources = Hash.new { |hash, key| hash[key] = [] }
while obj
if @targets.include?(obj)
- @targets[obj].uniq.each do |sub|
+ callbacks.clear
+ sources.clear
+ @targets[obj].each do |event, sub|
+ # Collect all of the subs for each callback
+ callbacks[sub.callback] << sub
+
+ # And collect the sources for logging
+ sources[event.source] << sub.callback
+ end
+
+ sources.each do |source, callbacklist|
+ obj.debug "%s[%s] results in triggering %s" %
+ [source.class.name, source.name, callbacklist.join(", ")]
+ end
+
+ callbacks.each do |callback, subs|
+ obj.info "Triggering '%s' from %s dependencies" %
+ [callback, subs.length]
# At this point, just log failures, don't try to react
# to them in any way.
begin
- sub.trigger(self)
+ obj.send(callback)
rescue => detail
- sub.target.err "Failed to call %s on %s: %s" %
- [sub.callback, sub.target, detail]
+ obj.err "Failed to call %s on %s: %s" %
+ [callback, obj, detail]
if Puppet[:debug]
puts detail.backtrace
end
end
+
+ triggered(obj, callback)
end
end