/** * {@inheritdoc} */ public function run() { do { /** @var StepList $steps */ $steps = $this->stepListFactory->create(['mode' => 'delta']); /** * @var string $stepName * @var StageInterface[] $step */ foreach ($steps->getSteps() as $stepName => $step) { if (empty($step['delta'])) { continue; } $this->runDelta($step, $stepName); if (!empty($step['volume'])) { $this->runVolume($step, $stepName); } } $deltaLogs = $this->groupsReader->getGroups(); foreach ($deltaLogs as $deltaDocuments) { foreach (array_keys($deltaDocuments) as $documentName) { /** @var Mysql $adapter */ $adapter = $this->source->getAdapter(); $adapter->deleteProcessedRecords($this->source->addDocumentPrefix($this->source->getDeltaLogName($documentName))); } } $this->logger->info('Migration completed successfully'); if ($this->autoRestart) { $this->logger->info("Automatic restart in {$this->autoRestart} sec. Use CTRL-C to abort"); sleep($this->autoRestart); } } while ($this->autoRestart); return true; }
/** * @return bool */ public function perform() { $deltaLogs = $this->groupsReader->getGroups(); $this->progress->start(count($deltaLogs, 1) - count($deltaLogs)); foreach ($deltaLogs as $deltaDocuments) { foreach ($deltaDocuments as $documentName => $idKey) { $this->progress->advance(); if ($this->source->getDocument($documentName)) { $this->source->createDelta($documentName, $idKey); } } } $this->progress->finish(); return true; }