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