Class: Rukawa::Job

Inherits:
AbstractJob show all
Defined in:
lib/rukawa/job.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractJob

#parent_job_net

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractJob

add_skip_rule, description, #elapsed_time_from, #formatted_elapsed_time_from, #inspect, #name, set_description, #skip?

Constructor Details

#initialize(parent_job_net, variables) ⇒ Job

Returns a new instance of Job.



29
30
31
32
33
34
35
36
37
# File 'lib/rukawa/job.rb', line 29

def initialize(parent_job_net, variables)
  @parent_job_net = parent_job_net
  @variables = variables
  @in_comings = Set.new
  @out_goings = Set.new
  @retry_count = 0
  @retry_wait = 1
  set_state(:waiting)
end

Instance Attribute Details

#finished_atObject (readonly)

Returns the value of attribute finished_at.



10
11
12
# File 'lib/rukawa/job.rb', line 10

def finished_at
  @finished_at
end

#in_comingsObject

Returns the value of attribute in_comings.



9
10
11
# File 'lib/rukawa/job.rb', line 9

def in_comings
  @in_comings
end

#out_goingsObject

Returns the value of attribute out_goings.



9
10
11
# File 'lib/rukawa/job.rb', line 9

def out_goings
  @out_goings
end

#started_atObject (readonly)

Returns the value of attribute started_at.



10
11
12
# File 'lib/rukawa/job.rb', line 10

def started_at
  @started_at
end

#stateObject (readonly)

Returns the value of attribute state.



10
11
12
# File 'lib/rukawa/job.rb', line 10

def state
  @state
end

#variablesObject (readonly)

Returns the value of attribute variables.



10
11
12
# File 'lib/rukawa/job.rb', line 10

def variables
  @variables
end

Class Method Details

.set_dependency_type(name) ⇒ Object



24
25
26
# File 'lib/rukawa/job.rb', line 24

def set_dependency_type(name)
  self.dependency_type = Rukawa::Dependency.get(name)
end

.set_retryable(limit: 8, type: nil, wait: nil) ⇒ Object



17
18
19
20
21
22
# File 'lib/rukawa/job.rb', line 17

def set_retryable(limit: 8, type: nil, wait: nil)
  self.retryable = true
  self.retry_limit = limit
  self.retry_exception_type = type
  self.retry_wait = wait
end

Instance Method Details

#dataflowObject



51
52
53
54
55
56
57
58
59
# File 'lib/rukawa/job.rb', line 51

def dataflow
  return @dataflow if @dataflow
  return @dataflow = bypass_dataflow if @state.bypassed?

  @dataflow = Concurrent.dataflow_with(Rukawa.executor, *depend_dataflows) do |*results|
    do_run(*results)
    @state
  end
end

#jobs_as_fromObject Also known as: jobs_as_to



86
87
88
# File 'lib/rukawa/job.rb', line 86

def jobs_as_from
  [self]
end

#leaf?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/rukawa/job.rb', line 47

def leaf?
  out_goings.select { |edge| edge.cluster == @parent_job_net }.empty?
end

#root?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rukawa/job.rb', line 43

def root?
  in_comings.select { |edge| edge.cluster == @parent_job_net }.empty?
end

#runObject



61
62
# File 'lib/rukawa/job.rb', line 61

def run
end

#set_state(name) ⇒ Object



39
40
41
# File 'lib/rukawa/job.rb', line 39

def set_state(name)
  @state = Rukawa::State.get(name)
end

#to_dot_defObject



91
92
93
94
95
96
97
# File 'lib/rukawa/job.rb', line 91

def to_dot_def
  if state == Rukawa::State::Waiting
    "#{name};\n"
  else
    "#{name} [style = filled,fillcolor = #{state.color}];\n"
  end
end