Module xg :: Class Controller
[show private | hide private]
[frames | no frames]

Class Controller

GridManager --+
              |
 JobManager --+
              |
             Controller


A class for working with an Xgrid controller.
Method Summary
  __init__(self, connection, update)
This class provides an interface to an Xgrid controller.
Job batch(self, specification, gridID, silent)
Submits a batch job to the specified grid.
Job submit(self, cmd, args, stdin, indir, email, gridID)
Submits a single task job to the specified grid.
    Inherited from JobManager
  deleteAll(self)
Deletes all active jobs.
  job(self, jobID, update)
Returns the Job object with job identifier id.
tuple jobIDs(self, update)
Returns a tuple of job identifiers for all active jobs.
list jobs(self, update)
Returns a list of initialized Job objects for all active jobs.
  perform(self, action, jobIDs)
Performs an action on a subset of active jobs.
  printJobs(self)
Prints information about all active Xgrid jobs.
  restartAll(self)
Restarts all active jobs.
  resumeAll(self)
Resumes all active jobs.
  stopAll(self)
Stops all active jobs.
  suspendAll(self)
Suspends all active jobs.
    Inherited from GridManager
  grid(self, gridID, update)
Returns the Grid object with grid identifier gridID.
  gridIDs(self, update)
Returns a tuple of grid identifiers for all avialable grids.
  grids(self, update)
Returns a list of initialized Grid objects.

Method Details

__init__(self, connection=None, update=0)
(Constructor)

This class provides an interface to an Xgrid controller.

An Xgrid controller is a single machine that manages a set of of grids. Each grid in turn, consists of a set of agents and jobs running on the agents.

This class provides access to the grids and jobs managed by the controller. In Xgrid, both grids and jobs have identifiers, which are unicode strings, like u'0', but this module can take identifiers as strings or integers as well.

Controller and Grid objects can be used to submit Xgrid jobs, but the Job class is used to retrieve job results.

The Controller is only the JobManager for the default Grid. To access the jobs of other grids, create instances of their Grid objects.

Examples

>>> cn = Connection('myhost','mypassword')
>>> c = Controller(cn)
>>> c.jobIDs()
(1, 2, 3)
>>> j1 = c.job('1')     # Get an initialized Job object with id = '1'
>>> j1
<Job with id = 1>
>>> c.grid_ids()        # List the grid ids
('0',)
>>> c.grid('10')        # Get an initialized Grid object with id = '10'
<Grid with gridID = 10>
>>> c.grid()            # Get the Grid boject for the default grid
Parameters:
connection - Instance of Connection class. If empty a default Connection object is used.
           (type=Connection)
update - A boolean flag that determines whether or not the internal state is updated upon creation. This involves a call to the Xgrid controller.
           (type=boolean)
Overrides:
xg.JobManager.__init__

batch(self, specification, gridID=u'0', silent=False)

Submits a batch job to the specified grid.

This is a nonblocking job submission method used for submitting complex multi-task jobs. For single task jobs, use submit().

To retrieve job results, use the results() method of the Job object.
Parameters:
specification - The job specification of the job, which must be an instance of the JobSpecification class. See the docstring for JobSpecification for more details.
           (type=JobSpecification)
gridID - The identifier of the Grid to which the job will be submitted. If empty, the default grid u'0' is used.
           (type=unicode, str or int)
silent - If set to True will slience all messages.
           (type=boolean)
Returns:
Initialized Job object for sumbitted job.
           (type=Job)

submit(self, cmd, args='', stdin='', indir='', email='', gridID=u'0')

Submits a single task job to the specified grid.

This is a nonblocking job submission method for a single job with no sub-tasks. For more complicated jobs with sub-tasks, use the batch() method and the JobSpecification class.

Job results can be obtained by calling the results() method of the Job object.
Parameters:
cmd - The command the execute as a string. The executable is not copied if the full path is given, otherwise it is.
           (type=str)
args - The command line arguments to be passed to the command.
           (type=list or str)
stdin - A local file to use as the stdin stream for the job.
           (type=str)
indir - A local directory to copy to the remote agent.
           (type=str)
email - An email to which notification will be send of various job state changes.
           (type=str)
gridID - The identifier of the Grid to which the job will be submitted. If empty, the default grid u'0' is used.
           (type=unicode, str or int)
Returns:
Initialized Job object for sumbitted job.
           (type=Job)

Generated by Epydoc 2.1 on Thu Dec 22 15:15:21 2005 http://epydoc.sf.net