1 | <?php |
||
14 | class Health |
||
15 | { |
||
16 | /** |
||
17 | * @var \Elastica\Client Client object. |
||
18 | */ |
||
19 | protected $_client; |
||
20 | |||
21 | /** |
||
22 | * @var array The cluster health data. |
||
23 | */ |
||
24 | protected $_data; |
||
25 | |||
26 | /** |
||
27 | * @param \Elastica\Client $client The Elastica client. |
||
28 | */ |
||
29 | public function __construct(Client $client) |
||
30 | { |
||
31 | $this->_client = $client; |
||
32 | $this->refresh(); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Retrieves the health data from the cluster. |
||
37 | * |
||
38 | * @return array |
||
39 | */ |
||
40 | protected function _retrieveHealthData() |
||
41 | { |
||
42 | $endpoint = new \Elasticsearch\Endpoints\Cluster\Health(); |
||
43 | $endpoint->setParams(['level' => 'shards']); |
||
44 | |||
45 | $response = $this->_client->requestEndpoint($endpoint); |
||
46 | |||
47 | return $response->getData(); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Gets the health data. |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | public function getData() |
||
59 | |||
60 | /** |
||
61 | * Refreshes the health data for the cluster. |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | public function refresh() |
||
71 | |||
72 | /** |
||
73 | * Gets the name of the cluster. |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | public function getClusterName() |
||
81 | |||
82 | /** |
||
83 | * Gets the status of the cluster. |
||
84 | * |
||
85 | * @return string green, yellow or red. |
||
86 | */ |
||
87 | public function getStatus() |
||
91 | |||
92 | /** |
||
93 | * TODO determine the purpose of this. |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function getTimedOut() |
||
101 | |||
102 | /** |
||
103 | * Gets the number of nodes in the cluster. |
||
104 | * |
||
105 | * @return int |
||
106 | */ |
||
107 | public function getNumberOfNodes() |
||
111 | |||
112 | /** |
||
113 | * Gets the number of data nodes in the cluster. |
||
114 | * |
||
115 | * @return int |
||
116 | */ |
||
117 | public function getNumberOfDataNodes() |
||
121 | |||
122 | /** |
||
123 | * Gets the number of active primary shards. |
||
124 | * |
||
125 | * @return int |
||
126 | */ |
||
127 | public function getActivePrimaryShards() |
||
131 | |||
132 | /** |
||
133 | * Gets the number of active shards. |
||
134 | * |
||
135 | * @return int |
||
136 | */ |
||
137 | public function getActiveShards() |
||
141 | |||
142 | /** |
||
143 | * Gets the number of relocating shards. |
||
144 | * |
||
145 | * @return int |
||
146 | */ |
||
147 | public function getRelocatingShards() |
||
151 | |||
152 | /** |
||
153 | * Gets the number of initializing shards. |
||
154 | * |
||
155 | * @return int |
||
156 | */ |
||
157 | public function getInitializingShards() |
||
161 | |||
162 | /** |
||
163 | * Gets the number of unassigned shards. |
||
164 | * |
||
165 | * @return int |
||
166 | */ |
||
167 | public function getUnassignedShards() |
||
171 | |||
172 | /** |
||
173 | * get the number of delayed unassined shards |
||
174 | * |
||
175 | * @return int |
||
176 | */ |
||
177 | public function getDelayedUnassignedShards() |
||
181 | |||
182 | /** |
||
183 | * @return int |
||
184 | */ |
||
185 | public function getNumberOfPendingTasks() |
||
189 | |||
190 | /** |
||
191 | * @return int |
||
192 | */ |
||
193 | public function getNumberOfInFlightFetch() |
||
197 | |||
198 | /** |
||
199 | * @return int |
||
200 | */ |
||
201 | public function getTaskMaxWaitingInQueueMillis() |
||
205 | |||
206 | /** |
||
207 | * @return int |
||
208 | */ |
||
209 | public function getActiveShardsPercentAsNumber() |
||
213 | |||
214 | /** |
||
215 | * Gets the status of the indices. |
||
216 | * |
||
217 | * @return \Elastica\Cluster\Health\Index[] |
||
218 | */ |
||
219 | public function getIndices() |
||
228 | } |
||
229 |