Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
AllClustersQueueingRemediator | |
100.00% |
9 / 9 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
canSendOptimizedJob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
redirectInIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
pageNotInIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
ghostPageInIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
pageInWrongIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
oldVersionInIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
oldDocument | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Sanity; |
4 | |
5 | use CirrusSearch\Assignment\ClusterAssignment; |
6 | use CirrusSearch\UpdateGroup; |
7 | use JobQueueGroup; |
8 | use MediaWiki\Title\Title; |
9 | use WikiPage; |
10 | |
11 | /** |
12 | * Remediator that forwards all actions to all writable clusters |
13 | * using the 'cluster' => null optimization |
14 | * @see \CirrusSearch\Job\CirrusGenericJob::decideClusters() |
15 | */ |
16 | class AllClustersQueueingRemediator implements Remediator { |
17 | |
18 | /** |
19 | * @var Remediator |
20 | */ |
21 | private $inner; |
22 | |
23 | /** |
24 | * @var string[] list of all writable clusters this remediator will write to |
25 | */ |
26 | private $clusters; |
27 | |
28 | /** |
29 | * @param ClusterAssignment $clusterAssignment |
30 | * @param JobQueueGroup $jobQueueGroup |
31 | */ |
32 | public function __construct( ClusterAssignment $clusterAssignment, JobQueueGroup $jobQueueGroup ) { |
33 | $this->clusters = $clusterAssignment->getWritableClusters( UpdateGroup::SANEITIZER ); |
34 | $this->inner = new QueueingRemediator( null, $jobQueueGroup ); |
35 | } |
36 | |
37 | /** |
38 | * Checker whether or not some remediations that are scheduled for the clusters |
39 | * defined in $clusters can be optimized by sending a single job per remediation |
40 | * instead duplicated remediations per cluster. |
41 | * |
42 | * @param array $clusters List of clusters affected by a remediation |
43 | * @return bool true if the list of clusters affected is the same than all writable clusters |
44 | * allowing the remediation to be sent to this Remediator |
45 | */ |
46 | public function canSendOptimizedJob( array $clusters ) { |
47 | return array_diff( $this->clusters, $clusters ) === array_diff( $clusters, $this->clusters ); |
48 | } |
49 | |
50 | /** |
51 | * @inheritDoc |
52 | */ |
53 | public function redirectInIndex( WikiPage $page ) { |
54 | $this->inner->redirectInIndex( $page ); |
55 | } |
56 | |
57 | /** |
58 | * @inheritDoc |
59 | */ |
60 | public function pageNotInIndex( WikiPage $page ) { |
61 | $this->inner->pageNotInIndex( $page ); |
62 | } |
63 | |
64 | /** |
65 | * @inheritDoc |
66 | */ |
67 | public function ghostPageInIndex( $docId, Title $title ) { |
68 | $this->inner->ghostPageInIndex( $docId, $title ); |
69 | } |
70 | |
71 | /** |
72 | * @inheritDoc |
73 | */ |
74 | public function pageInWrongIndex( $docId, WikiPage $page, $indexSuffix ) { |
75 | $this->inner->pageInWrongIndex( $docId, $page, $indexSuffix ); |
76 | } |
77 | |
78 | /** |
79 | * @inheritDoc |
80 | */ |
81 | public function oldVersionInIndex( $docId, WikiPage $page, $indexSuffix ) { |
82 | $this->inner->oldVersionInIndex( $docId, $page, $indexSuffix ); |
83 | } |
84 | |
85 | /** |
86 | * @inheritDoc |
87 | */ |
88 | public function oldDocument( WikiPage $page ) { |
89 | $this->inner->oldDocument( $page ); |
90 | } |
91 | } |