class Tengine::Job::Runtime::RootJobnet
DSLを評価して登録されるルートジョブネットを表すVertex
Public Class Methods
find_by_name(name, options = {})
click to toggle source
Tengine::Core::FindByName で定義しているクラスメソッドfind_by_nameを上書きしています
# File lib/tengine/job/runtime/root_jobnet.rb, line 71 def find_by_name(name, options = {}) version = options[:version] || Tengine::Core::Setting.dsl_version where({:name => name, :dsl_version => version}).first end
Public Instance Methods
execute(options = {})
click to toggle source
# File lib/tengine/job/runtime/root_jobnet.rb, line 10 def execute(options = {}) event_sender = options.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!( (options || {}).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()
click to toggle source
# File lib/tengine/job/runtime/root_jobnet.rb, line 64 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)
click to toggle source
# File lib/tengine/job/runtime/root_jobnet.rb, line 45 def fire_stop_event(options = Hash.new) root_jobnet_id = self.id.to_s result = Tengine::Job::Runtime::Execution.create!( options.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)
click to toggle source
# File lib/tengine/job/runtime/root_jobnet.rb, line 26 def rerun(*args) options = args.extract_options! sender = options.delete(:sender) || Tengine::Event.default_sender options = options.merge({ :retry => true, :root_jobnet_id => self.id, }) result = Tengine::Job::Runtime::Execution.new(options) 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