Class: Naf::RunningJob
- Includes:
- PgAdvisoryLocker
- Defined in:
- app/models/naf/running_job.rb
Class Method Summary collapse
- .affinity_weights(machine) ⇒ Object
- .assigned_jobs(machine) ⇒ Object
- .in_run_group(run_group_name) ⇒ Object
-
.started_on(machine) ⇒ Object
————————- *** Class Methods *** +++++++++++++++++++++++++.
- .started_on_invocation(invocation_id) ⇒ Object
Instance Method Summary collapse
-
#add_tags(tags_to_add) ⇒ Object
————————- *** Instance Methods *** +++++++++++++++++++++++++.
- #lock_for_runner_use(&block) ⇒ Object
- #remove_all_tags ⇒ Object
- #remove_tags(tags_to_remove) ⇒ Object
- #unlock_for_runner_use ⇒ Object
Methods inherited from NafBase
Class Method Details
.affinity_weights(machine) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/naf/running_job.rb', line 70 def self.affinity_weights(machine) affinity_ids = ::Naf::Affinity.all.map(&:id) job_weights = {} affinity_ids.each do |affinity_id| job_weights[affinity_id] = 0 end ::Naf::RunningJob.where(started_on_machine_id: machine.id).all.each do |running_job| affinity_ids.each do |affinity_id| job_weights[affinity_id] += running_job. historical_job.historical_job_affinity_tabs. where(affinity_id: affinity_id). first.try(:affinity_parameter).to_f end end job_weights end |
.assigned_jobs(machine) ⇒ Object
66 67 68 |
# File 'app/models/naf/running_job.rb', line 66 def self.assigned_jobs(machine) started_on(machine) end |
.in_run_group(run_group_name) ⇒ Object
62 63 64 |
# File 'app/models/naf/running_job.rb', line 62 def self.in_run_group(run_group_name) where(application_run_group_name: run_group_name) end |
.started_on(machine) ⇒ Object
*** Class Methods *** +++++++++++++++++++++++++
53 54 55 |
# File 'app/models/naf/running_job.rb', line 53 def self.started_on(machine) where(started_on_machine_id: machine.id) end |
.started_on_invocation(invocation_id) ⇒ Object
57 58 59 60 |
# File 'app/models/naf/running_job.rb', line 57 def self.started_on_invocation(invocation_id) joins(:historical_job). where("#{::Naf.schema_name}.historical_jobs.machine_runner_invocation_id = #{invocation_id}") end |
Instance Method Details
#add_tags(tags_to_add) ⇒ Object
*** Instance Methods *** +++++++++++++++++++++++++
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/models/naf/running_job.rb', line 94 def () = nil if self..present? = self..gsub(/[{}]/,'').split(',') = '{' + ( | ).join(',') + '}' else = '{' + .join(',') + '}' end self. = self.save! end |
#lock_for_runner_use(&block) ⇒ Object
122 123 124 |
# File 'app/models/naf/running_job.rb', line 122 def lock_for_runner_use(&block) advisory_lock(&block) end |
#remove_all_tags ⇒ Object
117 118 119 120 |
# File 'app/models/naf/running_job.rb', line 117 def self. = '{}' self.save! end |
#remove_tags(tags_to_remove) ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'app/models/naf/running_job.rb', line 107 def () if self..present? = self..gsub(/[{}]/,'').split(',') = '{' + ( - ).join(',') + '}' self. = self.save! end end |
#unlock_for_runner_use ⇒ Object
126 127 128 |
# File 'app/models/naf/running_job.rb', line 126 def unlock_for_runner_use advisory_unlock end |