Class: Tengine::Job::Runtime::RootJobnet
- Inherits:
-
Jobnet
- Object
- Jobnet
- Tengine::Job::Runtime::RootJobnet
- Defined in:
- lib/tengine/job/runtime/root_jobnet.rb
Overview
DSLを評価して登録されるルートジョブネットを表すVertex
Class Method Summary collapse
-
.find_by_name(name, options = {}) ⇒ Object
Tengine::Core::FindByName で定義しているクラスメソッドfind_by_nameを上書きしています.
Instance Method Summary collapse
- #execute(options = {}) ⇒ Object
- #find_duplication ⇒ Object
- #fire_stop_event(options = Hash.new) ⇒ Object
- #rerun(*args) ⇒ Object
Class Method Details
.find_by_name(name, options = {}) ⇒ Object
Tengine::Core::FindByName で定義しているクラスメソッドfind_by_nameを上書きしています
72 73 74 75 |
# File 'lib/tengine/job/runtime/root_jobnet.rb', line 72 def find_by_name(name, = {}) version = [:version] || Tengine::Core::Setting.dsl_version where({:name => name, :dsl_version => version}).first end |
Instance Method Details
#execute(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tengine/job/runtime/root_jobnet.rb', line 11 def execute( = {}) event_sender = .delete(:sender) || Tengine::Event.default_sender with(safe: safemode(self.class.collection)).save! if new_record? result = Tengine::Job::Runtime::Execution.with( safe: safemode(Tengine::Job::Runtime::Execution.collection) ).create!( ( || {}).update(:root_jobnet_id => self.id) ) event_sender.fire(:"start.execution.job.tengine", :properties => { :execution_id => result.id, :root_jobnet_id => self.id, :target_jobnet_id => self.id }) result end |
#find_duplication ⇒ Object
65 66 67 68 |
# File 'lib/tengine/job/runtime/root_jobnet.rb', line 65 def find_duplication return nil unless self.new_record? self.class.find_by_name(name, :version => self.dsl_version) end |
#fire_stop_event(options = Hash.new) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/tengine/job/runtime/root_jobnet.rb', line 46 def fire_stop_event( = Hash.new) root_jobnet_id = self.id.to_s result = Tengine::Job::Runtime::Execution.create!( .merge(:root_jobnet_id => root_jobnet_id)) EM.run do Tengine::Event.fire(:"stop.jobnet.job.tengine", :source_name => name_as_resource, :properties => { :execution_id => result.id.to_s, :root_jobnet_id => root_jobnet_id, :target_jobnet_id => root_jobnet_id.to_s, :stop_reason => "user_stop", }) end return result end |
#rerun(*args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tengine/job/runtime/root_jobnet.rb', line 27 def rerun(*args) = args. sender = .delete(:sender) || Tengine::Event.default_sender = .merge({ :retry => true, :root_jobnet_id => self.id, }) result = Tengine::Job::Runtime::Execution.new() result.target_actual_ids ||= [] result.target_actual_ids += args.flatten result.with(safe: safemode(Tengine::Job::Runtime::Execution.collection)).save! sender.wait_for_connection do sender.fire(:'start.execution.job.tengine', :properties => { :execution_id => result.id.to_s }) end result end |