mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Synchro: fixed issue in the counter (deletion of replicas) and improved the behavior in case of an error happening in the underlying process
SVN:trunk[1736]
This commit is contained in:
@@ -115,11 +115,13 @@ try
|
||||
}
|
||||
if ($oSynchroExec->DoSynchronizeChunk($oLog, $oChange, $iChunkSize))
|
||||
{
|
||||
// The last line MUST follow this convention
|
||||
$oP->p("continue");
|
||||
}
|
||||
else
|
||||
{
|
||||
$oP->p("done!");
|
||||
// The last line MUST follow this convention
|
||||
$oP->p("finished");
|
||||
}
|
||||
$oP->output();
|
||||
}
|
||||
|
||||
@@ -2112,7 +2112,8 @@ class SynchroExecution
|
||||
|
||||
$sSelectTotal = "SELECT SynchroReplica WHERE sync_source_id = :source_id";
|
||||
$oSetTotal = new DBObjectSet(DBObjectSearch::FromOQL($sSelectTotal), array() /* order by*/, array('source_id' => $this->m_oDataSource->GetKey()));
|
||||
$this->m_oStatLog->Set('stats_nb_replica_total', $oSetTotal->Count());
|
||||
$this->m_iCountAllReplicas = $oSetTotal->Count();
|
||||
$this->m_oStatLog->Set('stats_nb_replica_total', $this->m_iCountAllReplicas);
|
||||
|
||||
$this->m_oStatLog->DBInsertTracked($this->m_oChange);
|
||||
}
|
||||
@@ -2215,12 +2216,6 @@ class SynchroExecution
|
||||
}
|
||||
}
|
||||
|
||||
// Count the replicas
|
||||
$sSelectAll = "SELECT SynchroReplica WHERE sync_source_id = :source_id";
|
||||
$oSetAll = new DBObjectSet(DBObjectSearch::FromOQL($sSelectAll), array() /* order by*/, array('source_id' => $this->m_oDataSource->GetKey()));
|
||||
$this->m_iCountAllReplicas = $oSetAll->Count();
|
||||
$this->m_oStatLog->Set('stats_nb_replica_total', $this->m_iCountAllReplicas);
|
||||
|
||||
// Compute and keep track of the limit date taken into account for obsoleting replicas
|
||||
//
|
||||
if ($this->m_oLastFullLoadStartDate == null)
|
||||
@@ -2361,23 +2356,34 @@ class SynchroExecution
|
||||
$aArguments['step_count'] = $iStepCount;
|
||||
$iStepCount++;
|
||||
|
||||
$this->m_oStatLog->AddTrace("Launching a separate process: step $iStepCount");
|
||||
|
||||
list ($iRes, $aOut) = utils::ExecITopScript('synchro/priv_sync_chunk.php', $aArguments);
|
||||
|
||||
$this->m_oStatLog->AddTrace("The script replied:");
|
||||
foreach ($aOut as $sOut)
|
||||
{
|
||||
$this->m_oStatLog->AddTrace(">>> $sOut");
|
||||
}
|
||||
|
||||
// Reload the log that has been modified by the processes
|
||||
$this->m_oStatLog->Reload();
|
||||
|
||||
$sLastRes = strtolower(trim(end($aOut)));
|
||||
$bContinue = ($sLastRes == 'continue');
|
||||
switch($sLastRes)
|
||||
{
|
||||
case 'continue':
|
||||
$bContinue = true;
|
||||
break;
|
||||
|
||||
case 'finished':
|
||||
$bContinue = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->m_oStatLog->AddTrace("The script did not reply with the expected keywords:");
|
||||
$aIndentedOut = array();
|
||||
foreach ($aOut as $sOut)
|
||||
{
|
||||
$aIndentedOut[] = "-> $sOut";
|
||||
$this->m_oStatLog->AddTrace(">>> $sOut");
|
||||
}
|
||||
throw new Exception("Encountered an error in an underspinned process:\n".implode("\n", $aIndentedOut));
|
||||
}
|
||||
}
|
||||
while ($bContinue);
|
||||
|
||||
// Reload the log that has been modified by the processes
|
||||
$this->m_oStatLog->Reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user