Class: Tengine::Job::Signal
- Inherits:
-
Object
- Object
- Tengine::Job::Signal
- Defined in:
- lib/tengine/job/signal.rb
Defined Under Namespace
Modules: Transmittable Classes: Error, Reservation
Instance Attribute Summary collapse
-
#callback ⇒ Object
start.job.job.tengineイベントによって ジョブは :ready -> :starting -> :running に遷移するが、 一度のroot_jobnet.update_with_lock では :starting が保存されないので、 2回のroot_jobnet.update_with_lock に分けることができるようにするための 処理を記憶しておく属性です.
-
#data ⇒ Object
現時点ではジョブのrunからackを返す際にPIDを保持するために使用します。.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#reservations ⇒ Object
readonly
Returns the value of attribute reservations.
-
#受け渡しのためにデータを一時的に保持する属性。 ⇒ Object
現時点ではジョブのrunからackを返す際にPIDを保持するために使用します。.
Instance Method Summary collapse
- #execution ⇒ Object
- #fire(source, event_type_name, properties = {}, options = {}) ⇒ Object
-
#initialize(event) ⇒ Signal
constructor
A new instance of Signal.
- #leave(obj, action = :transmit) ⇒ Object
- #reset ⇒ Object
- #with_paths_backup ⇒ Object
Constructor Details
#initialize(event) ⇒ Signal
Returns a new instance of Signal.
22 23 24 25 |
# File 'lib/tengine/job/signal.rb', line 22 def initialize(event) @event = event reset end |
Instance Attribute Details
#callback ⇒ Object
start.job.job.tengineイベントによってジョブは :ready -> :starting -> :running に遷移するが、一度のroot_jobnet.update_with_lock では :starting が保存されないので、2回のroot_jobnet.update_with_lock に分けることができるようにするための処理を記憶しておく属性です
20 21 22 |
# File 'lib/tengine/job/signal.rb', line 20 def callback @callback end |
#data ⇒ Object
現時点ではジョブのrunからackを返す際にPIDを保持するために使用します。
13 14 15 |
# File 'lib/tengine/job/signal.rb', line 13 def data @data end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
9 10 11 |
# File 'lib/tengine/job/signal.rb', line 9 def event @event end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
9 10 11 |
# File 'lib/tengine/job/signal.rb', line 9 def paths @paths end |
#reservations ⇒ Object (readonly)
Returns the value of attribute reservations.
9 10 11 |
# File 'lib/tengine/job/signal.rb', line 9 def reservations @reservations end |
#受け渡しのためにデータを一時的に保持する属性。 ⇒ Object
現時点ではジョブのrunからackを返す際にPIDを保持するために使用します。
13 |
# File 'lib/tengine/job/signal.rb', line 13 attr_accessor :data |
Instance Method Details
#execution ⇒ Object
34 35 36 |
# File 'lib/tengine/job/signal.rb', line 34 def execution @execution ||= Tengine::Job::Execution.find(event[:execution_id]) end |
#fire(source, event_type_name, properties = {}, options = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/tengine/job/signal.rb', line 78 def fire(source, event_type_name, properties = {}, = {}) case source when Tengine::Job::Execution then properties[:execution_id] ||= source.id.to_s properties[:root_jobnet_id] ||= source.root_jobnet.id.to_s properties[:root_jobnet_name_path] ||= source.root_jobnet.name_path properties[:target_jobnet_id] ||= source.root_jobnet.id.to_s properties[:target_jobnet_name_path] ||= source.root_jobnet.name_path else properties[:execution_id] ||= self.execution.id.to_s properties[:root_jobnet_id] ||= source.root.id.to_s properties[:root_jobnet_name_path] ||= source.root.name_path end # デバッグ用 # properties[:target_jobnet_name] = source.root.vertex(properties[:target_jobnet_id]).name_path ||= {} [:properties] = properties properties.each do |key, value| if value.is_a?(Moped::BSON::ObjectId) properties[key] = value.to_s end end @reservations << Reservation.new(source, event_type_name, ) end |
#leave(obj, action = :transmit) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tengine/job/signal.rb', line 38 def leave(obj, action = :transmit) @paths << obj begin if obj.is_a?(Tengine::Job::Edge) obj.destination.send(action, self) elsif obj.is_a?(Tengine::Job::Vertex) obj.next_edges.each do |edge| with_paths_backup{ edge.send(action, self) } end else raise Tengine::Job::Signal::Error, "leaving unsupported object: #{obj.inspect}" end rescue Tengine::Job::Signal::Error => e puts "[#{e.class.name}] #{e.}\nsignal.paths: #{@paths.inspect}" raise e end end |
#reset ⇒ Object
27 28 29 30 31 32 |
# File 'lib/tengine/job/signal.rb', line 27 def reset @paths = [] @reservations = [] @data = nil @callback = nil end |
#with_paths_backup ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/tengine/job/signal.rb', line 56 def with_paths_backup paths_backup = @paths.dup begin yield if block_given? ensure @paths = paths_backup end end |