GlobalSearch::QueueInterface Class Reference

Abstract interface for job submission. More...

#include <globalsearch/queueinterface.h>

Inheritance diagram for GlobalSearch::QueueInterface:
GlobalSearch::LocalQueueInterface

List of all members.

Public Types

enum  QueueStatus {
  Unknown = -1, Success, Error, Queued,
  Running, CommunicationError, Started, Pending
}

Public Slots

virtual void readSettings (const QString &filename="")
virtual void writeSettings (const QString &filename="")
virtual bool writeInputFiles (Structure *s) const
virtual bool writeFiles (Structure *s, const QHash< QString, QString > &files) const =0
virtual bool startJob (Structure *s)=0
virtual bool stopJob (Structure *s)=0
virtual QueueInterface::QueueStatus getStatus (Structure *s) const =0
virtual bool prepareForStructureUpdate (Structure *s) const =0
virtual bool checkIfFileExists (Structure *s, const QString &filename, bool *exists)=0
virtual bool fetchFile (Structure *s, const QString &filename, QString *contents) const =0
virtual bool grepFile (Structure *s, const QString &matchText, const QString &filename, QStringList *matches=0, int *exitcode=0, const bool caseSensitive=true) const =0
QString getIDString () const
QStringList getTemplateFileNames () const
bool hasDialog ()
virtual QDialog * dialog ()

Public Member Functions

 QueueInterface (OptBase *parent, const QString &settingFile="")
virtual ~QueueInterface ()
virtual bool isReadyToSearch (QString *err)

Protected Attributes

OptBasem_opt
 Cached pointer to the parent OptBase class.
QString m_idString
 String identifying the type of queue interface.
QStringList m_templates
bool m_hasDialog
 Whether this QueueInterface has a configuration dialog.
QDialog * m_dialog
 Pointer to configuration dialog (may be NULL).

Detailed Description

Abstract interface for job submission.

Author:
David C. Lonie

Do not derive directly from this class. Instead, use LocalQueue or (more likely) RemoteQueue.

TODO detailed description.

Definition at line 41 of file queueinterface.h.


Member Enumeration Documentation

Possible status for running jobs

See also:
getStatus
Enumerator:
Unknown 

Something very bizarre has happened.

Success 

Job has completed successfully.

Error 

Job finished, but the optimization was unsuccessful.

Queued 

Job is queued.

Running 

Job is current running.

CommunicationError 

Communication with a remote server has failed.

Started 

Job has appeared in queue, but the Structure still returns Structure::Submitted instead of Structure::InProcess. This will be corrected in the next iteration of QueueManager::checkRunning().

Pending 

Job has been submitted, but has not appeared in queue.

Definition at line 65 of file queueinterface.h.


Constructor & Destructor Documentation

GlobalSearch::QueueInterface::QueueInterface ( OptBase parent,
const QString &  settingFile = "" 
) [inline, explicit]

Constructor

Parameters:
parent OptBase parent
settingFile Filename from which to initialize settings.

Definition at line 52 of file queueinterface.h.

virtual GlobalSearch::QueueInterface::~QueueInterface (  )  [inline, virtual]

Destructor

Definition at line 59 of file queueinterface.h.


Member Function Documentation

virtual bool GlobalSearch::QueueInterface::checkIfFileExists ( Structure s,
const QString &  filename,
bool *  exists 
) [pure virtual, slot]

Check if the file filename exists in the working directory of Structure s and store the result in exists.

Note:
This function uses the argument exists to report whether or not the file exists. The return value indicates whether the file check was performed without errors (e.g. network errors).
Returns:
True if the test encountered no errors, false otherwise.

Implemented in GlobalSearch::LocalQueueInterface.

Referenced by GlobalSearch::Optimizer::checkIfOutputFileExists().

virtual bool GlobalSearch::QueueInterface::fetchFile ( Structure s,
const QString &  filename,
QString *  contents 
) const [pure virtual, slot]

Retrieve the contents of the file filename for Structure s as a QString contents.

Returns:
True on success, false otherwise.

Implemented in GlobalSearch::LocalQueueInterface.

QString GlobalSearch::QueueInterface::getIDString (  )  const [inline, slot]
Returns:
The name of the queue interface (e.g. "Local", "PBS", etc)

Definition at line 249 of file queueinterface.h.

References m_idString.

Referenced by GlobalSearch::Optimizer::readTemplatesFromSettings(), and GlobalSearch::Optimizer::writeTemplatesToSettings().

virtual QueueInterface::QueueStatus GlobalSearch::QueueInterface::getStatus ( Structure s  )  const [pure virtual, slot]
Returns:
The queue status of Structure s.
QStringList GlobalSearch::QueueInterface::getTemplateFileNames (  )  const [inline, slot]
Returns:
The names of all template files associated with this interface.

Definition at line 255 of file queueinterface.h.

References m_templates.

Referenced by GlobalSearch::AbstractEditTab::getTemplateNames(), and GlobalSearch::Optimizer::updateQueueInterface().

virtual bool GlobalSearch::QueueInterface::grepFile ( Structure s,
const QString &  matchText,
const QString &  filename,
QStringList *  matches = 0,
int *  exitcode = 0,
const bool  caseSensitive = true 
) const [pure virtual, slot]

Grep through the file filename in Structure s's working directory, looking for matchText. The list of matches is returned in the QStringList matches and the exit status is returned as exitcode.

Possible exitcodes:

  • 0: Matches were found, execution successful
  • 1: No matches found, execution successful
  • 2: Execution unsuccessful
Parameters:
s Structure of interest
matchText Text to match
filename Name of file to grep
matches List of matches (return)
exitcode Exit code of grep (see details) (return)
caseSensitive If true, match case. Otherwise, perform case-insensitive search (e.g. grep -i) Default is true.
Returns:
True on success, false otherwise.
Note:
There are two types of failure possible here: Either the exitcode can be 2 or the function can return false. If the exitcode is 2, then grep failed to execute. If false, then there was a failure in the interface code, likely a communication error with a remote server.
On local queue interface, grep is not actually used and the exit code behavior is emulated.

Implemented in GlobalSearch::LocalQueueInterface.

Referenced by GlobalSearch::Optimizer::checkForSuccessfulOutput().

virtual bool GlobalSearch::QueueInterface::isReadyToSearch ( QString *  err  )  [inline, virtual]

Check that all mandatory internal variables are set. Check this before starting a search.

Parameters:
err String to be overwritten with an error message
Returns:
true if all variables are initialized, false otherwise. If false, err will be overwritten with a user-friendly error message.

Definition at line 97 of file queueinterface.h.

virtual bool GlobalSearch::QueueInterface::prepareForStructureUpdate ( Structure s  )  const [pure virtual, slot]

Perform any work needed before calling Optimizer::update. This function mainly exists for RemoteQueue classes to copy files back from the server, but may be used for other purposes. It is guaranteed to be called by Optimizer before updating.

Parameters:
s The structure that is to be updated.
Returns:
True on success, false otherwise.

Implemented in GlobalSearch::LocalQueueInterface.

Referenced by GlobalSearch::Optimizer::update().

virtual void GlobalSearch::QueueInterface::readSettings ( const QString &  filename = ""  )  [inline, virtual, slot]

Read optimizer data from file (.scheme or .state). If called without an argument, this function does nothing, i.e. it will not read optimizer data from the system config file.

Parameters:
filename Scheme or state file to load data from.
See also:
writeSettings

Definition at line 109 of file queueinterface.h.

virtual bool GlobalSearch::QueueInterface::startJob ( Structure s  )  [pure virtual, slot]

Start a job for Structure s.

Note:
Ensure that writeFiles is called before attempting to start the job.
Returns:
True on success, false otherwise.

Referenced by GlobalSearch::QueueManager::startJob().

virtual bool GlobalSearch::QueueInterface::stopJob ( Structure s  )  [pure virtual, slot]

Stop any currently running jobs for Structure s.

Returns:
True on success, false otherwise.

Referenced by GlobalSearch::QueueManager::stopJob().

virtual bool GlobalSearch::QueueInterface::writeFiles ( Structure s,
const QHash< QString, QString > &  files 
) const [pure virtual, slot]

Write the provided files in the hash files to the local working directory for Structure s and (if appropriate) copy them to a remote server.

Parameters:
s Structure of interest
files Key: filename, Value: text.
Note:
The filenames in files must not be absolute, but relative to the structure's working directory.
Returns:
True on success, false otherwise.

Implemented in GlobalSearch::LocalQueueInterface.

Referenced by writeInputFiles().

bool GlobalSearch::QueueInterface::writeInputFiles ( Structure s  )  const [virtual, slot]

Write the input files for Structure s to the appropriate location.

This function will also construct and write any queue-specific files (e.g. job.pbs for PBS queues) and copy them to the remote host if using a remote queue.

Returns:
True on success, false otherwise.

Definition at line 28 of file queueinterface.cpp.

References GlobalSearch::Optimizer::getInterpretedTemplates(), m_opt, GlobalSearch::OptBase::optimizer(), and writeFiles().

virtual void GlobalSearch::QueueInterface::writeSettings ( const QString &  filename = ""  )  [inline, virtual, slot]

Write optimizer data to file (.scheme or .state). If called without an argument, this function does nothing, i.e. it will not write optimizer data to the system config file.

Parameters:
filename Scheme or state file to write data to.
See also:
readSettings

Definition at line 119 of file queueinterface.h.

Referenced by GlobalSearch::Optimizer::writeSettings().


Member Data Documentation

QStringList containing list of all template filenames

Note:
templates are actually handled in Optimizer

Definition at line 283 of file queueinterface.h.

Referenced by getTemplateFileNames().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator
Generated on Mon Jul 16 14:40:04 2012 for GlobalSearch by  doxygen 1.6.3