Class: Rukawa::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rukawa/runner.rb

Constant Summary collapse

DEFAULT_REFRESH_INTERVAL =
3

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_job_net) ⇒ Runner

Returns a new instance of Runner.



12
13
14
15
# File 'lib/rukawa/runner.rb', line 12

def initialize(root_job_net)
  @root_job_net = root_job_net
  @errors = []
end

Class Method Details

.run(job_net, batch_mode = false, refresh_interval = DEFAULT_REFRESH_INTERVAL) ⇒ Object



8
9
10
# File 'lib/rukawa/runner.rb', line 8

def self.run(job_net, batch_mode = false, refresh_interval = DEFAULT_REFRESH_INTERVAL)
  new(job_net).run(batch_mode, refresh_interval)
end

Instance Method Details

#run(batch_mode = false, refresh_interval = DEFAULT_REFRESH_INTERVAL) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rukawa/runner.rb', line 17

def run(batch_mode = false, refresh_interval = DEFAULT_REFRESH_INTERVAL)
  Rukawa.logger.info("=== Start Rukawa ===")
  futures = @root_job_net.dataflows.each(&:execute)
  until futures.all?(&:complete?)
    display_table unless batch_mode
    sleep refresh_interval
  end
  Rukawa.logger.info("=== Finish Rukawa ===")

  display_table unless batch_mode

  errors = futures.map(&:reason).compact

  unless errors.empty?
    errors.each do |err|
      next if err.is_a?(DependentJobFailure)
      Rukawa.logger.error(err)
    end
    return false
  end

  true
end