Class: Logical::Naf::ConstructionZone::Foreman
- Inherits:
-
Object
- Object
- Logical::Naf::ConstructionZone::Foreman
- Includes:
- Af::Application::Component
- Defined in:
- app/models/logical/naf/construction_zone/foreman.rb
Instance Method Summary collapse
- #enqueue(work_order) ⇒ Object
-
#initialize ⇒ Foreman
constructor
A new instance of Foreman.
- #limited_by_run_group?(application_run_group_restriction, application_run_group_name, application_run_group_limit) ⇒ Boolean
Constructor Details
#initialize ⇒ Foreman
Returns a new instance of Foreman.
6 7 8 |
# File 'app/models/logical/naf/construction_zone/foreman.rb', line 6 def initialize() @proletariat = Proletariat.new end |
Instance Method Details
#enqueue(work_order) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/logical/naf/construction_zone/foreman.rb', line 10 def enqueue(work_order) unless work_order.enqueue_backlogs if limited_by_run_group?(work_order.application_run_group_restriction, work_order.application_run_group_name, work_order.application_run_group_limit) logger.warn "work order limited by run queue limits #{work_order.inspect}" return nil end end @proletariat.create_job(work_order.historical_job_parameters, work_order.historical_job_affinity_tab_parameters, work_order.historical_job_prerequisite_historical_jobs) end |
#limited_by_run_group?(application_run_group_restriction, application_run_group_name, application_run_group_limit) ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/logical/naf/construction_zone/foreman.rb', line 24 def limited_by_run_group?(application_run_group_restriction, application_run_group_name, application_run_group_limit) if (application_run_group_restriction.id == ::Naf::ApplicationRunGroupRestriction.no_limit.id || application_run_group_limit.nil? || application_run_group_name.nil?) false elsif application_run_group_restriction.id == ::Naf::ApplicationRunGroupRestriction.limited_per_machine.id # XXX this is difficult to figure out, so we punt for now # XXX we should check if there is any machine affinity (must pass that in) and # XXX if so check if that machine has this application group running on it. # XXX but this code is only used as a heuristic for queues #(::Naf::QueuedJob.where(:application_run_group_name => application_run_group_name).count + #::Naf::RunningJob.where(:application_run_group_name => application_run_group_name, #:started_on_machine_id => @machine.id).count) >= application_run_group_limit # XXX just returning false false elsif application_run_group_restriction.id == ::Naf::ApplicationRunGroupRestriction.limited_per_all_machines.id (::Naf::QueuedJob.where(:application_run_group_name => application_run_group_name).count + ::Naf::RunningJob.where(:application_run_group_name => application_run_group_name).count) >= application_run_group_limit else logger.warn "not limited by run group restriction but don't know why: #{application_run_group_restriction.inspect}" true end end |