[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Markus Roberts Markus at reality.com
Tue May 10 08:10:24 UTC 2011


The following commit has been merged in the experimental branch:
commit 8b5ffde9c4464d942aa0e2cae35220b933b7e3a6
Author: Markus Roberts <Markus at reality.com>
Date:   Fri Apr 1 15:12:54 2011 -0700

    (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

diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index ad79f17..928a1b4 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)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list