diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-27 20:34:32 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-27 20:34:32 +0000 |
commit | a3f36748528ea760b5965f972941c6022d0449e9 (patch) | |
tree | d4964f917a6c018d543201a18b21303ee54740c9 /lib/puppet | |
parent | 1a7d8b6715b6dfb55be7a0e36442af4d04e46954 (diff) | |
download | puppet-a3f36748528ea760b5965f972941c6022d0449e9.tar.gz puppet-a3f36748528ea760b5965f972941c6022d0449e9.tar.xz puppet-a3f36748528ea760b5965f972941c6022d0449e9.zip |
Redoing some aspects of the graphing in hopes of helping hte performance a bit.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2230 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/pgraph.rb | 19 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 5 |
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb index af8e720cb..fe55533d9 100644 --- a/lib/puppet/pgraph.rb +++ b/lib/puppet/pgraph.rb @@ -1,5 +1,3 @@ -#!/usr/bin/env ruby -# # Created by Luke A. Kanies on 2006-11-24. # Copyright (c) 2006. All rights reserved. @@ -51,8 +49,7 @@ class Puppet::PGraph < GRATR::Digraph end # Fail in a somewhat informative way if the graph has become cyclic. - def check_cycle - sorted = topsort() + def check_cycle(sorted) return true if sorted.size == size() bad = [] @@ -120,20 +117,19 @@ class Puppet::PGraph < GRATR::Digraph # This creates direct relationships where there were previously # indirect relationships through the containers. def splice!(other, type) - vertices.find_all { |v| v.is_a?(type) }.each do |vertex| + vertices.find_all { |v| v.is_a?(type) }.each do |container| # Get the list of children from the other graph. - #children = other.adjacent(vertex, :direction => :out) - children = other.leaves(vertex) + children = other.adjacent(container, :direction => :out) # Just remove the container if it's empty. if children.empty? - remove_vertex!(vertex) + remove_vertex!(container) next end # First create new edges for each of the :in edges [:in, :out].each do |dir| - adjacent(vertex, :direction => dir, :type => :edges).each do |edge| + adjacent(container, :direction => dir, :type => :edges).each do |edge| children.each do |child| if dir == :in s = edge.source @@ -160,9 +156,12 @@ class Puppet::PGraph < GRATR::Digraph [s, t] end end + + # Now get rid of the edge, so remove_vertex! works correctly. + remove_edge!(edge) end end - remove_vertex!(vertex) + remove_vertex!(container) end end diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 43ee135a6..2a83ea630 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -474,6 +474,9 @@ class Transaction @relgraph = relationship_graph @sorted_resources = @relgraph.topsort + + # Now make sure no cycles crept into our graph. + @relgraph.check_cycle(@sorted_resources) end # Create a graph of all of the relationships in our resource graph. @@ -507,8 +510,6 @@ class Transaction # Then splice in the container information graph.splice!(@resources, Puppet::Type::Component) - graph.check_cycle - graph(graph, :expanded_relationships) return graph |