line |
true |
false |
branch |
113
|
0 |
0 |
if (not _check_host($host) && $port =~ /^[0-9]+$/ or $port < 1 or $port > 19888) |
130
|
0 |
0 |
if ($params) |
155
|
0 |
0 |
$server ? : |
173
|
0 |
0 |
unless (@servers) |
174
|
0 |
0 |
@banned_servers ? : |
189
|
0 |
0 |
$method eq 'GET' ? : |
192
|
0 |
0 |
if $self->debug |
201
|
0 |
0 |
if ($response->code == 500) { } |
|
0 |
0 |
elsif ($response->code == 401) { } |
205
|
0 |
0 |
eval {
do {
require LWP::Authen::Negotiate;
1
}
} ? : |
|
0 |
0 |
($response->headers->{'www-authenticate'} || '') eq 'Negotiate' ? : |
221
|
0 |
0 |
unless ($content =~ / \A ( \s+ )? <[?]xml /msx) |
222
|
0 |
0 |
if ($content =~ /
This\ is\ standby\ RM\.\ Redirecting\ to\ the\ current\ active\ RM
/msx) |
248
|
0 |
0 |
unless (eval {
do {
my $content = $response->decoded_content || die('No response from the server!');
unless ($content =~ / \A ( \s+ )? <[?]xml /msx) {
if ($content =~ /
This\ is\ standby\ RM\.\ Redirecting\ to\ the\ current\ active\ RM
/msx) {
push @banned_servers, shift @servers;
++$redo;
die "Hit the standby with $selected_server";
};
die $e_non_html . $content;
};
$res = XMLin($content, 'KeepRoot', 0, 'KeyAttr', [], 'ForceArray', ['app', 'appAttempt', 'container', 'counterGroup', 'job', 'jobAttempt', 'task', 'taskAttempt']) || die('Failed to parse XML!');
1
}
}) |
252
|
0 |
0 |
if ($is_html) |
261
|
0 |
0 |
unless my $txt = trim($token->[0]) |
271
|
0 |
0 |
if $will_fail_again |
275
|
0 |
0 |
$response->redirects ? : |
283
|
0 |
0 |
if $self->debug |
285
|
0 |
0 |
if ($response->is_success) |
300
|
0 |
0 |
unless (eval {
do {
$eval_error = undef;
my $uri = $self->_mk_uri($selected_server, $path, $method eq 'GET' ? $extra->{'params'} : ());
print STDERR "====> $uri\n" if $self->debug;
my $req = 'HTTP::Request'->new(uc $method, $uri);
$req->header('Accept-Encoding', 'gzip');
$req->header('Accept', 'application/xml');
my $response = $self->ua->request($req);
if ($response->code == 500) {
die "Bad request: $uri";
}
elsif ($response->code == 401) {
my $extramsg = ($response->headers->{'www-authenticate'} || '') eq 'Negotiate' ? eval {
do {
require LWP::Authen::Negotiate;
1
}
} ? ' (Did you forget to run kinit?) ' : q[ (LWP::Authen::Negotiate doesn't seem available) ] : '';
croak("SecurityError$extramsg");
};
my $res;
unless (eval {
do {
my $content = $response->decoded_content || die('No response from the server!');
unless ($content =~ / \A ( \s+ )? <[?]xml /msx) {
if ($content =~ /
This\ is\ standby\ RM\.\ Redirecting\ to\ the\ current\ active\ RM
/msx) {
push @banned_servers, shift @servers;
++$redo;
die "Hit the standby with $selected_server";
};
die $e_non_html . $content;
};
$res = XMLin($content, 'KeepRoot', 0, 'KeyAttr', [], 'ForceArray', ['app', 'appAttempt', 'container', 'counterGroup', 'job', 'jobAttempt', 'task', 'taskAttempt']) || die('Failed to parse XML!');
1
}
}) {
my $is_html = $response->content_type eq 'text/html';
my $decode_error = $@ || 'Zombie error';
if ($is_html) {
(my $str_to_parse = $decode_error) =~ s/ \Q$e_non_html\E //msx;
my $parser = 'HTML::PullParser'->new('doc', \$str_to_parse, 'text', 'dtext') || Carp::confess("Can't parse HTML received from the API: $!");
my(%link, @txt_error);
while (my $token = $parser->get_token) {
do {
next unless my $txt = trim($token->[0]);
push @txt_error, $txt
};
};
$decode_error = 'Decoded error: ' . join(' ', @txt_error);
};
my $will_fail_again = $decode_error =~ /
could\ not\ be\ found\,\ please\ try\ the\ history\ server
/msx;
$n = $maxtries if $will_fail_again;
my $msg = $response->redirects ? q[server response wasn't valid (possibly buggy redirect to HTML instead of JSON or XML)] : q[server response wasn't valid JSON or XML];
die "$msg - $uri ($n/$maxtries): $decode_error";
};
print STDERR Dumper($res) if $self->debug;
if ($response->is_success) {
$ret = $res;
return 1;
};
my $e = $res->{'RemoteException'};
die sprintf('%s (%s in %s) for URI: %s', $e->{'message'} || $res->{'message'} || '[unknown message]', $e->{'exception'} || $res->{'exception'} || '[unknown exception]', $e->{'javaClassName'} || $res->{'javaClassName'} || '[unknown javaClassName]', $uri);
1
}
}) |
305
|
0 |
0 |
if $redo |
306
|
0 |
0 |
if @servers > 1 |
309
|
0 |
0 |
if ($ret) |
310
|
0 |
0 |
if ($self->add_host_key) |
319
|
0 |
0 |
if ($eval_error) |