NodesNamespace.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace Elasticsearch\Namespaces;
  3. /**
  4. * Class NodesNamespace
  5. *
  6. * @category Elasticsearch
  7. * @package Elasticsearch\Namespaces\NodesNamespace
  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 NodesNamespace extends AbstractNamespace
  13. {
  14. /**
  15. * $params['fields'] = (list) A comma-separated list of fields for `fielddata` metric (supports wildcards)
  16. * ['metric_family'] = (enum) Limit the information returned to a certain metric family
  17. * ['metric'] = (enum) Limit the information returned for `indices` family to a specific metric
  18. * ['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  19. * ['all'] = (boolean) Return all available information
  20. * ['clear'] = (boolean) Reset the default level of detail
  21. * ['fs'] = (boolean) Return information about the filesystem
  22. * ['http'] = (boolean) Return information about HTTP
  23. * ['indices'] = (boolean) Return information about indices
  24. * ['jvm'] = (boolean) Return information about the JVM
  25. * ['network'] = (boolean) Return information about network
  26. * ['os'] = (boolean) Return information about the operating system
  27. * ['process'] = (boolean) Return information about the Elasticsearch process
  28. * ['thread_pool'] = (boolean) Return information about the thread pool
  29. * ['transport'] = (boolean) Return information about transport
  30. *
  31. * @param $params array Associative array of parameters
  32. *
  33. * @return array
  34. */
  35. public function stats($params = array())
  36. {
  37. $nodeID = $this->extractArgument($params, 'node_id');
  38. $metric = $this->extractArgument($params, 'metric');
  39. $index_metric = $this->extractArgument($params, 'index_metric');
  40. /** @var callback $endpointBuilder */
  41. $endpointBuilder = $this->endpoints;
  42. /** @var \Elasticsearch\Endpoints\Cluster\Nodes\Stats $endpoint */
  43. $endpoint = $endpointBuilder('Cluster\Nodes\Stats');
  44. $endpoint->setNodeID($nodeID)
  45. ->setMetric($metric)
  46. ->setIndexMetric($index_metric)
  47. ->setParams($params);
  48. return $this->performRequest($endpoint);
  49. }
  50. /**
  51. * $params['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  52. * ['metric'] = (list) A comma-separated list of metrics you wish returned. Leave empty to return all.
  53. * ['flat_settings'] = (boolean) Return settings in flat format (default: false)
  54. * ['human'] = (boolean) Whether to return time and byte values in human-readable format.
  55. *
  56. * @param $params array Associative array of parameters
  57. *
  58. * @return array
  59. */
  60. public function info($params = array())
  61. {
  62. $nodeID = $this->extractArgument($params, 'node_id');
  63. $metric = $this->extractArgument($params, 'metric');
  64. /** @var callback $endpointBuilder */
  65. $endpointBuilder = $this->endpoints;
  66. /** @var \Elasticsearch\Endpoints\Cluster\Nodes\Info $endpoint */
  67. $endpoint = $endpointBuilder('Cluster\Nodes\Info');
  68. $endpoint->setNodeID($nodeID)->setMetric($metric);
  69. $endpoint->setParams($params);
  70. return $this->performRequest($endpoint);
  71. }
  72. /**
  73. * $params['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  74. * ['interval'] = (time) The interval for the second sampling of threads
  75. * ['snapshots'] = (number) Number of samples of thread stacktrace (default: 10)
  76. * ['threads'] = (number) Specify the number of threads to provide information for (default: 3)
  77. * ['type'] = (enum) The type to sample (default: cpu)
  78. *
  79. * @param $params array Associative array of parameters
  80. *
  81. * @return array
  82. */
  83. public function hotThreads($params = array())
  84. {
  85. $nodeID = $this->extractArgument($params, 'node_id');
  86. /** @var callback $endpointBuilder */
  87. $endpointBuilder = $this->endpoints;
  88. /** @var \Elasticsearch\Endpoints\Cluster\Nodes\HotThreads $endpoint */
  89. $endpoint = $endpointBuilder('Cluster\Nodes\HotThreads');
  90. $endpoint->setNodeID($nodeID);
  91. $endpoint->setParams($params);
  92. return $this->performRequest($endpoint);
  93. }
  94. /**
  95. * $params['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  96. *
  97. * @param array $params Associative array of parameters
  98. *
  99. * @return array
  100. */
  101. public function reloadSecureSettings($params = array())
  102. {
  103. $nodeID = $this->extractArgument($params, 'node_id');
  104. /** @var callback $endpointBuilder */
  105. $endpointBuilder = $this->endpoints;
  106. /** @var \Elasticsearch\Endpoints\Cluster\Nodes\ReloadSecureSettings $endpoint */
  107. $endpoint = $endpointBuilder('Cluster\Nodes\ReloadSecureSettings');
  108. $endpoint->setNodeID($nodeID);
  109. $endpoint->setParams($params);
  110. return $this->performRequest($endpoint);
  111. }
  112. }