Class: Tengine::Job::Structure::EdgeBuilder

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/tengine/job/structure/edge_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, boot_job_names, redirections, options = {}) ⇒ EdgeBuilder

Returns a new instance of EdgeBuilder.



9
10
11
12
13
14
15
16
17
# File 'lib/tengine/job/structure/edge_builder.rb', line 9

def initialize(client, boot_job_names, redirections, options = {})
  @client, @boot_job_names, @redirections = client, boot_job_names, redirections.dup
  @graph = Hash.new do |h, k| h[k] = Array.new end
  @redirections.each do |(x, y)|
    @graph[x] << y
  end
  @fork_class = options[:fork_class]
  @join_class = options[:join_class]
end

Instance Method Details

#child_by_name(*args) ⇒ Object



20
# File 'lib/tengine/job/structure/edge_builder.rb', line 20

def child_by_name(*args); @client.child_by_name(*args); end

#childrenObject



19
# File 'lib/tengine/job/structure/edge_builder.rb', line 19

def children; @client.children; end

#new_edge(*args) ⇒ Object



21
# File 'lib/tengine/job/structure/edge_builder.rb', line 21

def new_edge(*args); @client.new_edge(*args); end

#prepare_end(*args, &block) ⇒ Object



22
# File 'lib/tengine/job/structure/edge_builder.rb', line 22

def prepare_end(*args, &block); @client.prepare_end(*args, &block); end

#processObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tengine/job/structure/edge_builder.rb', line 24

def process
  tsort
rescue TSort::Cyclic
  raise Tengine::Job::Structure::Error, "circular dependency found in jobnet ``#{@client.name}''"
else
  build_start_edges
  build_edge_by_redirections
  prepare_end do |_end|
    build_end_edges(_end, @boot_job_names.map{|jn| [:start, jn]} + @redirections)
  end
end