Debian Codegraph @

lib/Search/Elasticsearch/Client/2_0/Direct/Cluster.pm

raw
1 package Search::Elasticsearch::Client::2_0::Direct::Cluster;
2 $Search::Elasticsearch::Client::2_0::Direct::Cluster::VERSION = '6.81';
3 use Moo;
4 with 'Search::Elasticsearch::Client::2_0::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::2_0::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(
35 index => 'index' | \@indices # optional
36 );
37
38 The C<health()> method is used to retrieve information about the cluster
39 health, returning C<red>, C<yellow> or C<green> to indicate the state
40 of the cluster, indices or shards.
41
42 Query string parameters:
43 C<level>,
44 C<local>,
45 C<master_timeout>,
46 C<timeout>,
47 C<wait_for_active_shards>,
48 C<wait_for_nodes>,
49 C<wait_for_relocating_shards>,
50 C<wait_for_status>
51
52 See the L<cluster health docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html>
53 for more information.
54
55 =head2 C<stats()>
56
57 $response = $e->cluster->stats(
58 node_id => 'node' | \@nodes # optional
59 );
60
61 Returns high-level cluster stats, optionally limited to the listed nodes.
62
63 Query string parameters:
64 C<flat_settings>,
65 C<human>,
66 C<timeout>
67
68 See the L<cluster stats docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html>
69 for more information.
70
71 =head2 C<get_settings()>
72
73 $response = $e->cluster->get_settings()
74
75 The C<get_settings()> method is used to retrieve cluster-wide settings that
76 have been set with the L</put_settings()> method.
77
78 Query string parameters:
79 C<flat_settings>,
80 C<master_timeout>,
81 C<timeout>
82
83 See the L<cluster settings docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html>
84 for more information.
85
86 =head2 C<put_settings()>
87
88 $response = $e->cluster->put_settings( %settings );
89
90 The C<put_settings()> method is used to set cluster-wide settings, either
91 transiently (which don't survive restarts) or permanently (which do survive
92 restarts).
93
94 For instance:
95
96 $response = $e->cluster->put_settings(
97 body => {
98 transient => { "discovery.zen.minimum_master_nodes" => 5 }
99 }
100 );
101
102 Query string parameters:
103 C<flat_settings>
104
105 See the L<cluster settings docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html>
106 for more information.
107
108 =head2 C<state()>
109
110 $response = $e->cluster->state(
111 metric => $metric | \@metrics # optional
112 index => $index | \@indices # optional
113 );
114
115 The C<state()> method returns the current cluster state from the master node,
116 or from the responding node if C<local> is set to C<true>.
117
118 It returns all metrics by default, but these can be limited to any of:
119 C<_all>,
120 C<blocks>,
121 C<metadata>,
122 C<nodes>,
123 C<routing_table>
124
125 Metrics for indices can be limited to particular indices with the C<index>
126 parameter.
127
128 Query string parameters:
129 C<allow_no_indices>,
130 C<expand_wildcards>,
131 C<flat_settings>,
132 C<ignore_unavailable>,
133 C<local>,
134 C<master_timeout>
135
136 See the L<cluster state docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html>
137 for more information.
138
139 =head2 C<pending_tasks()>
140
141 $response = $e->cluster->pending_tasks();
142
143 Returns a list of cluster-level tasks still pending on the master node.
144
145 Query string parameters:
146 C<local>,
147 C<master_timeout>
148
149 See the L<pending tasks docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html>
150 for more information.
151
152 =head2 C<reroute()>
153
154 $e->cluster->reroute(
155 body => { commands }
156 );
157
158 The C<reroute()> method is used to manually reallocate shards from one
159 node to another. The C<body> should contain the C<commands> indicating
160 which changes should be made. For instance:
161
162 $e->cluster->reroute(
163 body => {
164 commands => [
165 { move => {
166 index => 'test',
167 shard => 0,
168 from_node => 'node_1',
169 to_node => 'node_2
170 }},
171 { allocate => {
172 index => 'test',
173 shard => 1,
174 node => 'node_3'
175 }}
176 ]
177 }
178 );
179
180 Query string parameters:
181 C<dry_run>,
182 C<explain>,
183 C<master_timeout>,
184 C<metric>,
185 C<timeout>
186
187 See the L<reroute docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html>
188 for more information.
189
190 =head1 AUTHOR
191
192 Enrico Zimuel <[email protected]>
193
194 =head1 COPYRIGHT AND LICENSE
195
196 This software is Copyright (c) 2020 by Elasticsearch BV.
197
198 This is free software, licensed under:
199
200 The Apache License, Version 2.0, January 2004
201
202 =cut
203
204 __END__
205
206 # ABSTRACT: A client for running cluster-level requests
207