1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nord\Lumen\Elasticsearch\Pipelines\Payloads; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class ApplyMigrationPayload |
7
|
|
|
* @package Nord\Lumen\Elasticsearch\Pipelines\Payloads |
8
|
|
|
*/ |
9
|
|
|
class ApplyMigrationPayload extends MigrationPayload |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $targetVersionFile; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var int |
19
|
|
|
*/ |
20
|
|
|
private $batchSize; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var int |
24
|
|
|
*/ |
25
|
|
|
private $numberOfReplicas; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* ApplyMigrationPayload constructor. |
29
|
|
|
* |
30
|
|
|
* @param string $configurationPath |
31
|
|
|
* @param int $batchSize |
32
|
|
|
*/ |
33
|
|
|
public function __construct($configurationPath, $batchSize) |
34
|
|
|
{ |
35
|
|
|
parent::__construct($configurationPath); |
36
|
|
|
|
37
|
|
|
$this->batchSize = $batchSize; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $targetVersionFile |
42
|
|
|
*/ |
43
|
|
|
public function setTargetVersionFile($targetVersionFile) |
44
|
|
|
{ |
45
|
|
|
$this->targetVersionFile = $targetVersionFile; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getTargetVersionPath() |
52
|
|
|
{ |
53
|
|
|
return sprintf('%s/%s', $this->getIndexVersionsPath(), $this->targetVersionFile); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
public function getTargetConfiguration() |
60
|
|
|
{ |
61
|
|
|
return include $this->getTargetVersionPath(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getTargetVersionName() |
68
|
|
|
{ |
69
|
|
|
return $this->getTargetConfiguration()['index']; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return int |
74
|
|
|
*/ |
75
|
|
|
public function getBatchSize() |
76
|
|
|
{ |
77
|
|
|
return $this->batchSize; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return int |
82
|
|
|
*/ |
83
|
|
|
public function getNumberOfReplicas() |
84
|
|
|
{ |
85
|
|
|
return $this->numberOfReplicas; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param int $numberOfReplicas |
90
|
|
|
*/ |
91
|
|
|
public function setNumberOfReplicas($numberOfReplicas) |
92
|
|
|
{ |
93
|
|
|
$this->numberOfReplicas = $numberOfReplicas; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|