summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2011-04-01 15:12:54 -0700
committerMarkus Roberts <Markus@reality.com>2011-04-01 15:12:54 -0700
commit8b5ffde9c4464d942aa0e2cae35220b933b7e3a6 (patch)
tree2249dd7c866e0d1a4def8acf7d528f032df69d9a /lib/puppet
parentfa5c2b1b1494cc760f95c95e6e50a304c2651c7b (diff)
downloadpuppet-8b5ffde9c4464d942aa0e2cae35220b933b7e3a6.tar.gz
puppet-8b5ffde9c4464d942aa0e2cae35220b933b7e3a6.tar.xz
puppet-8b5ffde9c4464d942aa0e2cae35220b933b7e3a6.zip
(6911) Add bookkeeping facade around Transaction#relationship_graph
To implement graph frontiers transactions need to track information about the catalog's relationship graph. For various reasons (serialzation, lifetime, etc.) the data belongs with the transaction rather than the catalog or its relationship graph. This commit introduces a facade around the property used to cheat Demeter which has the apropriate lifetime and can be used to hold the state information durring a traversal. Paired-with: Jesse Wolfe
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/transaction.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index ad79f176e..928a1b488 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -277,8 +277,39 @@ class Puppet::Transaction
end
end
+ # We want to monitor changes in the relationship graph of our
+ # catalog but this is complicated by the fact that the catalog
+ # both is_a graph and has_a graph, by the fact that changes to
+ # the structure of the object can have adverse serialization
+ # effects, by threading issues, by order-of-initialization issues,
+ # etc.
+ #
+ # Since the proper lifetime/scope of the monitoring is a transaction
+ # and the transaction is already commiting a mild law-of-demeter
+ # transgression, we cut the Gordian knot here by simply wrapping the
+ # transaction's view of the resource graph to capture and maintain
+ # the information we need. Nothing outside the transaction needs
+ # this information, and nothing outside the transaction can see it
+ # except via the Transaction#relationship_graph
+
+ class Relationship_graph_wrapper
+ def initialize(real_graph,transaction)
+ @real_graph = real_graph
+ @transaction = transaction
+ end
+ def method_missing(*args,&block)
+ @real_graph.send(*args,&block)
+ end
+ def add_vertex(v)
+ @real_graph.add_vertex(v)
+ end
+ def add_edge(f,t)
+ @real_graph.add_edge(f,t)
+ end
+ end
+
def relationship_graph
- catalog.relationship_graph
+ @relationship_graph ||= Relationship_graph_wrapper.new(catalog.relationship_graph,self)
end
def add_resource_status(status)