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
|
|
851
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# DOC: Search::Elasticsearch::Client::6_0::Direct::Cluster |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::Client::Elasticsearch); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
830
|
|
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
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub brik_init { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
$self->open or return 0; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self->SUPER::brik_init; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub show { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return $self->SUPER::show_nodes(); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub list { |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
my $show = $self->show or return; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my @nodes = (); |
62
|
0
|
|
|
|
|
|
for (@$show) { |
63
|
0
|
|
|
|
|
|
chomp; |
64
|
0
|
|
|
|
|
|
my @t = split(/\s+/); |
65
|
0
|
|
|
|
|
|
push @nodes, $t[-1]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return \@nodes; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub health { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my ($indices) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my %args = (); |
76
|
0
|
0
|
|
|
|
|
if (defined($indices)) { |
77
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('health', $indices, 'ARRAY', 'SCALAR') or return; |
78
|
0
|
|
|
|
|
|
$args{index} = $indices; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $self->_es->cluster->health(%args); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub stats { |
85
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
|
my ($nodes) = @_; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my %args = (); |
89
|
0
|
0
|
|
|
|
|
if (defined($nodes)) { |
90
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('stats', $nodes, 'ARRAY', 'SCALAR') or return; |
91
|
0
|
|
|
|
|
|
$args{node_id} = $nodes; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return $self->_es->cluster->stats(%args); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub remote_info { |
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $self->_es->cluster->remote_info; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub pending_tasks { |
104
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
return $self->_es->cluster->pending_tasks; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub get_settings { |
110
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
return $self->_es->cluster->get_settings; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub put_settings { |
116
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
117
|
0
|
|
|
|
|
|
my ($settings) = @_; |
118
|
|
|
|
|
|
|
|
119
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('put_settings', $settings) or return; |
120
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('put', $settings, 'HASH') or return; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $self->_es->cluster->put_settings(body => $settings); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub exclude { |
126
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
127
|
0
|
|
|
|
|
|
my ($node) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('exclude', $node) or return; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $settings = { |
132
|
|
|
|
|
|
|
transient => { |
133
|
|
|
|
|
|
|
'cluster.routing.allocation.exclude._name' => $node, |
134
|
|
|
|
|
|
|
}, |
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
return $self->put_settings($settings); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub include { |
141
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
142
|
0
|
|
|
|
|
|
my ($node) = @_; |
143
|
|
|
|
|
|
|
|
144
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('include', $node) or return; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
my $settings = { |
147
|
|
|
|
|
|
|
transient => { |
148
|
|
|
|
|
|
|
'cluster.routing.allocation.include._name' => $node, |
149
|
|
|
|
|
|
|
}, |
150
|
|
|
|
|
|
|
}; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return $self->put_settings($settings); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
# PUT _cluster/settings |
157
|
|
|
|
|
|
|
# { |
158
|
|
|
|
|
|
|
# "transient": { |
159
|
|
|
|
|
|
|
# "cluster.routing.allocation.*": null |
160
|
|
|
|
|
|
|
# } |
161
|
|
|
|
|
|
|
# } |
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
sub reset_settings_transient_cluster_routing_allocation { |
164
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $settings = { |
167
|
|
|
|
|
|
|
transient => { |
168
|
|
|
|
|
|
|
'cluster.routing.allocation.*' => undef, |
169
|
|
|
|
|
|
|
}, |
170
|
|
|
|
|
|
|
}; |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return $self->put_settings($settings); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
__END__ |