| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Elasticsearch::CxnPool::Static::NoPing; |
|
2
|
|
|
|
|
|
|
$Elasticsearch::CxnPool::Static::NoPing::VERSION = '1.05'; |
|
3
|
7
|
|
|
7
|
|
5527
|
use Moo; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
51
|
|
|
4
|
|
|
|
|
|
|
with 'Elasticsearch::Role::CxnPool::Static::NoPing', |
|
5
|
|
|
|
|
|
|
'Elasticsearch::Role::Is_Sync'; |
|
6
|
7
|
|
|
7
|
|
2627
|
use Elasticsearch::Util qw(throw); |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
68
|
|
|
7
|
7
|
|
|
7
|
|
2220
|
use namespace::clean; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
58
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#=================================== |
|
10
|
|
|
|
|
|
|
sub next_cxn { |
|
11
|
|
|
|
|
|
|
#=================================== |
|
12
|
58
|
|
|
58
|
1
|
85
|
my $self = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
58
|
|
|
|
|
134
|
my $cxns = $self->cxns; |
|
15
|
58
|
|
|
|
|
96
|
my $total = @$cxns; |
|
16
|
58
|
|
|
|
|
114
|
my $dead = $self->_dead_cxns; |
|
17
|
|
|
|
|
|
|
|
|
18
|
58
|
|
|
|
|
156
|
while ( $total-- ) { |
|
19
|
69
|
|
|
|
|
234
|
my $cxn = $cxns->[ $self->next_cxn_num ]; |
|
20
|
69
|
100
|
100
|
|
|
251
|
return $cxn |
|
21
|
|
|
|
|
|
|
if $cxn->is_live |
|
22
|
|
|
|
|
|
|
|| $cxn->next_ping < time(); |
|
23
|
13
|
100
|
|
|
|
58
|
push @$dead, $cxn unless grep { $_ eq $cxn } @$dead; |
|
|
10
|
|
|
|
|
68
|
|
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
50
|
33
|
|
|
23
|
if ( @$dead and $self->retries <= $self->max_retries ) { |
|
27
|
2
|
|
|
|
|
90
|
$_->force_ping for @$dead; |
|
28
|
2
|
|
|
|
|
9
|
return shift @$dead; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
0
|
|
|
|
|
|
throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' ); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=encoding UTF-8 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Elasticsearch::CxnPool::Static::NoPing - A CxnPool for connecting to a remote cluster without the ability to ping. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
version 1.05 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$e = Elasticsearch->new( |
|
50
|
|
|
|
|
|
|
cxn_pool => 'Static::NoPing' |
|
51
|
|
|
|
|
|
|
nodes => [ |
|
52
|
|
|
|
|
|
|
'search1:9200', |
|
53
|
|
|
|
|
|
|
'search2:9200' |
|
54
|
|
|
|
|
|
|
], |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The L<Static::NoPing|Elasticsearch::CxnPool::Static::NoPing> connection |
|
60
|
|
|
|
|
|
|
pool (like the L<Static|Elasticsearch::CxnPool::Static> pool) should be used |
|
61
|
|
|
|
|
|
|
when your access to the cluster is limited. However, the C<Static> pool needs |
|
62
|
|
|
|
|
|
|
to be able to ping nodes in the cluster, with a C<HEAD /> request. If you |
|
63
|
|
|
|
|
|
|
can't ping your nodes, then you should use the C<Static::NoPing> |
|
64
|
|
|
|
|
|
|
connection pool instead. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Because the cluster cannot be pinged, this CxnPool cannot use a short |
|
67
|
|
|
|
|
|
|
ping request to determine whether nodes are live or not - it just has to |
|
68
|
|
|
|
|
|
|
send requests to the nodes to determine whether they are alive or not. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Most of the time, a dead node will cause the request to fail quickly. |
|
71
|
|
|
|
|
|
|
However, in situations where node failure takes time (eg malfunctioning |
|
72
|
|
|
|
|
|
|
routers or firewalls), a failure may not be reported until the request |
|
73
|
|
|
|
|
|
|
itself times out (see L<Elasticsearch::Cxn/request_timeout>). |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Failed nodes will be retried regularly to check if they have recovered. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This class does L<Elasticsearch::Role::CxnPool::Static::NoPing> and |
|
78
|
|
|
|
|
|
|
L<Elasticsearch::Role::Is_Sync>. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 C<nodes> |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The list of nodes to use to serve requests. Can accept a single node, |
|
85
|
|
|
|
|
|
|
multiple nodes, and defaults to C<localhost:9200> if no C<nodes> are |
|
86
|
|
|
|
|
|
|
specified. See L<Elasticsearch::Role::Cxn::HTTP/node> for details of the node |
|
87
|
|
|
|
|
|
|
specification. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 See also |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<Elasticsearch::Role::Cxn/request_timeout> |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<Elasticsearch::Role::Cxn/dead_timeout> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<Elasticsearch::Role::Cxn/max_dead_timeout> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 Inherited configuration |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
From L<Elasticsearch::Role::CxnPool::Static::NoPing> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * L<max_retries|Elasticsearch::Role::CxnPool::Static::NoPing/"max_retries"> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
From L<Elasticsearch::Role::CxnPool> |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * L<randomize_cxns|Elasticsearch::Role::CxnPool/"randomize_cxns"> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 METHODS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 C<next_cxn()> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
$cxn = $cxn_pool->next_cxn |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns the next available node in round robin fashion - either a live node |
|
132
|
|
|
|
|
|
|
which has previously responded successfully, or a previously failed |
|
133
|
|
|
|
|
|
|
node which should be retried. If all nodes are dead, it will throw |
|
134
|
|
|
|
|
|
|
a C<NoNodes> error. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 Inherited methods |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
From L<Elasticsearch::Role::CxnPool::Static::NoPing> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * L<should_mark_dead()|Elasticsearch::Role::CxnPool::Static::NoPing/"should_mark_dead()"> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * L<schedule_check()|Elasticsearch::Role::CxnPool::Static::NoPing/"schedule_check()"> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
From L<Elasticsearch::Role::CxnPool> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * L<cxn_factory()|Elasticsearch::Role::CxnPool/"cxn_factory()"> |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * L<logger()|Elasticsearch::Role::CxnPool/"logger()"> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * L<serializer()|Elasticsearch::Role::CxnPool/"serializer()"> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * L<current_cxn_num()|Elasticsearch::Role::CxnPool/"current_cxn_num()"> |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * L<cxns()|Elasticsearch::Role::CxnPool/"cxns()"> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * L<seed_nodes()|Elasticsearch::Role::CxnPool/"seed_nodes()"> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * L<next_cxn_num()|Elasticsearch::Role::CxnPool/"next_cxn_num()"> |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * L<set_cxns()|Elasticsearch::Role::CxnPool/"set_cxns()"> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * L<request_ok()|Elasticsearch::Role::CxnPool/"request_ok()"> |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * L<request_failed()|Elasticsearch::Role::CxnPool/"request_failed()"> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * L<should_retry()|Elasticsearch::Role::CxnPool/"should_retry()"> |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * L<should_mark_dead()|Elasticsearch::Role::CxnPool/"should_mark_dead()"> |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * L<cxns_str()|Elasticsearch::Role::CxnPool/"cxns_str()"> |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * L<cxns_seeds_str()|Elasticsearch::Role::CxnPool/"cxns_seeds_str()"> |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * L<retries()|Elasticsearch::Role::CxnPool/"retries()"> |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * L<reset_retries()|Elasticsearch::Role::CxnPool/"reset_retries()"> |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Clinton Gormley <drtech@cpan.org> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Elasticsearch BV. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This is free software, licensed under: |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
__END__ |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# ABSTRACT: A CxnPool for connecting to a remote cluster without the ability to ping. |
|
201
|
|
|
|
|
|
|
|