Class: Bosh::Director::DeploymentPlan::ParallelMultiJobUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/deployment_plan/multi_job_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(job_updater_factory) ⇒ ParallelMultiJobUpdater

Returns a new instance of ParallelMultiJobUpdater.



21
22
23
# File 'lib/bosh/director/deployment_plan/multi_job_updater.rb', line 21

def initialize(job_updater_factory)
  @job_updater_factory = job_updater_factory
end

Instance Method Details

#run(base_job, deployment_plan, jobs) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bosh/director/deployment_plan/multi_job_updater.rb', line 25

def run(base_job, deployment_plan, jobs)
  base_job.logger.info("Updating jobs in parallel: #{jobs.map(&:name).join(', ')}")
  base_job.task_checkpoint

  ThreadPool.new(max_threads: jobs.size).wrap do |pool|
    jobs.each do |j|
      pool.process do
        base_job.logger.info("Updating job: #{j.name}")
        job_updater = @job_updater_factory.new_job_updater(deployment_plan, j)
        job_updater.update
      end
    end
  end
end