Class: Rukawa::Job
- Inherits:
-
AbstractJob
- Object
- AbstractJob
- Rukawa::Job
- Defined in:
- lib/rukawa/job.rb
Instance Attribute Summary collapse
-
#in_comings ⇒ Object
Returns the value of attribute in_comings.
-
#out_goings ⇒ Object
Returns the value of attribute out_goings.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #dataflow ⇒ Object
-
#initialize(job_net) ⇒ Job
constructor
A new instance of Job.
- #leaf? ⇒ Boolean
- #nodes_as_from ⇒ Object (also: #nodes_as_to)
- #root? ⇒ Boolean
- #run ⇒ Object
- #to_dot_def ⇒ Object
Methods inherited from AbstractJob
add_skip_rule, #name, #skip?, skip_rules, #skip_rules
Constructor Details
#initialize(job_net) ⇒ Job
Returns a new instance of Job.
9 10 11 12 13 14 |
# File 'lib/rukawa/job.rb', line 9 def initialize(job_net) @job_net = job_net @in_comings = Set.new @out_goings = Set.new set_state(:waiting) end |
Instance Attribute Details
#in_comings ⇒ Object
Returns the value of attribute in_comings.
6 7 8 |
# File 'lib/rukawa/job.rb', line 6 def in_comings @in_comings end |
#out_goings ⇒ Object
Returns the value of attribute out_goings.
6 7 8 |
# File 'lib/rukawa/job.rb', line 6 def out_goings @out_goings end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/rukawa/job.rb', line 7 def state @state end |
Instance Method Details
#dataflow ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rukawa/job.rb', line 24 def dataflow return @dataflow if @dataflow @dataflow = Concurrent.dataflow_with(Rukawa.executor, *depend_dataflows) do |*results| begin raise DependentJobFailure unless results.all? { |r| !r.nil? } if skip? || @job_net.skip? || results.any? { |r| r == Rukawa::State.get(:skipped) } Rukawa.logger.info("Skip #{self.class}") set_state(:skipped) else Rukawa.logger.info("Start #{self.class}") set_state(:running) run Rukawa.logger.info("Finish #{self.class}") set_state(:finished) end rescue => e Rukawa.logger.error("Error #{self.class} by #{e}") set_state(:error) raise end @state end end |
#leaf? ⇒ Boolean
20 21 22 |
# File 'lib/rukawa/job.rb', line 20 def leaf? out_goings.empty? end |
#nodes_as_from ⇒ Object Also known as: nodes_as_to
54 55 56 |
# File 'lib/rukawa/job.rb', line 54 def nodes_as_from [self] end |
#root? ⇒ Boolean
16 17 18 |
# File 'lib/rukawa/job.rb', line 16 def root? in_comings.empty? end |
#run ⇒ Object
51 52 |
# File 'lib/rukawa/job.rb', line 51 def run end |