Skip to content

Commit 05c7906

Browse files
authored
Merge branch 'master' into settings-use-presets
2 parents 1a5828a + 18f2e32 commit 05c7906

9 files changed

Lines changed: 60 additions & 32 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/Command/NodeIndexQueueCommandController.php renamed to Classes/Command/NodeIndexQueueCommandController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Flowpack\ElasticSearch\ContentRepositoryQueueIndexer\UpdateAliasJob;
1010
use Flowpack\JobQueue\Common\Job\JobManager;
1111
use Flowpack\JobQueue\Common\Queue\QueueManager;
12+
use Flowpack\ElasticSearch\Domain\Model\Mapping;
13+
use Flowpack\JobQueue\Common\Exception as JobQueueException;
1214
use Neos\Flow\Annotations as Flow;
1315
use Neos\Flow\Cli\CommandController;
1416
use Neos\Flow\Persistence\PersistenceManagerInterface;
@@ -26,6 +28,7 @@ class NodeIndexQueueCommandController extends CommandController
2628

2729
const BATCH_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer';
2830
const LIVE_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer.Live';
31+
const DEFAULT_BATCH_SIZE = 500;
2932

3033
/**
3134
* @var JobManager
@@ -69,6 +72,12 @@ class NodeIndexQueueCommandController extends CommandController
6972
*/
7073
protected $nodeIndexer;
7174

75+
/**
76+
* @Flow\InjectConfiguration(package="Flowpack.ElasticSearch.ContentRepositoryQueueIndexer")
77+
* @var array
78+
*/
79+
protected $settings;
80+
7281
/**
7382
* Index all nodes by creating a new index and when everything was completed, switch the index alias.
7483
*
@@ -210,7 +219,7 @@ protected function indexWorkspace($workspaceName, $indexPostfix)
210219
$this->outputLine('<info>++</info> Indexing %s workspace', [$workspaceName]);
211220
$nodeCounter = 0;
212221
$offset = 0;
213-
$batchSize = 500;
222+
$batchSize = $this->settings['batchSize'] ?? static::DEFAULT_BATCH_SIZE;
214223
while (true) {
215224
$iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $batchSize);
216225

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/Domain/Repository/NodeDataRepository.php renamed to Classes/Domain/Repository/NodeDataRepository.php

File renamed without changes.

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/Indexer/NodeIndexer.php renamed to Classes/Indexer/NodeIndexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class NodeIndexer extends ContentRepositoryAdaptor\Indexer\NodeIndexer
3434

3535
/**
3636
* @param NodeInterface $node
37-
* @param string|null $targetWorkspaceName
37+
* @param string|null $targetWorkspaceName In case indexing is triggered during publishing, a target workspace name will be passed in
3838
*/
3939
public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
4040
{

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/IndexingJob.php renamed to Classes/IndexingJob.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use Flowpack\JobQueue\Common\Job\JobInterface;
77
use Flowpack\JobQueue\Common\Queue\Message;
88
use Flowpack\JobQueue\Common\Queue\QueueInterface;
9+
use Neos\ContentRepository\Domain\Model\NodeData;
910
use Neos\Flow\Annotations as Flow;
10-
use Neos\Flow\Log\SystemLoggerInterface;
1111
use Neos\Flow\Utility\Algorithms;
1212
use Neos\ContentRepository\Domain\Factory\NodeFactory;
1313
use Neos\ContentRepository\Domain\Model\NodeInterface;
@@ -52,7 +52,7 @@ class IndexingJob implements JobInterface
5252
/**
5353
* @var string
5454
*/
55-
protected $workspaceName;
55+
protected $targetWorkspaceName;
5656

5757
/**
5858
* @var string
@@ -66,13 +66,13 @@ class IndexingJob implements JobInterface
6666

6767
/**
6868
* @param string $indexPostfix
69-
* @param string $workspaceName
69+
* @param string $targetWorkspaceName In case indexing is triggered during publishing, a target workspace name will be passed in
7070
* @param array $nodes
7171
*/
72-
public function __construct($indexPostfix, $workspaceName, array $nodes)
72+
public function __construct($indexPostfix, $targetWorkspaceName, array $nodes)
7373
{
7474
$this->identifier = Algorithms::generateRandomString(24);
75-
$this->workspaceName = $workspaceName;
75+
$this->targetWorkspaceName = $targetWorkspaceName;
7676
$this->indexPostfix = $indexPostfix;
7777
$this->nodes = $nodes;
7878
}
@@ -94,7 +94,7 @@ public function execute(QueueInterface $queue, Message $message)
9494
/** @var NodeData $nodeData */
9595
$nodeData = $this->nodeDataRepository->findByIdentifier($node['nodeIdentifier']);
9696
$context = $this->contextFactory->create([
97-
'workspaceName' => $this->workspaceName,
97+
'workspaceName' => $this->targetWorkspaceName ?: $nodeData->getWorkspace()->getName(),
9898
'invisibleContentShown' => true,
9999
'inaccessibleContentShown' => false,
100100
'dimensions' => $node['dimensions']

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/LoggerTrait.php renamed to Classes/LoggerTrait.php

File renamed without changes.

Classes/Flowpack/ElasticSearch/ContentRepositoryQueueIndexer/UpdateAliasJob.php renamed to Classes/UpdateAliasJob.php

File renamed without changes.

Configuration/Settings.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ Flowpack:
22
ElasticSearch:
33
ContentRepositoryQueueIndexer:
44
enableLiveAsyncIndexing: true
5-
5+
# Change size of single batch jobs via this setting (fallback default is 500)
6+
# batchSize: 50
67
JobQueue:
78
Common:
89
presets:
910
'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer':
1011
className: 'Flowpack\JobQueue\Beanstalkd\Queue\BeanstalkdQueue'
1112
executeIsolated: true
1213
options:
13-
host: '127.0.0.1'
14-
port: 11300
14+
client:
15+
host: '127.0.0.1'
16+
port: 11300
1517

1618
queues:
1719
'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer':

README.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
# Neos CMS ElasticSearch indexer based on beanstalkd (job queue)
1+
# Neos CMS Elasticsearch indexer based on a job queue
22

3-
This package can be used to index a huge amount of nodes in ElasticSearch indexes. This
4-
package use Beanstalkd and the JobQueue package to handle ES indexing asynchronously.
3+
This package can be used to index a huge amount of nodes in Elasticsearch indexes. This
4+
package use the Flowpack JobQueue packages to handle the indexing asynchronously.
55

66
# Breaking change after an upgrade to 3.0
77

8-
## Install and configure your Queue package
8+
Previously the Beanstalk queue package was installed by default, this is no longer
9+
the case.
10+
11+
# Install and configure your Queue package
912

1013
You need to install the correct Queue package based on your needs.
1114

1215
Available packages:
1316

1417
- [sqlite](https://packagist.org/packages/flownative/jobqueue-sqlite)
15-
- [beanstalkd](https://packagist.org/packages/flownative/jobqueue-beanstalkd)
16-
- [doctrine](https://packagist.org/packages/flownative/jobqueue-doctrine)
17-
- [redis](https://packagist.org/packages/flownative/jobqueue-redis)
18+
- [beanstalkd](https://packagist.org/packages/flowpack/jobqueue-beanstalkd)
19+
- [doctrine](https://packagist.org/packages/flowpack/jobqueue-doctrine)
20+
- [redis](https://packagist.org/packages/flowpack/jobqueue-redis)
1821

1922
Please check the package documentation for specific configurations.
2023

21-
The default configuration use Beanstalkd, but you need to install it manually:
24+
The default configuration uses Beanstalkd, but you need to install it manually:
2225

2326
composer require flowpack/jobqueue-beanstalkd
24-
27+
2528
Check the ```Settings.yaml``` to adapt based on the Queue package, you need to adapt the ```className```:
2629

2730
Flowpack:
@@ -30,18 +33,32 @@ Check the ```Settings.yaml``` to adapt based on the Queue package, you need to a
3033
queues:
3134
'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer':
3235
className: 'Flowpack\JobQueue\Beanstalkd\Queue\BeanstalkdQueue'
33-
36+
3437
'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer.Live':
3538
className: 'Flowpack\JobQueue\Beanstalkd\Queue\BeanstalkdQueue'
3639

37-
40+
If you use the [doctrine](https://packagist.org/packages/flownative/jobqueue-doctrine) package you have to set the ```tableName``` manually:
41+
42+
Flowpack:
43+
JobQueue:
44+
Common:
45+
queues:
46+
'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer':
47+
className: 'Flowpack\JobQueue\Doctrine\Queue\DoctrineQueue'
48+
options:
49+
tableName: 'flowpack_jobqueue_QueueIndexer'
50+
51+
'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer.Live':
52+
className: 'Flowpack\JobQueue\Doctrine\Queue\DoctrineQueue'
53+
options:
54+
tableName: 'flowpack_jobqueue_QueueIndexerLive'
3855

3956
# Batch Indexing
4057

4158
## How to build indexing job
4259

4360
flow nodeindexqueue:build --workspace live
44-
61+
4562
## How to process indexing job
4663

4764
You can use this CLI command to process indexing job:
@@ -56,20 +73,20 @@ You can disable async live indexing by editing ```Settings.yaml```:
5673
ElasticSearch:
5774
ContentRepositoryQueueIndexer:
5875
enableLiveAsyncIndexing: false
59-
76+
6077
You can use this CLI command to process indexing job:
6178

62-
flow nodeindexqueue:work --queue live
79+
flow nodeindexqueue:work --queue live
6380

6481
# Supervisord configuration
6582

6683
You can use tools like ```supervisord``` to manage long runing process. Bellow you can
6784
found a basic configuration:
6885

6986
[supervisord]
70-
87+
7188
[supervisorctl]
72-
89+
7390
[program:elasticsearch_batch_indexing]
7491
command=php flow nodeindexqueue:work --queue batch
7592
stdout_logfile=AUTO
@@ -80,7 +97,7 @@ found a basic configuration:
8097
autostart=true
8198
autorestart=true
8299
stopsignal=QUIT
83-
100+
84101
[program:elasticsearch_live_indexing]
85102
command=php flow nodeindexqueue:work --queue live
86103
stdout_logfile=AUTO

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "flowpack/elasticsearch-contentrepositoryqueueindexer",
3-
"type": "typo3-flow-package",
4-
"description": "Neos CMS ElasticSearch indexer based on beanstalkd (job queue)",
3+
"type": "neos-package",
4+
"description": "Neos CMS Elasticsearch indexer based on a job queue",
55
"license": "MIT",
66
"require": {
77
"flowpack/jobqueue-common": "^2.0.0",
88
"flowpack/elasticsearch-contentrepositoryadaptor": "^4.0.0"
99
},
1010
"autoload": {
11-
"psr-0": {
12-
"Flowpack\\ElasticSearch\\ContentRepositoryQueueIndexer": "Classes"
11+
"psr-4": {
12+
"Flowpack\\ElasticSearch\\ContentRepositoryQueueIndexer\\": "Classes"
1313
}
1414
},
1515
"extra": {

0 commit comments

Comments
 (0)