Background processes - API ready for periodicity management

SVN:trunk[1137]
This commit is contained in:
Romain Quetiez
2011-03-21 11:17:42 +00:00
parent c3bd0b1b9e
commit de5ccf5908
4 changed files with 19 additions and 4 deletions

View File

@@ -26,6 +26,11 @@
class ExecAsyncTask implements iBackgroundProcess
{
public function GetPeriodicity()
{
return 2; // seconds
}
public function Process($iTimeLimit)
{
$sOQL = "SELECT AsyncTask WHERE ISNULL(started)";

View File

@@ -26,6 +26,7 @@
interface iBackgroundProcess
{
public function GetPeriodicity();
public function Process($iUnixTimeLimit);
}

View File

@@ -612,6 +612,11 @@ abstract class ResponseTicket extends Ticket
class ProcessSLAResponseTicket implements iBackgroundProcess
{
public function GetPeriodicity()
{
return 2; // seconds
}
public function Process($iTimeLimit)
{
$oMyChange = new CMDBChange();
@@ -622,7 +627,7 @@ class ProcessSLAResponseTicket implements iBackgroundProcess
$aReport = array();
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'new\' AND tto_escalation_deadline <= NOW()'));
while ($oToEscalate = $oSet->Fetch())
while ((time() < $iTimeLimit) && $oToEscalate = $oSet->Fetch())
{
$oToEscalate->ApplyStimulus('ev_timeout');
//$oToEscalate->Set('tto_escalation_deadline', null);
@@ -631,7 +636,7 @@ class ProcessSLAResponseTicket implements iBackgroundProcess
}
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'assigned\' AND ttr_escalation_deadline <= NOW()'));
while ($oToEscalate = $oSet->Fetch())
while ((time() < $iTimeLimit) && $oToEscalate = $oSet->Fetch())
{
$oToEscalate->ApplyStimulus('ev_timeout');
//$oToEscalate->Set('ttr_escalation_deadline', null);
@@ -640,7 +645,7 @@ class ProcessSLAResponseTicket implements iBackgroundProcess
}
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'resolved\' AND closure_deadline <= NOW()'));
while ($oToEscalate = $oSet->Fetch())
while ((time() < $iTimeLimit) && $oToEscalate = $oSet->Fetch())
{
$oToEscalate->ApplyStimulus('ev_close');
//$oToEscalate->Set('closure_deadline', null);

View File

@@ -31,6 +31,10 @@ require_once(APPROOT.'/application/clipage.class.inc.php');
require_once(APPROOT.'/application/startup.inc.php');
// Known limitation - the background process periodicity is NOT taken into account
function CronExec($oP, $aBackgroundProcesses, $bVerbose)
{
$iStarted = time();
@@ -117,7 +121,7 @@ foreach(get_declared_classes() as $sPHPClass)
{
$oExecInstance = new $sPHPClass;
}
$aBackgroundProcesses[] = $oExecInstance;
$aBackgroundProcesses[$sPHPClass] = $oExecInstance;
}
}