| 1 | package Net::Hadoop::YARN::NameNode::JMX; | ||||||||||||||||||||||||||||
| 2 | 1 | $Net::Hadoop::YARN::NameNode::JMX::VERSION = '0.203'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Ref::Util qw( is_arrayref ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | my $RE_TIMEOUT = qr{ \Q500 read timeout\E }xms; | |||||||||||||||||||||||||||
| 11 | 1 | my $RE_DEAD = qr{ \Q500 Can't connect to\E .+? \QConnection refused\E }xms; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | has namenodes => ( | ||||||||||||||||||||||||||||
| 14 | is => 'rw', | ||||||||||||||||||||||||||||
| 15 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 16 | 0 | die "namenodes not specified"; | |||||||||||||||||||||||||||
| 17 | }, | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ( ! is_arrayref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | die "namenodes needs to be an ARRAY"; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ( ! @{ $_[0] } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | die "namenodes needs at least one element"; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | }, | ||||||||||||||||||||||||||||
| 26 | 1 | ); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub active_namenode { | ||||||||||||||||||||||||||
|
Subroutine
active_namenode: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $opt = ref $_[0] eq 'HASH' ? shift @_ : {}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | my($rv, $try); | |||||||||||||||||||||||||||
| 32 | NN_TRY: { | ||||||||||||||||||||||||||||
| 33 | 0 | NN_PROBE: foreach my $nn ( @{ $self->namenodes } ) { | |||||||||||||||||||||||||||
| 34 | 0 | my $uri = sprintf 'http://%s/jmx?qry=Hadoop:service=NameNode,name=FSNamesystem', $nn; | |||||||||||||||||||||||||||
| 35 | 0 | my $jmx; | |||||||||||||||||||||||||||
| 36 | eval { | ||||||||||||||||||||||||||||
| 37 | 0 | $jmx = $self->agent_request( $uri ); | |||||||||||||||||||||||||||
| 38 | 0 | 1; | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $eval_error = $@ || 'Zombie error'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'Zombie error'
MC/DC0%0/1
$@ || 'Zombie error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$eval_error =~ /$RE_TIMEOUT/ or $eval_error =~ /$RE_DEAD/
MC/DC0%0/2
$eval_error =~ /$RE_TIMEOUT/ or $eval_error =~ /$RE_DEAD/
$eval_error =~ /$RE_TIMEOUT/
$eval_error =~ /$RE_DEAD/
Truth table0%0/3
A or B
A= $eval_error =~ /$RE_TIMEOUT/B= $eval_error =~ /$RE_DEAD/
| |||||||||||||||||||||||||||||
| 42 | $eval_error =~ $RE_TIMEOUT | ||||||||||||||||||||||||||||
| 43 | || $eval_error =~ $RE_DEAD | ||||||||||||||||||||||||||||
| 44 | ) { | ||||||||||||||||||||||||||||
| 45 | 0 | next NN_PROBE; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | die sprintf 'Error while probing the name node `%s`: %s', | |||||||||||||||||||||||||||
| 48 | ( split m{ [:] }xms, $nn, 2 )[0], | ||||||||||||||||||||||||||||
| 49 | $eval_error, | ||||||||||||||||||||||||||||
| 50 | ; | ||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | next NN_PROBE if ref $jmx ne 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | my $status = $jmx->{beans}[0]{'tag.HAState'}; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | next NN_PROBE if ! $status || $status ne 'active'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $status or $status ne "active"
MC/DC0%0/2
not $status or $status ne "active"
not $status
$status ne "active"
Truth table0%0/3
not(A) or B
A= not $statusB= $status ne "active"
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ( $opt->{real_hostname} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $rv = $jmx->{beans}[0]{'tag.Hostname'} || die "Unable to locate tag.Hostname from JMX"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$jmx->{'beans'}[0]{'tag.Hostname'} || die('Unable to locate tag.Hostname from JMX')
MC/DC0%0/1
$jmx->{'beans'}[0]{'tag.Hostname'} || die('Unable to locate tag.Hostname from JMX')
$jmx->{'beans'}[0]{'tag.Hostname'}
Truth table0%0/2
A
A= $jmx->{'beans'}[0]{'tag.Hostname'}
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( ! $opt->{hostname_only} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $rv .= ':' . (split m{ [:] }xms, $nn )[1] | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | else { | ||||||||||||||||||||||||||||
| 63 | 0 | $rv = $nn; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | last NN_PROBE; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ( ! $rv ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( ++$try <= 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | sleep 1; | |||||||||||||||||||||||||||
| 71 | 0 | redo NN_TRY; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 0 | die sprintf 'Failed to locate the active namenode (tried %s times)', $try; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return $opt->{hostname_only} ? (split m{ [:] }xms, $rv )[0] : $rv; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub startupProgress { | ||||||||||||||||||||||||||
|
Subroutine
startupProgress: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | 0 | my @nn = @{ $self->namenodes }; | |||||||||||||||||||||||||||
| 83 | 0 | my $uri_tmpl = 'http://%s/%s'; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | NAME_NODE: while ( my $nn = shift @nn ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | my $uri = sprintf $uri_tmpl, $nn, 'startupProgress'; | |||||||||||||||||||||||||||
| 87 | 0 | my $resp; | |||||||||||||||||||||||||||
| 88 | eval { | ||||||||||||||||||||||||||||
| 89 | 0 | $resp = $self->agent_request( $uri ); | |||||||||||||||||||||||||||
| 90 | 0 | 1; | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $eval_error = $@ || 'Zombie error'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'Zombie error'
MC/DC0%0/1
$@ || 'Zombie error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||
| 93 | 0 | my $msg = "Error from $nn: $eval_error"; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # TODO: | ||||||||||||||||||||||||||||
| 96 | # if ( $eval_error =~ $failover_or_passive_or_whatever ) { | ||||||||||||||||||||||||||||
| 97 | # warn $msg; @rv = (); next NAME_NODE; | ||||||||||||||||||||||||||||
| 98 | # } | ||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | die $msg; | |||||||||||||||||||||||||||
| 102 | }; | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | return $resp; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | 1; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | __END__ | ||||||||||||||||||||||||||||