Skip to content

Commit

Permalink
fixup! Added support for concurrency in ibexa:migrate:richtext-namesp…
Browse files Browse the repository at this point in the history
…aces
  • Loading branch information
vidarl committed Jan 30, 2023
1 parent dfe0363 commit 1ab6c82
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/bundle/Command/MigrateNamespacesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ protected function iterate(): void
$cursor['stop'] = $this->getNextCursor($contentAttributeIDs);
while ($cursor['stop'] !== null) {
$this->createChildProcess($cursor, count($contentAttributeIDs));
//$this->updateNamespacesInColumns($cursor['start'], $cursor['stop']);

$cursor['start'] = $cursor['stop'];
//$this->advanceProgressBar(count($contentAttributeIDs));
$contentAttributeIDs = $this->gateway->getContentObjectAttributeIds($cursor['start'], $limit);
$cursor['stop'] = $this->getNextCursor($contentAttributeIDs);
}
Expand Down
53 changes: 53 additions & 0 deletions src/bundle/Command/MultiprocessComand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ abstract class MultiprocessComand extends Command
*/
protected $progressBar;

/**
* @var OutputInterface
*/
protected OutputInterface $output;

/**
* @var bool
*/
private bool $dryRun;

/**
* @var int
*/
private int $maxProcesses;

/**
Expand All @@ -53,8 +62,14 @@ abstract class MultiprocessComand extends Command
*/
private mixed $user;

/**
* @var int
*/
private int $iterationCount;

/**
* @var string
*/
private string $environment;

public function __construct(
Expand Down Expand Up @@ -154,18 +169,56 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::SUCCESS;
}

/**
* This method should return the total number of items to process.
*
* @return int
*/
abstract protected function getObjectCount(): int;

/**
* This method should process the subset of data, specified by the cursor
*
* @param mixed $cursor
* @return mixed
*/
abstract protected function processData(mixed $cursor);

/**
* This method is called once in every child process. It should return a cursor based on the input parameters
* to the subprocess command
*
* @return mixed
*/
abstract protected function constructCursorFromInputOptions(): mixed;

/**
* This method should return the command arguments that should be added when launching a new child process. It will
* typically be the arguments needed in order to construct the Cursor for the child process
*
* @param mixed $cursor
* @return array
*/
abstract protected function addChildProcessArguments(mixed $cursor): array;

/**
* The method should return true if the current process is a child process. This is typically detected using the
* custom command arguments used when launching a child proccess
*
* @return bool
*/
abstract protected function isChildProcess(): bool;

/**
* This is the method that is responsible for iterating over the dataset that is being processed and split it into
* chunks that can be processed by a child processes. In order to do that it will maintain a cursor and call
* createChildProcess() for each chunk.
*/
abstract protected function iterate(): void;

/**
* This method is called when all data has been completed successfully
*/
abstract protected function completed(): void;

public function isDryRun(): bool
Expand Down

0 comments on commit 1ab6c82

Please sign in to comment.