public function train()

in lib/php/libsdk/SDK/Build/PGO/Controller.php [189:235]


	public function train()
	{
		if (!$this->isInitialized()) {
			throw new Exception("PGO training environment is not initialized.");
		}

		echo "\nStarting PGO training using scenario '{$this->scenario}'.\n\n";
		$this->up();

		/* Clean the PGO db files, only needed once.
			Imply also, that any data created during init or
			startup is wasted. It is done by dumpbing the data
		 	from the current running processes and subsequently
		 	removing the files. */
		$php = $this->conf->getSrv("nginx")->getPhp();
		$pgo = new PGO($this->conf, $php);
		$pgo->waste();
		$pgo->clean();
		unset($pgo);

		$cases = $this->cases;
		foreach (new TrainingCaseIterator($this->conf) as $handler) {
			$name = $handler->getName();
			/* Just a white list handling for now. */
			if (is_array($cases)) {
				if (!in_array($name, $cases)) {
					continue;
				}
				$key = array_search($name, $cases);
				unset($cases[$key]);
			}

			echo "\n";
			$handler->run();
		}
		if (is_array($cases) && !empty($cases)) {
			echo "\n\033[31m WARNING: The cases " . implode(",", $cases) . " don't exist and was ignored!\033[0m\n\n";
		}

		/* All the PGC files are merged, simply clean them out. */
		$pgo = new PGO($this->conf, $php);
		$pgo->clean(true, false);
		unset($pgo);

		$this->down();
		echo "PGO training complete.\n";
	}