Arc::Job Class Reference

Job. More...

#include <Job.h>

Public Member Functions

 Job ()
void SaveToStream (std::ostream &out, bool longlist) const
Joboperator= (XMLNode job)
void Update (XMLNode job)
void ToXML (XMLNode job) const

Static Public Member Functions

static bool ReadAllJobsFromFile (const std::string &filename, std::list< Job > &jobs, unsigned nTries=10, unsigned tryInterval=500000)
static bool ReadJobsFromFile (const std::string &filename, std::list< Job > &jobs, std::list< std::string > &jobIdentifiers, bool all=false, const std::list< std::string > &endpoints=std::list< std::string >(), const std::list< std::string > &rejectEndpoints=std::list< std::string >(), unsigned nTries=10, unsigned tryInterval=500000)
static bool WriteJobsToTruncatedFile (const std::string &filename, const std::list< Job > &jobs, unsigned nTries=10, unsigned tryInterval=500000)
static bool WriteJobsToFile (const std::string &filename, const std::list< Job > &jobs, unsigned nTries=10, unsigned tryInterval=500000)
static bool WriteJobsToFile (const std::string &filename, const std::list< Job > &jobs, std::list< const Job * > &newJobs, unsigned nTries=10, unsigned tryInterval=500000)
static bool RemoveJobsFromFile (const std::string &filename, const std::list< URL > &jobids, unsigned nTries=10, unsigned tryInterval=500000)
static bool ReadJobIDsFromFile (const std::string &filename, std::list< std::string > &jobids, unsigned nTries=10, unsigned tryInterval=500000)
static bool WriteJobIDToFile (const URL &jobid, const std::string &filename, unsigned nTries=10, unsigned tryInterval=500000)
static bool WriteJobIDsToFile (const std::list< URL > &jobids, const std::string &filename, unsigned nTries=10, unsigned tryInterval=500000)

Detailed Description

Job.

This class describe a Grid job. Most of the members contained in this class are directly linked to the ComputingActivity defined in the GLUE Specification v. 2.0 (GFD-R-P.147).


Constructor & Destructor Documentation

Arc::Job::Job (  ) 

Create a Job object.

Default constructor. Takes no arguments.


Member Function Documentation

Job& Arc::Job::operator= ( XMLNode  job  ) 

Set Job attributes from a XMLNode.

The attributes of the Job object is set to the values specified in the XMLNode. The XMLNode should be a ComputingActivity type using the GLUE2 XML hierarchical rendering, see http://forge.gridforum.org/sf/wiki/do/viewPage/projects.glue-wg/wiki/GLUE2XMLSchema for more information. Note that associations are not parsed.

Parameters:
job is a XMLNode of GLUE2 ComputingActivity type.
See also:
ToXML
static bool Arc::Job::ReadAllJobsFromFile ( const std::string &  filename,
std::list< Job > &  jobs,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Read all jobs from file.

This static method will read jobs (in XML format) from the specified file, and they will be stored in the referenced list of jobs. The XML element in the file representing a job should be named "Job", and have the same format as accepted by the operator=(XMLNode) method.

File locking: To avoid simultaneous use (writing and reading) of the file, reading will not be initiated before a lock on the file has been acquired. For this purpose the FileLock class is used. nTries specifies the maximal number of times the method will try to acquire a lock on the file, with an interval of tryInterval micro seconds between each attempt. If a lock is not acquired* this method returns false.

The method will also return false if the content of file is not in XML format. Otherwise it returns true.

Parameters:
filename is the filename of the job list to read jobs from.
jobs is a reference to a list of Job objects, which will be filled with the jobs read from file (cleared before use).
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
See also:
operator=(XMLNode)
ReadJobsFromFile
WriteJobsToTruncatedFile
WriteJobsToFile
RemoveJobsFromFile
FileLock
XMLNode::ReadFromFile
static bool Arc::Job::ReadJobIDsFromFile ( const std::string &  filename,
std::list< std::string > &  jobids,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Read a list of Job IDs from a file, and append them to a list.

This static method will read job IDs from the given file, and append the strings to the string list given as parameter. File locking will be done as described for the ReadAllJobsFromFile method. It returns false if the file was not readable, true otherwise, even if there were no IDs in the file. The lines of the file will be trimmed, and lines starting with # will be ignored.

Parameters:
filename is the filename of the jobidfile
jobids is a list of strings, to which the IDs read from the file will be appended
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
static bool Arc::Job::ReadJobsFromFile ( const std::string &  filename,
std::list< Job > &  jobs,
std::list< std::string > &  jobIdentifiers,
bool  all = false,
const std::list< std::string > &  endpoints = std::list< std::string >(),
const std::list< std::string > &  rejectEndpoints = std::list< std::string >(),
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Read specified jobs from file.

Extract job information for jobs specified by job identifiers and/or endpoints from job list file. The method read all jobs from specified job list file, using the ReadAllJobsFromFile method. If the all argument is false, jobs will only be put into the list of Job objects (jobs) if the IDFromEndpoint or Name attributes of the Job object matches one of the entries in the jobIdentifiers list argument or if the Cluster attribute of the Job object matches one of the entries in the endpoints list argument (if specified), using the URL::StringMatches method. If the all argument is true, none of those matchings is carried out, instead all jobs are put into the list of Job objects. For both values of the all argument, the entries in the jobIdentifiers list will be removed if corresponding to a job in the jobs list. In the end, if the rejectEndpoints list is non-empty, the jobs list will be filtered by removing Job objects for which the Cluster attribute matches those in the rejectEndpoints list, using the URL::StringMatches method. This method returns true, except when the ReadAllJobsFromFile method returns false.

Parameters:
filename is the filename of the job list to read jobs from.
jobs is a reference to a list of Job objects, which will be filled with the jobs read from file (cleared before use).
jobIdentifiers specifies the job IDs and names of jobs to be put into the jobs list. Entries in this list is removed if found among the jobs in the job list file.
all specifies whether all jobs from the jobs list should be put into the jobs list.
endpoints is a list of strings resembling endpoints for which Job objects having matching Cluster attribute should be added to the jobs list.
rejectEndpoints is a list of strings resembling endpoint for which Job objects having matching Cluster attribute should be removed from the jobs list. Overides jobIdentifiers, all and endpoints.
nTries will be passed to the ReadAllJobsFromFile method
tryInterval will be passed to the ReadAllJobsFromFile method
Returns:
true in case of success, otherwise false.
See also:
ReadAllJobsFromFile
URL::StringMatches
WriteJobsToTruncatedFile
WriteJobsToFile
RemoveJobsFromFile
static bool Arc::Job::RemoveJobsFromFile ( const std::string &  filename,
const std::list< URL > &  jobids,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Remove job from file.

This static method will remove the jobs having IDFromEndpoint identical to any of those in the passed list jobids. File locking will be done as described for the ReadAllJobsFromFile method. The method will return false if reading from or writing jobs to the file fails. Otherwise it returns true.

Parameters:
filename is the filename of the job list to write jobs to.
jobids is a list of URL objects which specifies which jobs from the file to remove.
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
See also:
ReadAllJobsFromFile
WriteJobsToTruncatedFile
WriteJobsToFile
FileLock
XMLNode::ReadFromFile
XMLNode::SaveToFile
void Arc::Job::SaveToStream ( std::ostream &  out,
bool  longlist 
) const

Write job information to a std::ostream object.

This method will write job information to the passed std::ostream object. The longlist boolean specifies whether more (true) or less (false) information should be printed.

Parameters:
out is the std::ostream object to print the attributes to.
longlist is a boolean for switching on long listing (more details).
void Arc::Job::ToXML ( XMLNode  job  )  const

Add job information to a XMLNode.

Child nodes of GLUE ComputingActivity type containing job information of this object will be added to the passed XMLNode.

Parameters:
job is the XMLNode to add job information to in form of GLUE2 ComputingActivity type child nodes.
See also:
operator=
void Arc::Job::Update ( XMLNode  job  ) 

Set Job attributes from a XMLNode representing GLUE2 ComputingActivity.

Because job XML representation follows GLUE2 model this method is similar to operator=(XMLNode). But it only covers job attributes which are part of GLUE2 computing activity. Also it treats Job object as being iextended with information provided by XMLNode. Contrary operator=(XMLNode) fully reinitializes Job, hence removing any associations to other objects.

static bool Arc::Job::WriteJobIDsToFile ( const std::list< URL > &  jobids,
const std::string &  filename,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Append list of URLs to a file.

This static method will put the ID given as a string, and append it to the given file. File locking will be done as described for the ReadAllJobsFromFile method. It returns false if the file was not writable, true otherwise.

Parameters:
jobid is a list of URL objects to be written to file
filename is the filename of file, where the URL objects will be appended to.
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
static bool Arc::Job::WriteJobIDToFile ( const URL jobid,
const std::string &  filename,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Append a jobID to a file.

This static method will put the ID represented by a URL object, and append it to the given file. File locking will be done as described for the ReadAllJobsFromFile method. It returns false if the file is not writable, true otherwise.

Parameters:
jobid is a jobID as a URL object
filename is the filename of the jobidfile, where the jobID will be appended
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
static bool Arc::Job::WriteJobsToFile ( const std::string &  filename,
const std::list< Job > &  jobs,
std::list< const Job * > &  newJobs,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Write jobs to file.

This static method will write (append) the passed list of jobs to the specified file. Jobs will be written in XML format as returned by the ToXML method, and each job will be contained in a element named "Job". If the passed list of jobs contains two identical jobs (i.e. IDFromEndpoint identical), only the latter Job object is stored. If a job in the list is identical to one in file, the one in file will be replaced with the one from the list. A pointer (no memory allocation) to those jobs from the list which are not in the file will be added to the newJobs list, thus these pointers goes out of scope when 'jobs' list goes out of scope. File locking will be done as described for the ReadAllJobsFromFile method. The method will return false if writing jobs to the file fails. Otherwise it returns true.

Parameters:
filename is the filename of the job list to write jobs to.
jobs is the list of Job objects which should be written to file.
newJobs is a reference to a list of pointers to Job objects which are not duplicates.
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
See also:
ToXML
ReadAllJobsFromFile
WriteJobsToTruncatedFile
RemoveJobsFromFile
FileLock
XMLNode::SaveToFile
static bool Arc::Job::WriteJobsToFile ( const std::string &  filename,
const std::list< Job > &  jobs,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Write jobs to file.

This method is in all respects identical to the WriteJobsToFile(const std::string&, const std::list<Job>&, std::list<const Job*>&, unsigned, unsigned) method, except for the information about new jobs which is disregarded.

See also:
WriteJobsToFile(const std::string&, const std::list<Job>&, std::list<const Job*>&, unsigned, unsigned)
static bool Arc::Job::WriteJobsToTruncatedFile ( const std::string &  filename,
const std::list< Job > &  jobs,
unsigned  nTries = 10,
unsigned  tryInterval = 500000 
) [static]

Truncate file and write jobs to it.

This static method will write the passed list of jobs to the specified file, but before writing the file will be truncated. Jobs will be written in XML format as returned by the ToXML method, and each job will be contained in a element named "Job". If the passed list of jobs contains two identical jobs (i.e. IDFromEndpoint identical), only the latter Job object is stored. File locking will be done as described for the ReadAllJobsFromFile method. The method will return false if writing jobs to the file fails. Otherwise it returns true.

Parameters:
filename is the filename of the job list to write jobs to.
jobs is the list of Job objects which should be written to file.
nTries specifies the maximal number of times the method will try to acquire a lock on file to read.
tryInterval specifies the interval (in micro seconds) between each attempt to acquire a lock.
Returns:
true in case of success, otherwise false.
See also:
ToXML
ReadAllJobsFromFile
WriteJobsToFile
RemoveJobsFromFile
FileLock
XMLNode::SaveToFile

The documentation for this class was generated from the following file:
Generated on Wed Jun 27 11:54:18 2012 for Hosting Environment (Daemon) by  doxygen 1.6.3