Bric::Util::Job::Dist(3)

NAME
Bric::Util::Job::Dist - Manages Bricolage distribution jobs.

VERSION
$LastChangedRevision$

DATE
$LastChangedDate: 2005-10-27 03:29:10 +0200 (Thu, 27 Oct 2005) $

SYNOPSIS
  use Bric::Util::Job::Dist;

  my $id = 1;
  my $format = "%D %T";

  # Constructors.
  my $job = Bric::Util::Job::Dist->new($init);
  $job = Bric::Util::Job::Dist->lookup({ id => $id });
  my @jobs = Bric::Util::Job::Dist->list($params);

  # Class Methods.
  my @job_ids = Bric::Util::Job::Dist->list_ids($params);

  # Instance Methods
  my $id = $job->get_id;

  my $type = $job->get_type;
  $job = $job->set_type($type);

  my $sched_time = $job->get_sched_time($format);
  $job = $job->set_sched_time($sched_time);
  my $comp_time = $job->get_comp_time($format);

  my @resources = $job->get_resources;
  my @resource_ids = $job->get_resource_ids;
  $job = $job->set_resource_ids(@resource_ids);

  my @server_types = $job->get_server_types;
  my @server_type_ids = $job->get_server_type_ids;
  $job = $job->set_server_type_ids(@server_type_ids);

  # Save the job.
  $job = $job->save;

  # Cancel the job.
  $job = $job->cancel;

  # Execute the job.
  $job = $job->execute_me;

DESCRIPTION
This class manages distribution jobs. A job is a list of things to be transformed by actions and moved out, all at a scheduled time. The idea is that Bricolage will schedule a job and then it will be executed at its scheduled times. There are two types of jobs, "Deliver" and "Expire".

  Constructors
my (@jobs || $jobs_aref) = Bric::Util::Job::Dist->list($params)

Inherited from Bric::Util::Job

my (@job_ids || $job_ids_aref) = Bric::Util::Job->list_ids($params)

Inherited from Bric::Util::Job

  Private Instance Methods
$self = $job->_do_it

Carries out the actions that constitute the job. This method is called by "execute_me()" in Bric::Dist::Job and should therefore never be called directly.

For each of the server types associated with this job, the list of actions will be performed on each file, hopefully culminating in the distribution of the resources to the servers associated with the server type. At the end of the process, a completion time will be saved to the database. Attempting to execute a job before its scheduled time will throw an exception.

Throws: Quite a few exceptions can be thrown here. Check the do_it() methods on all Bric::Dist::Action subclasses, as well as the put_res() methods of the mover classes (e.g., Bric::Util::Trans::FS). Here are the exceptions thrown from withing this method itself.

•   Cannot execute job before its scheduled time.

•   Cannot execute job that has already been executed.

•   Can't get a lock on job.

•   Unable to connect to database.

•   Unable to prepare SQL statement.

•   Unable to execute SQL statement.

•   Incorrect number of args to Bric::_set().

•   Bric::set() - Problems setting fields.

Side Effects: NONE.

Notes: NONE.

NOTES
NONE.

AUTHOR
David Wheeler <david@kineticode.com>

Mark Jaroski <jaroskim@who.int>

SEE ALSO
Bric, Bric::Util::Job