ClusterNamespace.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. namespace Elasticsearch\Namespaces;
  3. /**
  4. * Class ClusterNamespace
  5. *
  6. * @category Elasticsearch
  7. * @package Elasticsearch\Namespaces\ClusterNamespace
  8. * @author Zachary Tong <zach@elastic.co>
  9. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  10. * @link http://elastic.co
  11. */
  12. class ClusterNamespace extends AbstractNamespace
  13. {
  14. /**
  15. * $params['index'] = (string) Limit the information returned to a specific index
  16. * ['level'] = (enum) Specify the level of detail for returned information
  17. * ['local'] = (boolean) Return local information, do not retrieve the state from master node (default: false)
  18. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  19. * ['timeout'] = (time) Explicit operation timeout
  20. * ['wait_for_active_shards'] = (number) Wait until the specified number of shards is active
  21. * ['wait_for_nodes'] = (number) Wait until the specified number of nodes is available
  22. * ['wait_for_relocating_shards'] = (number) Wait until the specified number of relocating shards is finished
  23. * ['wait_for_status'] = (enum) Wait until cluster is in a specific state
  24. *
  25. * @param $params array Associative array of parameters
  26. *
  27. * @return array
  28. */
  29. public function health($params = array())
  30. {
  31. $index = $this->extractArgument($params, 'index');
  32. /** @var callback $endpointBuilder */
  33. $endpointBuilder = $this->endpoints;
  34. /** @var \Elasticsearch\Endpoints\Cluster\Health $endpoint */
  35. $endpoint = $endpointBuilder('Cluster\Health');
  36. $endpoint->setIndex($index);
  37. $endpoint->setParams($params);
  38. return $this->performRequest($endpoint);
  39. }
  40. /**
  41. * $params['dry_run'] = (boolean) Simulate the operation only and return the resulting state
  42. * ['filter_metadata'] = (boolean) Don't return cluster state metadata (default: false)
  43. * ['body'] = (boolean) Don't return cluster state metadata (default: false)
  44. * ['explain'] = (boolean) Return an explanation of why the commands can or cannot be executed
  45. *
  46. * @param $params array Associative array of parameters
  47. *
  48. * @return array
  49. */
  50. public function reroute($params = array())
  51. {
  52. $body = $this->extractArgument($params, 'body');
  53. /** @var callback $endpointBuilder */
  54. $endpointBuilder = $this->endpoints;
  55. /** @var \Elasticsearch\Endpoints\Cluster\Reroute $endpoint */
  56. $endpoint = $endpointBuilder('Cluster\Reroute');
  57. $endpoint->setBody($body);
  58. $endpoint->setParams($params);
  59. return $this->performRequest($endpoint);
  60. }
  61. /**
  62. * $params['filter_blocks'] = (boolean) Do not return information about blocks
  63. * ['filter_index_templates'] = (boolean) Do not return information about index templates
  64. * ['filter_indices'] = (list) Limit returned metadata information to specific indices
  65. * ['filter_metadata'] = (boolean) Do not return information about indices metadata
  66. * ['filter_nodes'] = (boolean) Do not return information about nodes
  67. * ['filter_routing_table'] = (boolean) Do not return information about shard allocation (`routing_table` and `routing_nodes`)
  68. * ['local'] = (boolean) Return local information, do not retrieve the state from master node (default: false)
  69. * ['master_timeout'] = (time) Specify timeout for connection to master
  70. *
  71. * @param $params array Associative array of parameters
  72. *
  73. * @return array
  74. */
  75. public function state($params = array())
  76. {
  77. $index = $this->extractArgument($params, 'index');
  78. $metric = $this->extractArgument($params, 'metric');
  79. /** @var callback $endpointBuilder */
  80. $endpointBuilder = $this->endpoints;
  81. /** @var \Elasticsearch\Endpoints\Cluster\State $endpoint */
  82. $endpoint = $endpointBuilder('Cluster\State');
  83. $endpoint->setParams($params)
  84. ->setIndex($index)
  85. ->setMetric($metric);
  86. return $this->performRequest($endpoint);
  87. }
  88. /**
  89. * $params['flat_settings'] = (boolean) Return settings in flat format (default: false)
  90. * ['human'] = (boolean) Whether to return time and byte values in human-readable format.
  91. *
  92. * @param $params array Associative array of parameters
  93. *
  94. * @return array
  95. */
  96. public function stats($params = array())
  97. {
  98. $nodeID = $this->extractArgument($params, 'node_id');
  99. /** @var callback $endpointBuilder */
  100. $endpointBuilder = $this->endpoints;
  101. /** @var \Elasticsearch\Endpoints\Cluster\Stats $endpoint */
  102. $endpoint = $endpointBuilder('Cluster\Stats');
  103. $endpoint->setNodeID($nodeID)
  104. ->setParams($params);
  105. return $this->performRequest($endpoint);
  106. }
  107. /**
  108. * $params['body'] = ()
  109. *
  110. * @param $params array Associative array of parameters
  111. *
  112. * @return array
  113. */
  114. public function putSettings($params = array())
  115. {
  116. $body = $this->extractArgument($params, 'body');
  117. /** @var callback $endpointBuilder */
  118. $endpointBuilder = $this->endpoints;
  119. /** @var \Elasticsearch\Endpoints\Cluster\Settings\Put $endpoint */
  120. $endpoint = $endpointBuilder('Cluster\Settings\Put');
  121. $endpoint->setBody($body);
  122. $endpoint->setParams($params);
  123. return $this->performRequest($endpoint);
  124. }
  125. /**
  126. * @param array $params
  127. *
  128. * @return array
  129. */
  130. public function getSettings($params = array())
  131. {
  132. /** @var callback $endpointBuilder */
  133. $endpointBuilder = $this->endpoints;
  134. /** @var \Elasticsearch\Endpoints\Cluster\Settings\Put $endpoint */
  135. $endpoint = $endpointBuilder('Cluster\Settings\Get');
  136. $endpoint->setParams($params);
  137. return $this->performRequest($endpoint);
  138. }
  139. /**
  140. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  141. * ['master_timeout'] = (time) Specify timeout for connection to master
  142. *
  143. * @param $params array Associative array of parameters
  144. *
  145. * @return array
  146. */
  147. public function pendingTasks($params = array())
  148. {
  149. /** @var callback $endpointBuilder */
  150. $endpointBuilder = $this->endpoints;
  151. /** @var \Elasticsearch\Endpoints\Cluster\PendingTasks $endpoint */
  152. $endpoint = $endpointBuilder('Cluster\PendingTasks');
  153. $endpoint->setParams($params);
  154. return $this->performRequest($endpoint);
  155. }
  156. /**
  157. * $params['include_yes_decisions'] = (bool) Return 'YES' decisions in explanation (default: false)
  158. *
  159. * @param $params array Associative array of parameters
  160. *
  161. * @return array
  162. */
  163. public function allocationExplain($params = array())
  164. {
  165. $body = $this->extractArgument($params, 'body');
  166. /** @var callback $endpointBuilder */
  167. $endpointBuilder = $this->endpoints;
  168. /** @var \Elasticsearch\Endpoints\Cluster\AllocationExplain $endpoint */
  169. $endpoint = $endpointBuilder('Cluster\AllocationExplain');
  170. $endpoint->setBody($body)
  171. ->setParams($params);
  172. return $this->performRequest($endpoint);
  173. }
  174. /**
  175. * $params[]
  176. *
  177. * @param $params array Associative array of parameters
  178. *
  179. * @return array
  180. */
  181. public function remoteInfo($params = array())
  182. {
  183. /** @var callback $endpointBuilder */
  184. $endpointBuilder = $this->endpoints;
  185. /** @var \Elasticsearch\Endpoints\Cluster\RemoteInfo $endpoint */
  186. $endpoint = $endpointBuilder('Cluster\RemoteInfo');
  187. return $this->performRequest($endpoint);
  188. }
  189. }