line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# client::elasticsearch::cluster Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Client::Elasticsearch::Cluster; |
7
|
1
|
|
|
1
|
|
1234
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# DOC: Search::Elasticsearch::Client::7_0::Direct::Cluster |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik::Client::Elasticsearch); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1020
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub brik_properties { |
17
|
|
|
|
|
|
|
return { |
18
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
19
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
20
|
|
|
|
|
|
|
author => 'GomoR ', |
21
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
22
|
|
|
|
|
|
|
attributes => { |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
attributes_default => { |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
commands => { |
27
|
|
|
|
|
|
|
show => [ ], |
28
|
|
|
|
|
|
|
list => [ ], |
29
|
|
|
|
|
|
|
health => [ qw(indices|OPTIONAL) ], |
30
|
|
|
|
|
|
|
stats => [ qw(nodes|OPTIONAL) ], |
31
|
|
|
|
|
|
|
remote_info => [ ], |
32
|
|
|
|
|
|
|
pending_tasks => [ ], |
33
|
|
|
|
|
|
|
get_settings => [ ], |
34
|
|
|
|
|
|
|
put_settings => [ qw(settings) ], |
35
|
|
|
|
|
|
|
exclude => [ qw(node) ], |
36
|
|
|
|
|
|
|
include => [ qw(node) ], |
37
|
|
|
|
|
|
|
reset_settings_transient_cluster_routing_allocation => [ ], |
38
|
|
|
|
|
|
|
allocation_explain => [ ], |
39
|
|
|
|
|
|
|
reroute => [ qw(args|OPTIONAL) ], |
40
|
|
|
|
|
|
|
reroute_retry_failed => [ ], |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub brik_init { |
46
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
$self->open or return 0; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->SUPER::brik_init; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub show { |
54
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->SUPER::show_nodes(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub list { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
my $show = $self->show or return; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my @nodes = (); |
65
|
0
|
|
|
|
|
|
for (@$show) { |
66
|
0
|
|
|
|
|
|
chomp; |
67
|
0
|
|
|
|
|
|
my @t = split(/\s+/); |
68
|
0
|
|
|
|
|
|
push @nodes, $t[-1]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return \@nodes; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub health { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my ($indices) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my %args = (); |
79
|
0
|
0
|
|
|
|
|
if (defined($indices)) { |
80
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('health', $indices, 'ARRAY', 'SCALAR') or return; |
81
|
0
|
|
|
|
|
|
$args{index} = $indices; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return $self->_es->cluster->health(%args); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub stats { |
88
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
89
|
0
|
|
|
|
|
|
my ($nodes) = @_; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my %args = (); |
92
|
0
|
0
|
|
|
|
|
if (defined($nodes)) { |
93
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('stats', $nodes, 'ARRAY', 'SCALAR') or return; |
94
|
0
|
|
|
|
|
|
$args{node_id} = $nodes; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $self->_es->cluster->stats(%args); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub remote_info { |
101
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $self->_es->cluster->remote_info; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub pending_tasks { |
107
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $self->_es->cluster->pending_tasks; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub get_settings { |
113
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return $self->_es->cluster->get_settings; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub put_settings { |
119
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
120
|
0
|
|
|
|
|
|
my ($settings) = @_; |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('put_settings', $settings) or return; |
123
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('put', $settings, 'HASH') or return; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return $self->_es->cluster->put_settings(body => $settings); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub exclude { |
129
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
130
|
0
|
|
|
|
|
|
my ($node) = @_; |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('exclude', $node) or return; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $settings = { |
135
|
|
|
|
|
|
|
transient => { |
136
|
|
|
|
|
|
|
'cluster.routing.allocation.exclude._name' => $node, |
137
|
|
|
|
|
|
|
}, |
138
|
|
|
|
|
|
|
}; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return $self->put_settings($settings); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub include { |
144
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
145
|
0
|
|
|
|
|
|
my ($node) = @_; |
146
|
|
|
|
|
|
|
|
147
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('include', $node) or return; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
my $settings = { |
150
|
|
|
|
|
|
|
transient => { |
151
|
|
|
|
|
|
|
'cluster.routing.allocation.include._name' => $node, |
152
|
|
|
|
|
|
|
}, |
153
|
|
|
|
|
|
|
}; |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
return $self->put_settings($settings); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
# PUT _cluster/settings |
160
|
|
|
|
|
|
|
# { |
161
|
|
|
|
|
|
|
# "transient": { |
162
|
|
|
|
|
|
|
# "cluster.routing.allocation.*": null |
163
|
|
|
|
|
|
|
# } |
164
|
|
|
|
|
|
|
# } |
165
|
|
|
|
|
|
|
# |
166
|
|
|
|
|
|
|
sub reset_settings_transient_cluster_routing_allocation { |
167
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $settings = { |
170
|
|
|
|
|
|
|
transient => { |
171
|
|
|
|
|
|
|
'cluster.routing.allocation.*' => undef, |
172
|
|
|
|
|
|
|
}, |
173
|
|
|
|
|
|
|
}; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
return $self->put_settings($settings); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub allocation_explain { |
179
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
return $self->_es->cluster->allocation_explain(); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub reroute { |
185
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
186
|
0
|
|
|
|
|
|
my ($args) = @_; |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
0
|
|
|
|
$args ||= {}; |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
return $self->_es->cluster->reroute(%$args); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub reroute_retry_failed { |
194
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my %args = ( |
197
|
|
|
|
|
|
|
retry_failed => 'true', |
198
|
|
|
|
|
|
|
); |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
return $self->reroute(\%args); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
__END__ |