Open Journal Systems  2.4.8
 All Classes Namespaces Functions Variables Groups Pages
ProcessDAO Class Reference
Inheritance diagram for ProcessDAO:

Public Member Functions

_fromRow (&$row)
 authorizeProcess ($processId)
 canContinue ($processId)
 deleteObject (&$process)
 deleteObjectById ($processId)
 deleteZombies ($force=false)
 getNumberOfObjectsByProcessType ($processType)
 getObjectById ($processId)
insertObject ($processType, $maxParallelism)
 newDataObject ()
 ProcessDAO ()
 spawnProcesses (&$request, $handler, $op, $processType, $noOfProcesses)
- Public Member Functions inherited from DAO
 concat ()
 convertFromDB ($value, $type)
 convertToDB ($value, &$type)
 DAO ($dataSource=null, $callHooks=true)
 dateFromDB ($d)
 datetimeFromDB ($dt)
 datetimeToDB ($dt)
 dateToDB ($d)
 flushCache ()
 formatDateToDB ($date, $defaultNumWeeks=null, $acceptPastDate=true)
 getAffectedRows ()
 getDataChangedEvent ($elementId=null, $parentElementId=null)
getDataSource ()
 getDirectionMapping ($direction)
 getDriver ()
 getInsertId ($table= '', $id= '', $callHooks=true)
 getType ($value)
 replace ($table, $arrFields, $keyCols)
retrieve ($sql, $params=false, $callHooks=true)
retrieveCached ($sql, $params=false, $secsToCache=3600, $callHooks=true)
retrieveLimit ($sql, $params=false, $numRows=false, $offset=false, $callHooks=true)
retrieveRange ($sql, $params=false, $dbResultRange=null, $callHooks=true)
 setCacheDir ()
 setDataSource (&$dataSource)
 update ($sql, $params=false, $callHooks=true, $dieOnError=true)
 updateDataObjectSettings ($tableName, &$dataObject, $idArray)

Additional Inherited Members

- Public Attributes inherited from DAO

Detailed Description

Operations for retrieving and modifying process data.

See Also

Parallel processes are pooled. This defines a given number of process slots per pool. Once these slots are occupied, no new processes can be spawned for a given process type.

The process ID is not an integer but a globally unique string identifier that has to fulfill the following additional functions: 1) It is used as a one-time-key to authorize the the web request spawning a new process. It therefore has to be random enough to avoid it being guessed by an outsider. 2) We also use the process ID as a unique token to implement an atomic locking strategy to avoid race conditions when executing processes in parallel.

We use the uniqid() method to genereate one-time keys. This is not really cryptographically secure but it probably makes it difficult enough to guess the key to avoid abuse. This assumes that we don't start using processes for more sensitive tasks. If that happens we'd need to improve the randomness of the process id (e.g. via /dev/urandom or similar).

This usage of the processes table also explains why there is no updateObject() method in this DAO. If you need a process with different characteristics then insert a new one and delete stale processes.

Definition at line 65 of file

Member Function Documentation

& ProcessDAO::_fromRow ( $row)

Internal function to return a process object from a row.


Definition at line 373 of file

References newDataObject().

Referenced by getObjectById().

ProcessDAO::authorizeProcess (   $processId)

Check the one-time-key of a process. If the key has not been checked before then this call will mark it as used.

$processIdstring the unique process ID which is being used as one-time-key.

Definition at line 300 of file

References deleteObjectById(), getObjectById(), and DAO\update().

ProcessDAO::canContinue (   $processId)

Check whether a process identified by its ID can continue to run. This should be called about once a minute by running processes. If this method returns false then the process is required to halt immediately.


Definition at line 341 of file

References deleteObjectById(), and getObjectById().

ProcessDAO::deleteObject ( $process)

Delete a process.


Definition at line 171 of file

References deleteObjectById().

ProcessDAO::deleteObjectById (   $processId)

Delete a process by ID.


Definition at line 179 of file

References DAO\update().

Referenced by authorizeProcess(), canContinue(), and deleteObject().

ProcessDAO::deleteZombies (   $force = false)

Delete stale processes.

Zombie processes are remnants of process executions that for some reason died. We have to regularly remove them so that the process slots they occupy are freed for new processes.

$forcewhether to force zombie removal, even if they have been removed before.
See Also

Definition at line 198 of file

References DAO\update().

Referenced by insertObject(), and spawnProcesses().

ProcessDAO::getNumberOfObjectsByProcessType (   $processType)

Determine the number of currently running processes for a given process type.


Definition at line 149 of file

References DAO\retrieve().

Referenced by insertObject(), and spawnProcesses().

ProcessDAO::getObjectById (   $processId)

Get a process by ID.


Definition at line 128 of file

References _fromRow(), and DAO\retrieve().

Referenced by authorizeProcess(), and canContinue().

& ProcessDAO::insertObject (   $processType,

Insert a new process.

$processTypeinteger one of the PROCESS_TYPE_* constants
$maxParallelisminteger the max. number of parallel processes allowed for the given process type.
Process the new process instance, boolean false if there are too many parallel processes.

Definition at line 82 of file

References deleteZombies(), getNumberOfObjectsByProcessType(), newDataObject(), and DAO\update().

Referenced by spawnProcesses().

ProcessDAO::newDataObject ( )

Instantiate and return a new data object.


Definition at line 360 of file

Referenced by _fromRow(), and insertObject().

ProcessDAO::ProcessDAO ( )


Definition at line 69 of file

ProcessDAO::spawnProcesses ( $request,

Spawn new processes via web requests up to the given max. parallelism. NB: We currently do not support request parameters. If the requirement comes up this needs to be added.

$handlerstring a fully qualified handler class name
$opstring the operation to be called on the handler
$processTypeinteger one of the PROCESS_TYPE_* constants
$noOfProcessesinteger the number of processes to be spawned. The actual number of processes can be lower if the max parallelism is exceeded or if there are already processes of the same type running.
integer the actual number of spawned processes.

Definition at line 236 of file

References deleteZombies(), getNumberOfObjectsByProcessType(), and insertObject().

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