| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Licensed to Elasticsearch B.V. under one or more contributor |
|
2
|
|
|
|
|
|
|
# license agreements. See the NOTICE file distributed with |
|
3
|
|
|
|
|
|
|
# this work for additional information regarding copyright |
|
4
|
|
|
|
|
|
|
# ownership. Elasticsearch B.V. licenses this file to you under |
|
5
|
|
|
|
|
|
|
# the Apache License, Version 2.0 (the "License"); you may |
|
6
|
|
|
|
|
|
|
# not use this file except in compliance with the License. |
|
7
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, |
|
12
|
|
|
|
|
|
|
# software distributed under the License is distributed on an |
|
13
|
|
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
14
|
|
|
|
|
|
|
# KIND, either express or implied. See the License for the |
|
15
|
|
|
|
|
|
|
# specific language governing permissions and limitations |
|
16
|
|
|
|
|
|
|
# under the License. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Search::Elasticsearch::Role::CxnPool::Static::NoPing; |
|
19
|
|
|
|
|
|
|
$Search::Elasticsearch::Role::CxnPool::Static::NoPing::VERSION = '7.717'; |
|
20
|
7
|
|
|
7
|
|
2946
|
use Moo::Role; |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
37
|
|
|
21
|
|
|
|
|
|
|
with 'Search::Elasticsearch::Role::CxnPool'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
7
|
|
|
7
|
|
1951
|
use namespace::clean; |
|
|
7
|
|
|
|
|
24
|
|
|
|
7
|
|
|
|
|
42
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'max_retries' => ( is => 'lazy' ); |
|
26
|
|
|
|
|
|
|
has '_dead_cxns' => ( is => 'ro', default => sub { [] } ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#=================================== |
|
29
|
|
|
|
|
|
|
sub next_cxn { |
|
30
|
|
|
|
|
|
|
#=================================== |
|
31
|
58
|
|
|
58
|
0
|
83
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
58
|
|
|
|
|
132
|
my $cxns = $self->cxns; |
|
34
|
58
|
|
|
|
|
78
|
my $total = @$cxns; |
|
35
|
58
|
|
|
|
|
107
|
my $dead = $self->_dead_cxns; |
|
36
|
|
|
|
|
|
|
|
|
37
|
58
|
|
|
|
|
132
|
while ( $total-- ) { |
|
38
|
69
|
|
|
|
|
158
|
my $cxn = $cxns->[ $self->next_cxn_num ]; |
|
39
|
69
|
100
|
100
|
|
|
181
|
return $cxn |
|
40
|
|
|
|
|
|
|
if $cxn->is_live |
|
41
|
|
|
|
|
|
|
|| $cxn->next_ping < time(); |
|
42
|
13
|
100
|
|
|
|
44
|
push @$dead, $cxn unless grep { $_ eq $cxn } @$dead; |
|
|
10
|
|
|
|
|
33
|
|
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
50
|
33
|
|
|
42
|
if ( @$dead and $self->retries <= $self->max_retries ) { |
|
46
|
2
|
|
|
|
|
22
|
$_->force_ping for @$dead; |
|
47
|
2
|
|
|
|
|
6
|
return shift @$dead; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
0
|
|
|
|
|
0
|
throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#=================================== |
|
53
|
4
|
|
|
4
|
|
34
|
sub _build_max_retries { @{ shift->cxns } - 1 } |
|
|
4
|
|
|
|
|
29
|
|
|
54
|
11
|
|
|
11
|
|
144
|
sub _max_retries { shift->max_retries + 1 } |
|
55
|
|
|
|
|
|
|
#=================================== |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#=================================== |
|
58
|
|
|
|
|
|
|
sub BUILD { |
|
59
|
|
|
|
|
|
|
#=================================== |
|
60
|
7
|
|
|
7
|
0
|
50
|
my $self = shift; |
|
61
|
7
|
|
|
|
|
12
|
$self->set_cxns( @{ $self->seed_nodes } ); |
|
|
7
|
|
|
|
|
31
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#=================================== |
|
65
|
|
|
|
|
|
|
sub should_mark_dead { |
|
66
|
|
|
|
|
|
|
#=================================== |
|
67
|
12
|
|
|
12
|
0
|
23
|
my ( $self, $error ) = @_; |
|
68
|
12
|
|
|
|
|
30
|
return $error->is( 'Cxn', 'Timeout' ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#=================================== |
|
72
|
|
|
|
|
|
|
after 'reset_retries' => sub { |
|
73
|
|
|
|
|
|
|
#=================================== |
|
74
|
|
|
|
|
|
|
my $self = shift; |
|
75
|
|
|
|
|
|
|
@{ $self->_dead_cxns } = (); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
}; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#=================================== |
|
80
|
|
|
|
12
|
0
|
|
sub schedule_check { } |
|
81
|
|
|
|
|
|
|
#=================================== |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# ABSTRACT: A CxnPool for connecting to a remote cluster without the ability to ping. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |