class Blender::Job

A job represent encapsulates an array of tasks to be performed against an array of hosts. Jobs are created by scheduling strategies, and passed to underlying drivers for execution Tasks within a single job must has exactly same driver.

Attributes

driver[R]
hosts[R]
id[R]
tasks[R]

Public Class Methods

new(id, driver, tasks, hosts) click to toggle source

creates a new job @param id [Fixnum] a numeric identifier @param driver [Blender::Driver::Base] a driver object @patam hosts [Array] list of target hosts @patam hosts [Array] list of tasks to be run against the hosts

# File lib/blender/job.rb, line 34
def initialize(id, driver, tasks, hosts)
  @id = id
  @tasks = Array(tasks)
  @hosts = Array(hosts)
  @driver = driver
end

Public Instance Methods

name() click to toggle source

computes, momoize and return the name of the job name is used to summarize the job. @return [String]

# File lib/blender/job.rb, line 52
def name
  @name ||= compute_name
end
run() click to toggle source
# File lib/blender/job.rb, line 41
def run
  driver.execute(tasks, hosts)
end
to_s() click to toggle source
# File lib/blender/job.rb, line 45
def to_s
  "Job #{id} [#{name}]"
end

Private Instance Methods

compute_name() click to toggle source
# File lib/blender/job.rb, line 57
def compute_name
  if tasks.size == 1
    t_part = tasks.first.name
  else
    t_part = "#{tasks.size} tasks"
  end
  if hosts.size == 1
    h_part = hosts.first
  else
    h_part = "#{hosts.size} members"
  end
  "#{t_part} on #{h_part}"
end