| 1 | package Net::Hadoop::YARN::Roles::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 12 | $Net::Hadoop::YARN::Roles::Common::VERSION = '0.203'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 12 | ▶ | use HTML::PullParser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 12 | ▶ | use Regexp::Common qw( net ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | ▶ | use Text::Trim qw( trim ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | ▶ | use XML::LibXML::Simple; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | has no_http_redirect => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 12 | lazy => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | has _json => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | return JSON::XS->new->pretty(1)->canonical(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $json = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ( ! blessed $json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
builtin::blessed($json) && $json->isa('JSON::XS') && $json->can('decode')
builtin::blessed($json) and $json->isa("JSON::XS")
MC/DC0%0/3
builtin::blessed($json) && $json->isa('JSON::XS') && $json->can('decode')
builtin::blessed($json)
$json->isa("JSON::XS")
$json->can('decode')
Truth table0%0/4
A and B && C
A= builtin::blessed($json)B= $json->isa("JSON::XS")C= $json->can('decode')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | || ! $json->isa('JSON::XS') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | || ! $json->can('decode') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | die "Not a JSON object" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | has debug => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | default => sub { $ENV{NET_HADOOP_YARN_DEBUG} || 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | isa => sub { die 'debug should be an integer' if $_[0] !~ /^[0-9]$/ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 12 | lazy => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | has ua => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | return LWP::UserAgent->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | env_proxy => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | timeout => $_[0]->timeout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ( $_[0]->no_http_redirect ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | max_redirect => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ):()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $ua = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ( ! blessed( $ua ) || ! $ua->isa("LWP::UserAgent") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($ua) && $ua->isa('LWP::UserAgent')
MC/DC0%0/2
builtin::blessed($ua) && $ua->isa('LWP::UserAgent')
builtin::blessed($ua)
$ua->isa('LWP::UserAgent')
Truth table0%0/3
A && B
A= builtin::blessed($ua)B= $ua->isa('LWP::UserAgent')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | die "'ua' isn't a LWP::UserAgent"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | lazy => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | has timeout => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | default => sub {30}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ( $_[0] !~ /^[0-9]+$/ || $_[0] <= 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $_[0] =~ /^[0-9]+$/ or $_[0] <= 0
MC/DC0%0/2
not $_[0] =~ /^[0-9]+$/ or $_[0] <= 0
not $_[0] =~ /^[0-9]+$/
$_[0] <= 0
Truth table0%0/3
not(A) or B
A= not $_[0] =~ /^[0-9]+$/B= $_[0] <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | die "timeout must be an integer" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | has servers => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | die "Incorrect server list" if ! _check_servers(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | lazy => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | has add_host_key => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 12 | lazy => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | has host_key => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | default => sub { '__RESTHost' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 12 | lazy => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub _check_host { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_host: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $host = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return !!( eval { inet_aton($host) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | || $host =~ $RE{net}{IPv4} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | || $host =~ $RE{net}{IPv6} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
eval {
do {
inet_aton($host)
}
} || $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{'net'}{'IPv4'}/ || $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{'net'}{'IPv6'}/
eval {
do {
inet_aton($host)
}
} or $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{"net"}{"IPv4"}/
MC/DC0%0/3
eval {
do {
inet_aton($host)
}
} || $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{'net'}{'IPv4'}/ || $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{'net'}{'IPv6'}/
eval {
do {
inet_aton($host)
}
}
$host =~ /$Net::Hadoop::YARN::Roles::Common::RE{"net"}{"IPv4"}/
$host =~ /$Net::Hadoop::YARN::Roles::Common::RE{'net'}{'IPv6'}/
Truth table0%0/4
A or B || C
A= eval {
do {
inet_aton($host)
}
}B= $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{"net"}{"IPv4"}/C= $host =~ /$Net::Hadoop::YARN::Roles::Common::RE{'net'}{'IPv6'}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub _check_servers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_servers: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | for my $server (@{+shift}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my ($host, $port) = split /:/, $server, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( ! _check_host($host) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not _check_host($host) && $port =~ /^[0-9]+$/ or $port < 1 or $port > 19888
not _check_host($host) && $port =~ /^[0-9]+$/ or $port < 1
_check_host($host) && $port =~ /^[0-9]+$/
MC/DC0%0/4
not _check_host($host) && $port =~ /^[0-9]+$/ or $port < 1 or $port > 19888
_check_host($host)
$port =~ /^[0-9]+$/
$port < 1
$port > 19888
Truth table0%0/5
not(A && B) or C or D
A= _check_host($host)B= $port =~ /^[0-9]+$/C= $port < 1D= $port > 19888
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | || $port !~ /^[0-9]+$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | || $port < 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | || $port > 19888 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | die "server $server bad host (port=$port)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub _mk_uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_uri: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my ( $server, $path, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $uri = $server . "/ws/v1/" . $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $uri =~ s#//+#/#g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $uri = URI->new("http://" . $uri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( $params ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $uri->query_form($params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # http://hadoop.apache.org/docs/r2.2.0/hadoop-yarn/hadoop-yarn-site/WebServicesIntro.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub _get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | shift->_request( 'GET', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub _put { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_put: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | shift->_request( 'PUT', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub _post { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_post: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | shift->_request( 'POST', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub _request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_request: not called CC=39 SCAR=73.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my ( $method, $path, $extra, $server ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $host_key = $self->host_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my @servers = $server ? ( $server ) : @{ $self->servers }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $maxtries = @servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($eval_error, $ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # get a copy, don't mess with the global setting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my @banned_servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | my $selected_server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $e_non_html = "Response doesn't look like XML: "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | TRY: while ( $n < $maxtries ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ( ! @servers ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $eval_error = sprintf "No servers left in the queue. Banned servers: '%s'", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | @banned_servers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ? join( q{', '}, @banned_servers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | : '[none]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | last TRY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $selected_server = $servers[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $eval_error = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | my $uri = $self->_mk_uri( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $selected_server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $method eq 'GET' ? $extra->{params} : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | print STDERR "====> $uri\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $req = HTTP::Request->new( uc($method), $uri ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $req->header( "Accept-Encoding", "gzip" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | #$req->header( "Accept", "application/json" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $req->header( "Accept", "application/xml" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $response = $self->ua->request($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $response->code == 500 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | die "Bad request: $uri"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } elsif ( $response->code == 401 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | my $extramsg = ( $response->headers->{'www-authenticate'} || '' ) eq 'Negotiate' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | ? eval { require LWP::Authen::Negotiate; 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$response->headers->{'www-authenticate'} || ''
MC/DC0%0/1
$response->headers->{'www-authenticate'} || ''
$response->headers->{'www-authenticate'}
Truth table0%0/2
A
A= $response->headers->{'www-authenticate'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ? q{ (Did you forget to run kinit?) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | : q{ (LWP::Authen::Negotiate doesn't seem available) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | croak "SecurityError$extramsg"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # found out the json support is buggy at least in the scheduler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # info (overwrites child queues instead of making a list), revert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # to XML (see YARN-2336) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $content = $response->decoded_content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$response->decoded_content || die('No response from the server!')
MC/DC0%0/1
$response->decoded_content || die('No response from the server!')
$response->decoded_content
Truth table0%0/2
A
A= $response->decoded_content
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | || die 'No response from the server!'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( $content !~ m{ \A ( \s+ )? <[?]xml }xms ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( $content =~ m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | \QThis is standby RM. Redirecting to the current active RM\E | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | }xms ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | push @banned_servers, shift @servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $redo++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | die "Hit the standby with $selected_server"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | die $e_non_html . $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $res = XMLin( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
XMLin($content, 'KeepRoot', 0, 'KeyAttr', scalar [], 'ForceArray', ['app', 'appAttempt', 'container', 'counterGroup', 'job', 'jobAttempt', 'task', 'taskAttempt']) || die('Failed to parse XML!')
MC/DC0%0/1
XMLin($content, 'KeepRoot', 0, 'KeyAttr', scalar [], 'ForceArray', ['app', 'appAttempt', 'container', 'counterGroup', 'job', 'jobAttempt', 'task', 'taskAttempt']) || die('Failed to parse XML!')
XMLin($content, 'KeepRoot', 0, 'KeyAttr', scalar [], 'ForceArray', ['app', 'appAttempt', 'container', 'counterGroup', 'job', 'jobAttempt', 'task', 'taskAttempt'])
Truth table0%0/2
A
A= XMLin($content, 'KeepRoot', 0, 'KeyAttr', scalar [], 'ForceArray', ['app', 'appAttempt', 'container', 'counterGroup', 'job', 'jobAttempt', 'task', 'taskAttempt'])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | KeepRoot => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | KeyAttr => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ForceArray => [qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | appAttempt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | container | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | counterGroup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | job | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | jobAttempt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | task | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | taskAttempt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ) || die "Failed to parse XML!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $is_html = $response->content_type eq 'text/html'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $decode_error = $@ || 'Zombie error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'Zombie error'
MC/DC0%0/1
$@ || 'Zombie error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ( $is_html ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | (my $str_to_parse = $decode_error) =~ s{ \Q$e_non_html\E }{}xms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my $parser = HTML::PullParser->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'HTML::PullParser'->new('doc', \$str_to_parse, 'text', 'dtext') || Carp::confess("Can't parse HTML received from the API: $!")
MC/DC0%0/1
'HTML::PullParser'->new('doc', \$str_to_parse, 'text', 'dtext') || Carp::confess("Can't parse HTML received from the API: $!")
'HTML::PullParser'->new('doc', \$str_to_parse, 'text', 'dtext')
Truth table0%0/2
A
A= 'HTML::PullParser'->new('doc', \$str_to_parse, 'text', 'dtext')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | doc => \$str_to_parse, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | text => 'dtext', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ) || Carp::confess "Can't parse HTML received from the API: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my %link; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | my @txt_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | while ( my $token = $parser->get_token ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my $txt = trim $token->[0] or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | push @txt_error, $txt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $decode_error = 'Decoded error: ' . join q{ }, @txt_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $will_fail_again = $decode_error =~ m{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | \Qcould not be found, please try the history server\E | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | }xms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $n = $maxtries if $will_fail_again; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # when redirected to the history server, a bug present in hadoop 2.5.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # sends to an HTML page, ignoring the Accept-Type header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | my $msg = $response->redirects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ? q{server response wasn't valid (possibly buggy redirect to HTML instead of JSON or XML)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | : q{server response wasn't valid JSON or XML} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | die "$msg - $uri ($n/$maxtries): $decode_error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | print STDERR Dumper $res if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ( $response->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $ret = $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $e = $res->{RemoteException}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | die sprintf "%s (%s in %s) for URI: %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | $e->{message} || $res->{message} || '[unknown message]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | $e->{exception} || $res->{exception} || '[unknown exception]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $e->{javaClassName} || $res->{javaClassName} || '[unknown javaClassName]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/15
$e->{'message'} || $res->{'message'} || '[unknown message]'
$e->{"message"} or $res->{"message"}
$e->{'exception'} || $res->{'exception'} || '[unknown exception]'
$e->{"exception"} or $res->{"exception"}
$e->{'javaClassName'} || $res->{'javaClassName'} || '[unknown javaClassName]'
$e->{"javaClassName"} or $res->{"javaClassName"}
MC/DC0%0/2
$e->{'message'} || $res->{'message'} || '[unknown message]'
$e->{"message"}
$res->{"message"}
MC/DC0%0/2
$e->{'exception'} || $res->{'exception'} || '[unknown exception]'
$e->{"exception"}
$res->{"exception"}
MC/DC0%0/2
$e->{'javaClassName'} || $res->{'javaClassName'} || '[unknown javaClassName]'
$e->{"javaClassName"}
$res->{"javaClassName"}
Truth table0%0/3
A or B
A= $e->{"message"}B= $res->{"message"}
Truth table0%0/3
A or B
A= $e->{"exception"}B= $res->{"exception"}
Truth table0%0/3
A or B
A= $e->{"javaClassName"}B= $res->{"javaClassName"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | $uri, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # store the error for later; will be displayed if this is the last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # iteration. also use the next server in the list in case of retry, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # or reset the list for the next call (we went a full circle) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | $eval_error = $@ || 'Zombie error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'Zombie error'
MC/DC0%0/1
$@ || 'Zombie error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | redo TRY if $redo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | push @servers, shift @servers if @servers > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ( $ret ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | if ( $self->add_host_key ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # mark where we've been | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $ret->{ $host_key } = $selected_server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | last TRY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } # retry as many times as there are servers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ( $eval_error ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | die "Final error ($n/$maxtries): $eval_error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||