MoleQueue  0.8.0
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
Job Class Reference

#include <molequeue/job.h>

Inheritance diagram for Job:
JobReferenceBase

Public Member Functions

 Job (JobData *jobdata=NULL)
 
 Job (JobManager *jobManager, IdType mQId)
 
 Job (const JobReferenceBase &other)
 
QJsonObject toJsonObject () const
 
void setFromJson (const QJsonObject &state)
 
void setQueue (const QString &newQueue)
 
QString queue () const
 
void setProgram (const QString &newProgram)
 
QString program () const
 
void setJobState (JobState state)
 
JobState jobState () const
 
void setDescription (const QString &newDesc)
 
QString description () const
 
void setInputFile (const FileSpecification &spec)
 
FileSpecification inputFile () const
 
void setAdditionalInputFiles (const QList< FileSpecification > &files)
 
QList< FileSpecificationadditionalInputFiles () const
 
void addInputFile (const FileSpecification &spec)
 
void setOutputDirectory (const QString &path)
 
QString outputDirectory () const
 
void setLocalWorkingDirectory (const QString &path)
 
QString localWorkingDirectory () const
 
void setCleanRemoteFiles (bool clean)
 
bool cleanRemoteFiles () const
 
void setRetrieveOutput (bool b)
 
bool retrieveOutput () const
 
void setCleanLocalWorkingDirectory (bool b)
 
bool cleanLocalWorkingDirectory () const
 
void setHideFromGui (bool b)
 
bool hideFromGui () const
 
void setPopupOnStateChange (bool b)
 
bool popupOnStateChange () const
 
void setNumberOfCores (int num)
 
int numberOfCores () const
 
void setMaxWallTime (int minutes)
 
int maxWallTime () const
 
void setMoleQueueId (IdType id)
 
IdType moleQueueId () const
 
void setQueueId (IdType id)
 
IdType queueId () const
 
void setKeywords (const QHash< QString, QString > &keyrep)
 
QHash< QString, QString > keywords () const
 
void setKeywordReplacement (const QString &keyword, const QString &replacement)
 
bool hasKeywordReplacement (const QString &keyword) const
 
QString lookupKeywordReplacement (const QString &keyword) const
 
void replaceKeywords (QString &launchScript) const
 
- Public Member Functions inherited from JobReferenceBase
 JobReferenceBase (JobData *jobdata=NULL)
 
 JobReferenceBase (JobManager *jobManager, IdType moleQueueId)
 
 JobReferenceBase (const JobReferenceBase &other)
 
bool operator== (const JobReferenceBase &other) const
 
bool isValid () const
 

Additional Inherited Members

- Protected Member Functions inherited from JobReferenceBase
JobDatajobData () const
 
bool warnIfInvalid () const
 
- Protected Attributes inherited from JobReferenceBase
JobDatam_jobData
 
JobManagerm_jobManager
 
IdType m_moleQueueId
 

Detailed Description

Server-side interface to JobData properties.

Author
David C. Lonie

The Job class provides a lightweight interface to a specific instance of JobData. Since JobData contains dynamic information that changes during its lifetime, the Job interface forwards requests to a JobData instance, which ensures that all references to job information are synced throughout the application.

The Job class also ensures that JobData is modified in a consistent way. For example, calling the Job::setQueueId method will cause JobManager to emit the JobManager::jobQueueIdChanged signal, so that listeners (e.g. GUI elements) can be made aware of the change.

The JobReferenceBase class holds and validates a pointer to a JobData instance and will detect when the associated JobData object is removed from the JobManager (such as when the user deletes a job from the job table). To check the validity of the JobData pointer, use Job::isValid(), defined in JobReferenceBase.

To serialize a collection of valid Job objects as references (e.g., to maintain state in a Queue implementation between sessions), store the identifier returned from Job::moleQueueId() in the data store, and then deserialize the Job using JobManager::lookupJobByMoleQueueId.

Full serialization of all Job details can be performed by saving and restoring the JobData state via the Job::hash() and Job::setFromHash() methods. However, this should not need to be performed outside of the JobManager's serialization methods.

Constructor & Destructor Documentation

Job ( JobData jobdata = NULL)

Construct a new Job object with the specified JobData.

Job ( JobManager jobManager,
IdType  mQId 
)

Construct a new Job object for the job with the MoleQueueId in the indicated JobManager

Job ( const JobReferenceBase other)

Construct a new Job object with the same JobData as other.

Member Function Documentation

QJsonObject toJsonObject ( ) const
Returns
The JobData's internal state as a QJsonObject
void setFromJson ( const QJsonObject &  state)

Update the JobData's internal state from a QJsonObject.

void setQueue ( const QString &  newQueue)
Parameters
newQueuename of the queue.
QString queue ( ) const
Returns
Name of queue to use.
void setProgram ( const QString &  newProgram)
Parameters
newProgramName of the program.
QString program ( ) const
Returns
Name of program to run.
void setJobState ( JobState  state)

Set the current JobState for the job. Calling this function with a different JobState will cause the JobManager::jobStateChanged signal to be emitted.

Parameters
stateStatus of job
JobState jobState ( ) const
Returns
Status of job
void setDescription ( const QString &  newDesc)
Parameters
newDescDescription of job
QString description ( ) const
Returns
newDesc Description of job
void setInputFile ( const FileSpecification spec)
Parameters
filespecFileSpecification describing the main input file (called by the executable)
FileSpecification inputFile ( ) const
Returns
FileSpecification describing the main input file (called by the executable)
void setAdditionalInputFiles ( const QList< FileSpecification > &  files)
Parameters
filesFileSpecification objects describing additional input files to be placed in the working directory of the job prior to execution.
QList<FileSpecification> additionalInputFiles ( ) const
Returns
FileSpecification objects describing additional input files to be placed in the working directory of the job prior to execution.
void addInputFile ( const FileSpecification spec)

param spec FileSpecification describing an input file to append to the additional input file list.

void setOutputDirectory ( const QString &  path)

Set the output directory for the job. If empty, the Server will set it to the temporary working directory once the job is accepted. Otherwise, the output files will be copied to the specified location when the job completes.

QString outputDirectory ( ) const
Returns
String containing a location to copy the output files to after the job completes. Ignored if empty.
void setLocalWorkingDirectory ( const QString &  path)
Parameters
pathTemporary working directory where files are stored during job execution
Warning
This is set internally by MoleQueue, do not modify.
QString localWorkingDirectory ( ) const
Returns
Temporary working directory where files are stored during job execution.
void setCleanRemoteFiles ( bool  clean)
Parameters
cleanIf true, delete any working files on the remote server. Default: false.
bool cleanRemoteFiles ( ) const
Returns
If true, delete any working files on the remote server. Default: false.
void setRetrieveOutput ( bool  b)
Parameters
bIf true, copies files back from remote server. Default: true
bool retrieveOutput ( ) const
Returns
If true, copies files back from remote server. Default: true
void setCleanLocalWorkingDirectory ( bool  b)
Parameters
bIf true, the local working files are removed after job is complete. Should be used with setOutputDirectory. Default: false
bool cleanLocalWorkingDirectory ( ) const
Returns
If true, the local working files are removed after job is complete. Should be used with setOutputDirectory. Default: false
void setHideFromGui ( bool  b)
Parameters
bIf true, the job will not appear in the MoleQueue user interface by default. Useful for automated batch jobs.
bool hideFromGui ( ) const
Returns
If true, the job will not appear in the queue. Default: false
void setPopupOnStateChange ( bool  b)
Parameters
bIf true, changes in the job state will trigger a popup notification from the MoleQueue system tray icon. Default: false
bool popupOnStateChange ( ) const
Returns
If true, changes in the job state will trigger a popup notification from the MoleQueue system tray icon. Default: false
void setNumberOfCores ( int  num)
Parameters
numThe total number of processor cores to use (if applicable). Default: 1
int numberOfCores ( ) const
Returns
The total number of processor cores to use (if applicable). Default: 1
void setMaxWallTime ( int  minutes)
Parameters
minutesThe maximum walltime for this job in minutes. Setting this to a value <= 0 will use the queue-specific default max walltime. Only available for remote queues. Default is -1.
int maxWallTime ( ) const
Returns
The maximum walltime for this job in minutes. Setting this to a value <= 0 will use the queue-specific default max walltime. Only available for remote queues. Default is -1.
void setMoleQueueId ( IdType  id)
Parameters
idThe new MoleQueue id for this job.
Warning
Do not call this function except in Server or Client as a response to the JobManager::jobAboutToBeAdded signal.
IdType moleQueueId ( ) const
Returns
Internal MoleQueue identifier
void setQueueId ( IdType  id)

Set the job's queue id. Calling this function will cause the.

Parameters
idQueue Job ID.
IdType queueId ( ) const
Returns
Queue Job ID
void setKeywords ( const QHash< QString, QString > &  keyrep)
Parameters
keyrepThe keyword replacement hash for this job.
QHash<QString, QString> keywords ( ) const
Returns
The keyword replacement hash for this job.
void setKeywordReplacement ( const QString &  keyword,
const QString &  replacement 
)

Add a keyword / replacement pair for this job.

bool hasKeywordReplacement ( const QString &  keyword) const
Returns
True if the keyword has a replacement.
QString lookupKeywordReplacement ( const QString &  keyword) const
Returns
The replacement string for the keyword.
void replaceKeywords ( QString &  launchScript) const

Apply the replacements in the keywords() hash to the script.

Note
Do not call this directly, use Queue::replaceKeywords instead.

The documentation for this class was generated from the following file: