summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2011-04-01 22:53:44 -0700
committerMarkus Roberts <Markus@reality.com>2011-04-01 22:53:44 -0700
commit5dc994c594680203a4bbbbaa3d6f3b00640c1530 (patch)
tree2a4605b9e0a73421bd5ca8a078f7042a41d7ab3c /lib
parent8af29c8f9a4da0d9e4a1c15f032f9c0bb9348d62 (diff)
downloadpuppet-5dc994c594680203a4bbbbaa3d6f3b00640c1530.tar.gz
puppet-5dc994c594680203a4bbbbaa3d6f3b00640c1530.tar.xz
puppet-5dc994c594680203a4bbbbaa3d6f3b00640c1530.zip
(6911) Cleanup and renaming of transaction internals
The preceeding changes left some rough edges in the Transactions (a short, badly named method that was only used in one place and would be clearer in- line, a return value that was carfully retained and never used, etc.) This commit clears some of that up.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/transaction.rb31
1 files changed, 12 insertions, 19 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 79fdb044c..c502fc627 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -80,18 +80,14 @@ class Puppet::Transaction
if skip?(resource)
resource_status(resource).skipped = true
else
- eval_children_and_apply_resource(resource, ancestor)
+ resource_status(resource).scheduled = true
+ apply(resource, ancestor)
end
# Check to see if there are any events queued for this resource
event_manager.process_events(resource)
end
- def eval_children_and_apply_resource(resource, ancestor = nil)
- resource_status(resource).scheduled = true
- apply(resource, ancestor)
- end
-
# This method does all the actual work of running a transaction. It
# collects all of the changes, executes them, and responds to any
# necessary events.
@@ -105,18 +101,12 @@ class Puppet::Transaction
begin
relationship_graph.traverse do |resource|
- next if stop_processing?
if resource.is_a?(Puppet::Type::Component)
Puppet.warning "Somehow left a component in the relationship graph"
- next
- end
- ret = nil
- seconds = thinmark do
- ret = eval_resource(resource)
+ else
+ seconds = thinmark { eval_resource(resource) }
+ resource.info "Evaluated in %0.2f seconds" % seconds if Puppet[:evaltrace] and @catalog.host_config?
end
-
- resource.info "Evaluated in %0.2f seconds" % seconds if Puppet[:evaltrace] and @catalog.host_config?
- ret
end
ensure
# And then close the transaction log.
@@ -280,13 +270,14 @@ class Puppet::Transaction
# except via the Transaction#relationship_graph
class Relationship_graph_wrapper
- attr_reader :real_graph,:transaction,:ready,:generated,:done
+ attr_reader :real_graph,:transaction,:ready,:generated,:done,:unguessable_deterministic_key
def initialize(real_graph,transaction)
@real_graph = real_graph
@transaction = transaction
@ready = {}
@generated = {}
@done = {}
+ @unguessable_deterministic_key = Hash.new { |h,k| h[k] = Digest::SHA1.hexdigest("NaCl, MgSO4 (salts) and then #{k.title}") }
vertices.each { |v| check_if_now_ready(v) }
end
def method_missing(*args,&block)
@@ -301,10 +292,12 @@ class Puppet::Transaction
end
def check_if_now_ready(r)
ready[r] = true if direct_dependencies_of(r).all? { |r2| done[r2] }
- end
+ end
+ def next_resource
+ ready.keys.sort_by { |r0| unguessable_deterministic_key[r0] }.first
+ end
def traverse(&block)
- unguessable_deterministic_key = Hash.new { |h,k| h[k] = Digest::SHA1.hexdigest("NaCl, MgSO4 (salts) and then #{k.title}") }
- while r = ready.keys.sort_by { |r0| unguessable_deterministic_key[r0] }.first
+ while (r = next_resource) && !transaction.stop_processing?
if !generated[r]
transaction.eval_generate(r)
generated[r] = true