| 1 | package Search::Elasticsearch::Client::0_90::Direct::Cluster; | ||
| 2 | $Search::Elasticsearch::Client::0_90::Direct::Cluster::VERSION = '6.81'; | ||
| 3 | use Moo; | ||
| 4 | with 'Search::Elasticsearch::Client::0_90::Role::API'; | ||
| 5 | with 'Search::Elasticsearch::Role::Client::Direct'; | ||
| 6 | __PACKAGE__->_install_api('cluster'); | ||
| 7 | |||
| 8 | 1; | ||
| 9 | |||
| 10 | =pod | ||
| 11 | |||
| 12 | =encoding UTF-8 | ||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | Search::Elasticsearch::Client::0_90::Direct::Cluster - A client for running cluster-level requests | ||
| 17 | |||
| 18 | =head1 VERSION | ||
| 19 | |||
| 20 | version 6.81 | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | This module provides methods to make cluster-level requests, such as | ||
| 25 | getting and setting cluster-level settings, manually rerouting shards, | ||
| 26 | and retrieving for monitoring purposes. | ||
| 27 | |||
| 28 | It does L<Search::Elasticsearch::Role::Client::Direct>. | ||
| 29 | |||
| 30 | =head1 METHODS | ||
| 31 | |||
| 32 | =head2 C<health()> | ||
| 33 | |||
| 34 | $response = $e->cluster->health( %qs_params ) | ||
| 35 | |||
| 36 | The C<health()> method is used to retrieve information about the cluster | ||
| 37 | health, returning C<red>, C<yellow> or C<green> to indicate the state | ||
| 38 | of the cluster, indices or shards. | ||
| 39 | |||
| 40 | Query string parameters: | ||
| 41 | C<level>, | ||
| 42 | C<local>, | ||
| 43 | C<master_timeout>, | ||
| 44 | C<timeout>, | ||
| 45 | C<wait_for_active_shards>, | ||
| 46 | C<wait_for_nodes>, | ||
| 47 | C<wait_for_relocating_shards>, | ||
| 48 | C<wait_for_status> | ||
| 49 | |||
| 50 | See the L<cluster health docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-health.html> | ||
| 51 | for more information. | ||
| 52 | |||
| 53 | =head2 C<pending_tasks()> | ||
| 54 | |||
| 55 | $response = $e->cluster->pending_tasks(); | ||
| 56 | |||
| 57 | Returns a list of cluster-level tasks still pending on the master node. | ||
| 58 | |||
| 59 | Query string parameters: | ||
| 60 | C<local>, | ||
| 61 | C<master_timeout> | ||
| 62 | |||
| 63 | See the L<pending tasks docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-pending.html> | ||
| 64 | for more information. | ||
| 65 | |||
| 66 | =head2 C<node_info()> | ||
| 67 | |||
| 68 | $response = $e->cluster->node_info( | ||
| 69 | node_id => $node_id | \@node_ids # optional | ||
| 70 | ); | ||
| 71 | |||
| 72 | The C<node_info()> method returns static information about the nodes in the | ||
| 73 | cluster, such as the configured maximum number of file handles, the maximum | ||
| 74 | configured heap size or the threadpool settings. | ||
| 75 | |||
| 76 | Query string parameters: | ||
| 77 | C<all>, | ||
| 78 | C<clear>, | ||
| 79 | C<http>, | ||
| 80 | C<jvm>, | ||
| 81 | C<network>, | ||
| 82 | C<os>, | ||
| 83 | C<plugin>, | ||
| 84 | C<process>, | ||
| 85 | C<settings>, | ||
| 86 | C<thread_pool>, | ||
| 87 | C<timeout>, | ||
| 88 | C<transport> | ||
| 89 | |||
| 90 | See the L<node_info docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-nodes-info.html> | ||
| 91 | for more information. | ||
| 92 | |||
| 93 | =head2 C<node_stats()> | ||
| 94 | |||
| 95 | $response = $e->cluster->node_stats( | ||
| 96 | node_id => $node_id | \@node_ids # optional | ||
| 97 | ); | ||
| 98 | |||
| 99 | The C<node_stats()> method returns statistics about the nodes in the | ||
| 100 | cluster, such as the number of currently open file handles, the current | ||
| 101 | heap memory usage or the current number of threads in use. | ||
| 102 | |||
| 103 | Stats can be returned for all nodes, or limited to particular nodes | ||
| 104 | with the C<node_id> parameter. | ||
| 105 | The L<indices_stats|Search::Elasticsearch::Client::0_90::Direct::Indices/indices_stats()> | ||
| 106 | information can also be retrieved on a per-node basis with the C<node_stats()> | ||
| 107 | method: | ||
| 108 | |||
| 109 | $response = $e->cluster->node_stats( | ||
| 110 | node_id => 'node_1', | ||
| 111 | indices => 1, | ||
| 112 | metric => 'docs' | ||
| 113 | ); | ||
| 114 | |||
| 115 | Query string parameters: | ||
| 116 | C<all>, | ||
| 117 | C<clear>, | ||
| 118 | C<fields>, | ||
| 119 | C<fs>, | ||
| 120 | C<http>, | ||
| 121 | C<indices>, | ||
| 122 | C<jvm>, | ||
| 123 | C<network>, | ||
| 124 | C<os>, | ||
| 125 | C<process>, | ||
| 126 | C<thread_pool>, | ||
| 127 | C<transport> | ||
| 128 | |||
| 129 | See the L<node_stats docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-nodes-stats.html> | ||
| 130 | for more information. | ||
| 131 | |||
| 132 | =head2 C<hot_threads()> | ||
| 133 | |||
| 134 | $response = $e->cluster->hot_threads( | ||
| 135 | node_id => $node_id | \@node_ids # optional | ||
| 136 | ) | ||
| 137 | |||
| 138 | The C<hot_threads()> method is a useful tool for diagnosing busy nodes. It | ||
| 139 | takes a snapshot of which threads are consuming the most CPU. | ||
| 140 | |||
| 141 | Query string parameters: | ||
| 142 | C<interval>, | ||
| 143 | C<snapshots>, | ||
| 144 | C<threads>, | ||
| 145 | C<type> | ||
| 146 | |||
| 147 | See the L<hot_threads docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-nodes-hot-threads.html> | ||
| 148 | for more information. | ||
| 149 | |||
| 150 | =head2 C<get_settings()> | ||
| 151 | |||
| 152 | $response = $e->cluster->get_settings() | ||
| 153 | |||
| 154 | The C<get_settings()> method is used to retrieve cluster-wide settings that | ||
| 155 | have been set with the L</put_settings()> method. | ||
| 156 | |||
| 157 | See the L<cluster settings docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-update-settings.html> | ||
| 158 | for more information. | ||
| 159 | |||
| 160 | =head2 C<put_settings()> | ||
| 161 | |||
| 162 | $response = $e->cluster->put_settings( %settings ); | ||
| 163 | |||
| 164 | The C<put_settings()> method is used to set cluster-wide settings, either | ||
| 165 | transiently (which don't survive restarts) or permanently (which do survive | ||
| 166 | restarts). | ||
| 167 | |||
| 168 | For instance: | ||
| 169 | |||
| 170 | $response = $e->cluster->put_settings( | ||
| 171 | body => { | ||
| 172 | transient => { "discovery.zen.minimum_master_nodes" => 5 } | ||
| 173 | } | ||
| 174 | ); | ||
| 175 | |||
| 176 | See the L<cluster settings docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-update-settings.html> | ||
| 177 | for more information. | ||
| 178 | |||
| 179 | =head2 C<state()> | ||
| 180 | |||
| 181 | $response = $e->cluster->state(); | ||
| 182 | |||
| 183 | The C<state()> method returns the current cluster state from the master node, | ||
| 184 | or from the responding node if C<local> is set to C<true>. | ||
| 185 | |||
| 186 | Query string parameters: | ||
| 187 | C<filter_blocks>, | ||
| 188 | C<filter_index_templates>, | ||
| 189 | C<filter_indices>, | ||
| 190 | C<filter_metadata>, | ||
| 191 | C<filter_nodes>, | ||
| 192 | C<filter_routing_table>, | ||
| 193 | C<local>, | ||
| 194 | C<master_timeout> | ||
| 195 | |||
| 196 | See the L<cluster state docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-state.html> | ||
| 197 | for more information. | ||
| 198 | |||
| 199 | =head2 C<reroute()> | ||
| 200 | |||
| 201 | $e->cluster->reroute( | ||
| 202 | body => { commands } # required | ||
| 203 | ); | ||
| 204 | |||
| 205 | The C<reroute()> method is used to manually reallocate shards from one | ||
| 206 | node to another. The C<body> should contain the C<commands> indicating | ||
| 207 | which changes should be made. For instance: | ||
| 208 | |||
| 209 | $e->cluster->reroute( | ||
| 210 | body => { | ||
| 211 | commands => [ | ||
| 212 | { move => { | ||
| 213 | index => 'test', | ||
| 214 | shard => 0, | ||
| 215 | from_node => 'node_1', | ||
| 216 | to_node => 'node_2 | ||
| 217 | }}, | ||
| 218 | { allocate => { | ||
| 219 | index => 'test', | ||
| 220 | shard => 1, | ||
| 221 | node => 'node_3' | ||
| 222 | }} | ||
| 223 | ] | ||
| 224 | } | ||
| 225 | ); | ||
| 226 | |||
| 227 | Query string parameters: | ||
| 228 | C<dry_run>, | ||
| 229 | C<filter_metadata> | ||
| 230 | |||
| 231 | See the L<reroute docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-reroute.html> | ||
| 232 | for more information. | ||
| 233 | |||
| 234 | =head2 C<shutdown()> | ||
| 235 | |||
| 236 | $e->cluster->shutdown( | ||
| 237 | node_id => $node_id | \@node_ids # optional | ||
| 238 | ); | ||
| 239 | |||
| 240 | The C<shutdown()> method is used to shutdown one or more nodes, or the whole | ||
| 241 | cluster. | ||
| 242 | |||
| 243 | Query string parameters: | ||
| 244 | C<delay>, | ||
| 245 | C<exit> | ||
| 246 | |||
| 247 | See the L<shutdown docs|http://www.elastic.co/guide/en/elasticsearch/reference/0.90/cluster-nodes-shutdown.html> | ||
| 248 | for more information. | ||
| 249 | |||
| 250 | =head1 AUTHOR | ||
| 251 | |||
| 252 | Enrico Zimuel <enrico.zimuel@elastic.co> | ||
| 253 | |||
| 254 | =head1 COPYRIGHT AND LICENSE | ||
| 255 | |||
| 256 | This software is Copyright (c) 2020 by Elasticsearch BV. | ||
| 257 | |||
| 258 | This is free software, licensed under: | ||
| 259 | |||
| 260 | The Apache License, Version 2.0, January 2004 | ||
| 261 | |||
| 262 | =cut | ||
| 263 | |||
| 264 | __END__ |