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:
Romain Quetiez
2011-12-21 12:11:56 +00:00
parent 4869d5e92b
commit ea2843f04e
2 changed files with 28 additions and 20 deletions

View File

@@ -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();
}

View File

@@ -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
{