Class: Tengine::Job::JobnetActual

Inherits:
Jobnet
  • Object
show all
Includes:
Executable, Tengine::Job::Jobnet::JobStateTransition, Tengine::Job::Jobnet::JobnetStateTransition, ScriptExecutable, Stoppable
Defined in:
lib/tengine/job/jobnet_actual.rb

Overview

テンプレートから生成された実行時に使用されるジョブネットを表すVertex。

Direct Known Subclasses

RootJobnetActual

Constant Summary collapse

STATE_TRANSITION_METHODS =
[:transmit, :activate, :ack, :finish, :succeed, :fail, :fire_stop, :stop, :reset].freeze

Instance Method Summary collapse

Instance Method Details

#fire_stop_event(root_jobnet, options = Hash.new) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/tengine/job/jobnet_actual.rb', line 55

def fire_stop_event(root_jobnet, options = Hash.new)
  root_jobnet_id = root_jobnet.id.to_s
  result = Tengine::Job::Execution.create!(
    options.merge(:root_jobnet_id => root_jobnet_id))
  properties = {
    :execution_id => result.id.to_s,
    :root_jobnet_id => root_jobnet_id,
    :stop_reason => "user_stop"
  }

  target_id = self.id.to_s
  # if target.children.blank?
  if script_executable?
    event = :"stop.job.job.tengine"
    properties[:target_job_id] = target_id
    properties[:target_jobnet_id] = parent.id.to_s
  else
    event = :"stop.jobnet.job.tengine"
    properties[:target_jobnet_id] = target_id
  end

  EM.run do
    Tengine::Event.fire(event,
      :source_name => name_as_resource,
      :properties => properties)
  end

  return result
end

#root_or_expansionObject



30
31
32
33
# File 'lib/tengine/job/jobnet_actual.rb', line 30

def root_or_expansion
  p = parent
  p.nil? ? self : p.was_expansion ? p : p.root_or_expansion
end

#stop_reason=(r) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/tengine/job/jobnet_actual.rb', line 37

def stop_reason= r
  super
  children.each do |i|
    if i.respond_to?(:chained_box?) && i.chained_box?
      i.stop_reason = r
    end
  end
end

#stopped_at=(t) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/tengine/job/jobnet_actual.rb', line 46

def stopped_at= t
  super
  children.each do |i|
    if i.respond_to?(:chained_box?) && i.chained_box?
      i.stopped_at = t
    end
  end
end