class Tengine::Job::Runtime::Execution

Attributes

signal[RW]

Public Instance Methods

ack(signal) click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 105
def ack(signal)
  case phase_key
  when :ready then
    raise Tengine::Job::Runtime::Executable::PhaseError, "ack not available on #{phase_key.inspect}"
  when :starting then
    self.phase_key = :running
  end
end
activate(signal) click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 89
def activate(signal)
  case phase_key
  when :ready then
    self.phase_key = :starting
    if self.retry
      target_actuals.each do |target|
        target.transmit(signal)
      end
    else
      root_jobnet.transmit(signal)
    end
  else
    raise "Unsupported phase_key for activate: #{phase_key.inspect}"
  end
end
actual_estimated_end() click to toggle source

実開始日時から求める予定終了時刻

# File lib/tengine/job/runtime/execution.rb, line 31
def actual_estimated_end
  return nil unless started_at
  (started_at + (estimated_time || 0)).utc
end
fail(signal) click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 124
def fail(signal)
  case phase_key
  when :initialized, :ready, :success then
    raise Tengine::Job::Runtime::Executable::PhaseError, "fail not available on #{phase_key.inspect}"
  when :starting, :running, :dying, :stuck then
    self.phase_key = :error
    signal.fire(self, :"error.execution.job.tengine")
  end
end
in_scope?(vertex) click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 62
def in_scope?(vertex)
  return false if vertex.nil?
  return true if target_actual_ids.nil? || target_actual_ids.empty?
  (vertex.id == scope_root.id) || vertex.ancestors.map(&:id).include?(scope_root.id)
end
name_as_resource() click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 36
def name_as_resource
  root_jobnet.name_as_resource.sub(/^job:/, 'execution:')
end
scope_root() click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 51
def scope_root
  unless @scope_root
    actual = target_actuals.first
    @scope_root = spot ? actual : actual.parent || actual
    unless @scope_root
      raise "@scope_root must not be nil"
    end
  end
  @scope_root
end
stop(signal) click to toggle source

def fire_stop(signal)

return if self.phase_key == :initialized
signal.fire(self, :"stop.execution.job.tengine", {
    :execution_id => self.id,
    :root_jobnet_id => root_jobnet.id,
    :target_jobnet_id => root_jobnet.id,
  })

end

# File lib/tengine/job/runtime/execution.rb, line 143
def stop(signal)
  self.phase_key = :dying
  root_jobnet.fire_stop(signal)
end
succeed(signal) click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 114
def succeed(signal)
  case phase_key
  when :initialized, :ready, :error then
    raise Tengine::Job::Runtime::Executable::PhaseError, "succeed not available on #{phase_key.inspect}"
  when :starting, :running, :dying, :stuck then
    self.phase_key = :success
    signal.fire(self, :"success.execution.job.tengine")
  end
end
target_actuals() click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 40
def target_actuals
  r = self.root_jobnet
  if target_actual_ids.nil? || target_actual_ids.empty?
    [r]
  else
    target_actual_ids.map do |target_actual_id|
      r.vertex(target_actual_id)
    end
  end
end
transmit(signal) click to toggle source
# File lib/tengine/job/runtime/execution.rb, line 68
def transmit(signal)
  case phase_key
  when :initialized then
    self.phase_key = :ready
    signal.call_later do
      if self.retry
        target_actuals.each do |target|
          signal.call_later{ signal.cache(target).reset(signal) }
        end
      end
      signal.call_later do
        Tengine.logger.info("=" * 50)
        activate(signal)
        self.save!
      end
    end
  else
    raise "Unsupported phase_key for transmit: #{phase_key.inspect}"
  end
end