diff --git a/application/forms/SyncCheckForm.php b/application/forms/SyncCheckForm.php index 814f0c9c..63865889 100644 --- a/application/forms/SyncCheckForm.php +++ b/application/forms/SyncCheckForm.php @@ -57,7 +57,6 @@ class SyncCheckForm extends DirectorForm $this->setSuccessMessage( $this->translate('Nothing would change, this rule is still in sync') ); - parent::onSuccess(); } else { $this->addError($this->translate('Checking this sync rule failed')); } diff --git a/application/forms/SyncRunForm.php b/application/forms/SyncRunForm.php index 25875ab8..91b6869c 100644 --- a/application/forms/SyncRunForm.php +++ b/application/forms/SyncRunForm.php @@ -41,7 +41,5 @@ class SyncRunForm extends DirectorForm } else { $this->addError($this->translate('Synchronization failed')); } - - parent::onSuccess(); } } diff --git a/library/Director/Import/Sync.php b/library/Director/Import/Sync.php index 6e041e83..593811f6 100644 --- a/library/Director/Import/Sync.php +++ b/library/Director/Import/Sync.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Director\Import; use Exception; +use Icinga\Application\Benchmark; use Icinga\Data\Filter\Filter; use Icinga\Module\Director\Application\MemoryLimit; use Icinga\Module\Director\Data\Db\DbObject; @@ -173,6 +174,7 @@ class Sync { $this->run = SyncRun::start($this->rule); $this->runStartTime = microtime(true); + Benchmark::measure('Starting sync'); return $this; } @@ -260,6 +262,8 @@ class Sync */ protected function fetchImportedData() { + Benchmark::measure('Begin loading imported data'); + $this->imported = array(); $sourceKeyPattern = $this->rule->getSourceKeyPattern(); @@ -293,8 +297,10 @@ class Sync $usedColumns[$column] = $column; } } + Benchmark::measure(sprintf('Done pre-processing columns for source %s', $source->source_name)); $rows = $run->fetchRows($usedColumns); + Benchmark::measure(sprintf('Fetched source %s', $source->source_name)); $this->imported[$sourceId] = array(); foreach ($rows as $row) { @@ -335,6 +341,8 @@ class Sync unset($rows); } + Benchmark::measure('Done loading imported data'); + return $this; } @@ -368,6 +376,8 @@ class Sync protected function loadExistingObjects() { + Benchmark::measure('Begin loading existing objects'); + // TODO: Make object_type (template, object...) and object_name mandatory? if ($this->rule->hasCombinedKey()) { $this->objects = array(); @@ -412,6 +422,8 @@ class Sync $this->removeForeignListEntries(); } + Benchmark::measure('Done loading existing objects'); + return $this; } @@ -594,6 +606,8 @@ class Sync } } + Benchmark::measure('Begin preparing updated objects'); + /** @var DbObject|IcingaObject $object */ foreach ($newObjects as $key => $object) { if (array_key_exists($key, $this->objects)) { @@ -619,6 +633,8 @@ class Sync } } + Benchmark::measure('Done preparing updated objects'); + $noAction = array(); foreach ($this->rule->purgeStrategy()->listObjectsToPurge() as $key) { if (array_key_exists($key, $newObjects)) { @@ -634,6 +650,8 @@ class Sync } } + Benchmark::measure('Done marking objects for purge'); + foreach ($this->objects as $key => $object) { if (! $object->hasBeenModified() && ! $object->shouldBeRemoved()) { $noAction[] = $key; @@ -646,6 +664,8 @@ class Sync $this->isPrepared = true; + Benchmark::measure('Done preparing objects'); + return $this->objects; } @@ -657,6 +677,8 @@ class Sync */ public function apply() { + Benchmark::measure('Begin applying objects'); + $objects = $this->prepare(); $db = $this->db; $dba = $db->getDbAdapter(); @@ -711,6 +733,8 @@ class Sync $this->run->set('duration_ms', (int) round( (microtime(true) - $this->runStartTime) * 1000 ))->store(); + + Benchmark::measure('Done applying objects'); } catch (Exception $e) { $dba->rollBack();