Elasticsearch/Role/CxnPool/Static/NoPing.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 85.5% 59 / 69 CC 8 SCAR 14.8
CC
8
Cov
92%
next_cxn
8.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« Elasticsearch/CxnPool/Sniff.pm ↑ Summary Elasticsearch/Util.pm »
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 7 $Search::Elasticsearch::Role::CxnPool::Static::NoPing::VERSION = '8.12';
20 7 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 7 with 'Search::Elasticsearch::Role::CxnPool';
22  
23 7 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 7 has 'max_retries' => ( is => 'lazy' );
26 7 ▶has '_dead_cxns' => ( is => 'ro', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
27  
28 #===================================
29 58 ▶sub next_cxn {
Subroutine next_cxn: called CC=8 SCAR=21.1
Pod undocumented
30 #===================================
31 58 my $self = shift;
32  
33 58 my $cxns = $self->cxns;
34 58 my $total = @$cxns;
35 58 my $dead = $self->_dead_cxns;
36  
37 58 ▶ while ( $total-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total--) 69 2 71
38 69 my $cxn = $cxns->[ $self->next_cxn_num ];
39 69 ▶ return $cxn
Branch: 1 branch
BranchTrueFalseTotal
if $cxn->is_live or $cxn->next_ping < time 56 13 69
Condition100%3/3
$cxn->is_live or $cxn->next_ping < time
l!l&&r!l&&!r
48813
MC/DC100%2/2
$cxn->is_live or $cxn->next_ping < time
$cxn->is_live $cxn->next_ping < time
Truth table100%3/3
A or B
A= $cxn->is_liveB= $cxn->next_ping < time
ABresult
1X1
011
000
40 if $cxn->is_live
41 || $cxn->next_ping < time();
42 13 ▶ push @$dead, $cxn unless grep { $_ eq $cxn } @$dead;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $cxn;} @$dead 12 1 13
43 }
44  
45 2 ▶ if ( @$dead and $self->retries <= $self->max_retries ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$dead and $self->retries <= $self->max_retries) 2 0 2
Condition33%1/3
@$dead and $self->retries <= $self->max_retries
!ll&&!rl&&r
002
MC/DC0%0/2
@$dead and $self->retries <= $self->max_retries
@$dead $self->retries <= $self->max_retries
Truth table33%1/3
A and B
A= @$deadB= $self->retries <= $self->max_retries
ABresult
0X0
100
111
46 2 $_->force_ping for @$dead;
47 2 return shift @$dead;
48 }
49 0 throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' );
50 }
51  
52 #===================================
53 4 ▶sub _build_max_retries { @{ shift->cxns } - 1 }
Subroutine _build_max_retries: called CC=1 SCAR=0.0
54 11 ▶sub _max_retries { shift->max_retries + 1 }
Subroutine _max_retries: called CC=1 SCAR=0.0
55 #===================================
56  
57 #===================================
58 7 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
59 #===================================
60 7 my $self = shift;
61 7 $self->set_cxns( @{ $self->seed_nodes } );
62 }
63  
64 #===================================
65 12 ▶sub should_mark_dead {
Subroutine should_mark_dead: called CC=1 SCAR=0.0
Pod undocumented
66 #===================================
67 12 my ( $self, $error ) = @_;
68 12 return $error->is( 'Cxn', 'Timeout' );
69 }
70  
71 #===================================
72 49 ▶after 'reset_retries' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
73 #===================================
74 49 my $self = shift;
75 49 @{ $self->_dead_cxns } = ();
76  
77 7 };
78  
79 #===================================
80 12 ▶sub schedule_check { }
Subroutine schedule_check: called CC=1 SCAR=0.0
Pod undocumented
81 #===================================
82  
83 7 1;
84  
85 # ABSTRACT: A CxnPool for connecting to a remote cluster without the ability to ping.
86  
87 __END__
« Elasticsearch/CxnPool/Sniff.pm ↑ Summary Elasticsearch/Util.pm »