mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
Thanks to Marco Hermo and Brett Tasker for helping with this * Bump framework/cms to ^4.0@dev * WIP Silverstripe 4 compatibility fixes * more replacements and patches to migrate this module to 4.0 * Update composer.json * remove php <5.5 from travis.yml * WIP more SS4 compatibility fixes * WIP fix solr path to use DIR, avoid hardcoded module name * WIP respect current include path * WIP Namespacing and use on SearchIndex class * Namespacing for tests * WIP add namespaces to all classes * Second push of Test changes + namespacing * WIP split Solr files with multiple classes into single file / single class. Adjust namespaces * Fix PHP errors in test * break out search components with multiple classes into individual files and change namespaces * Update namespacing for Search indexes and variants in tests * Batch fixes for tests #2 * Update _config.php to use namespace * Use root namespace in referencing Apache_Solr_Document * Migrate task names so that the name is not fully qualified
101 lines
2.3 KiB
PHP
101 lines
2.3 KiB
PHP
<?php
|
|
namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs;
|
|
if (!interface_exists('QueuedJob')) {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Represents a queuedjob which invokes a reindex
|
|
*/
|
|
class SolrReindexQueuedJob extends SolrReindexQueuedJobBase
|
|
{
|
|
/**
|
|
* Size of each batch to run
|
|
*
|
|
* @var int
|
|
*/
|
|
protected $batchSize;
|
|
|
|
/**
|
|
* Name of devtask Which invoked this
|
|
* Not necessary for re-index processing performed entirely by queuedjobs
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $taskName;
|
|
|
|
/**
|
|
* List of classes to filter
|
|
*
|
|
* @var array|string
|
|
*/
|
|
protected $classes;
|
|
|
|
public function __construct($batchSize = null, $taskName = null, $classes = null)
|
|
{
|
|
$this->batchSize = $batchSize;
|
|
$this->taskName = $taskName;
|
|
$this->classes = $classes;
|
|
parent::__construct();
|
|
}
|
|
|
|
public function getJobData()
|
|
{
|
|
$data = parent::getJobData();
|
|
|
|
// Custom data
|
|
$data->jobData->batchSize = $this->batchSize;
|
|
$data->jobData->taskName = $this->taskName;
|
|
$data->jobData->classes = $this->classes;
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function setJobData($totalSteps, $currentStep, $isComplete, $jobData, $messages)
|
|
{
|
|
parent::setJobData($totalSteps, $currentStep, $isComplete, $jobData, $messages);
|
|
|
|
// Custom data
|
|
$this->batchSize = $jobData->batchSize;
|
|
$this->taskName = $jobData->taskName;
|
|
$this->classes = $jobData->classes;
|
|
}
|
|
|
|
public function getSignature()
|
|
{
|
|
return __CLASS__;
|
|
}
|
|
|
|
public function getTitle()
|
|
{
|
|
return 'Solr Reindex Job';
|
|
}
|
|
|
|
public function process()
|
|
{
|
|
$logger = $this->getLogger();
|
|
if ($this->jobFinished()) {
|
|
$logger->notice("reindex already complete");
|
|
return;
|
|
}
|
|
|
|
// Send back to processor
|
|
$logger->info("Beginning init of reindex");
|
|
$this
|
|
->getHandler()
|
|
->runReindex($logger, $this->batchSize, $this->taskName, $this->classes);
|
|
$logger->info("Completed init of reindex");
|
|
$this->isComplete = true;
|
|
}
|
|
|
|
/**
|
|
* Get size of batch
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getBatchSize()
|
|
{
|
|
return $this->batchSize;
|
|
}
|
|
}
|