| 1 | # Licensed to Elasticsearch B.V under one or more agreements. | ||||||||||||||||||||||||||||
| 2 | # Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||||||||||||||||||||||||||||
| 3 | # See the LICENSE file in the project root for more information | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Search::Elasticsearch::Role::CxnPool::Static::NoPing; | ||||||||||||||||||||||||||||
| 6 | 7 | $Search::Elasticsearch::Role::CxnPool::Static::NoPing::VERSION = '7.30_1'; # TRIAL | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | $Search::Elasticsearch::Role::CxnPool::Static::NoPing::VERSION = '7.301'; | |||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 7 | with 'Search::Elasticsearch::Role::CxnPool'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 7 | has 'max_retries' => ( is => 'lazy' ); | |||||||||||||||||||||||||||
| 15 | 7 | ▶ | has '_dead_cxns' => ( is => 'ro', default => sub { [] } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | #=================================== | ||||||||||||||||||||||||||||
| 18 | sub next_cxn { | ||||||||||||||||||||||||||||
| 19 | #=================================== | ||||||||||||||||||||||||||||
| 20 | 58 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
next_cxn: called CC=8 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 58 | my $cxns = $self->cxns; | |||||||||||||||||||||||||||
| 23 | 58 | my $total = @$cxns; | |||||||||||||||||||||||||||
| 24 | 58 | my $dead = $self->_dead_cxns; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 58 | ▶ | while ( $total-- ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 69 | my $cxn = $cxns->[ $self->next_cxn_num ]; | |||||||||||||||||||||||||||
| 28 | 69 | ▶ | return $cxn | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cxn->is_live or $cxn->next_ping < time
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
| |||||||||||||||||||||||||||||
| 29 | if $cxn->is_live | ||||||||||||||||||||||||||||
| 30 | || $cxn->next_ping < time(); | ||||||||||||||||||||||||||||
| 31 | 13 | ▶ | push @$dead, $cxn unless grep { $_ eq $cxn } @$dead; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | ▶ | if ( @$dead and $self->retries <= $self->max_retries ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$dead and $self->retries <= $self->max_retries
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
| |||||||||||||||||||||||||||||
| 35 | 2 | $_->force_ping for @$dead; | |||||||||||||||||||||||||||
| 36 | 2 | return shift @$dead; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' ); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | #=================================== | ||||||||||||||||||||||||||||
| 42 | 4 | ▶ | sub _build_max_retries { @{ shift->cxns } - 1 } | ||||||||||||||||||||||||||
|
Subroutine
_build_max_retries: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 11 | ▶ | sub _max_retries { shift->max_retries + 1 } | ||||||||||||||||||||||||||
|
Subroutine
_max_retries: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | #=================================== | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | #=================================== | ||||||||||||||||||||||||||||
| 47 | sub BUILD { | ||||||||||||||||||||||||||||
| 48 | #=================================== | ||||||||||||||||||||||||||||
| 49 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 7 | $self->set_cxns( @{ $self->seed_nodes } ); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | #=================================== | ||||||||||||||||||||||||||||
| 54 | sub should_mark_dead { | ||||||||||||||||||||||||||||
| 55 | #=================================== | ||||||||||||||||||||||||||||
| 56 | 12 | ▶ | my ( $self, $error ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
should_mark_dead: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 12 | return $error->is( 'Cxn', 'Timeout' ); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | #=================================== | ||||||||||||||||||||||||||||
| 61 | after 'reset_retries' => sub { | ||||||||||||||||||||||||||||
| 62 | #=================================== | ||||||||||||||||||||||||||||
| 63 | 49 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 49 | @{ $self->_dead_cxns } = (); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 7 | }; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | #=================================== | ||||||||||||||||||||||||||||
| 69 | ▶ | sub schedule_check { } | |||||||||||||||||||||||||||
|
Subroutine
schedule_check: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | #=================================== | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 7 | 1; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # ABSTRACT: A CxnPool for connecting to a remote cluster without the ability to ping. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||