| 1 | package Net::Hadoop::YARN::ResourceManager::Scheduler::UserApps; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $Net::Hadoop::YARN::ResourceManager::Scheduler::UserApps::VERSION = '0.203'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Data::Dumper (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Ref::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Time::Duration (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Net::Hadoop::YARN::ResourceManager; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | has rm_object => ( | ||||||||||||||||||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $thing = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $type = 'Net::Hadoop::YARN::ResourceManager'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ( ! $thing | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$thing && builtin::blessed($thing) && $thing->isa($type)
$thing and builtin::blessed($thing)
MC/DC0%0/3
$thing && builtin::blessed($thing) && $thing->isa($type)
$thing
builtin::blessed($thing)
$thing->isa($type)
Truth table0%0/4
A and B && C
A= $thingB= builtin::blessed($thing)C= $thing->isa($type)
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | || ! Scalar::Util::blessed $thing | ||||||||||||||||||||||||||||||||||||||||||
| 22 | || ! $thing->isa( $type ) | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | die "rm_object is not a $type"; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | Net::Hadoop::YARN::ResourceManager->new( | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ( $ENV{YARN_RESOURCE_MANAGER} ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | servers => [ split /,/, $ENV{YARN_RESOURCE_MANAGER} ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | ) : () ) | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub collect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect: not called CC=40 SCAR=74.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $user = shift || die "No user name was specified"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die('No user name was specified')
MC/DC0%0/1
shift() || die('No user name was specified')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $apps = $self->rm_object->apps( user => $user ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( ! Ref::Util::is_arrayref $apps ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ( Ref::Util::is_hashref $apps ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ( my $check = $apps->{apps} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ( ! keys %{ $check }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $apps = []; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | die sprintf "[TODO-1] Don't know what to do with %s", | |||||||||||||||||||||||||||||||||||||||||
| 50 | Data::Dumper::Dumper [ $user => $apps ], | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | die sprintf "[TODO-2] Don't know what to do with %s", | |||||||||||||||||||||||||||||||||||||||||
| 57 | Data::Dumper::Dumper [ $user => $apps ], | ||||||||||||||||||||||||||||||||||||||||||
| 58 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my $format_epoch = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $epoch = shift || die "No epoch specified!"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die('No epoch specified!')
MC/DC0%0/1
shift() || die('No epoch specified!')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return POSIX::strftime "%a %b %d %Y %H:%M:%S %Z", localtime $epoch; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my %apps_by_state; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | foreach my $app ( @{ $apps } ) { | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | foreach my $resource ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 71 | allocatedMB | ||||||||||||||||||||||||||||||||||||||||||
| 72 | allocatedVCores | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $app->{ $resource } = 0 if $app->{ $resource } eq '-1'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ( $app->{allocatedMB} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $app->{allocatedMB_fmt} = $self->format_bytes( $app->{allocatedMB} * 1024**2 ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ( $app->{allocatedVCores} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | $app->{allocatedVCores_fmt} = sprintf '%s vCore%s', | ||||||||||||||||||||||||||||||||||||||||||
| 83 | $app->{allocatedVCores}, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $app->{allocatedVCores} > 1 ? 's' : '', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # TODO | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # [STRING]"applicationTags" | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # the value is something like "oozie-59a27f107d250c9822fd45e87fd40db8" | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # which is not the job id. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | foreach my $hash_or_string ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 94 | diagnostics | ||||||||||||||||||||||||||||||||||||||||||
| 95 | applicationTags | ||||||||||||||||||||||||||||||||||||||||||
| 96 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | next if ! exists $app->{ $hash_or_string }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | # This is a bug in the REST layer | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ( Ref::Util::is_hashref $app->{ $hash_or_string } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Ref::Util::XS::is_hashref($app->{$hash_or_string}) and not keys %{$$app{$hash_or_string};}
MC/DC0%0/2
Ref::Util::XS::is_hashref($app->{$hash_or_string}) and not keys %{$$app{$hash_or_string};}
Ref::Util::XS::is_hashref($app->{$hash_or_string})
not keys %{$$app{$hash_or_string};}
Truth table0%0/3
A and not(B)
A= Ref::Util::XS::is_hashref($app->{$hash_or_string})B= not keys %{$$app{$hash_or_string};}
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | && ! keys %{ $app->{ $hash_or_string } } | |||||||||||||||||||||||||||||||||||||||||
| 101 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $app->{ $hash_or_string } = ''; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | # https://www.cloudera.com/documentation/enterprise/latest/topics/cm_dg_yarn_applications.html | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | foreach my $duration_field ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 108 | vcoreSeconds | ||||||||||||||||||||||||||||||||||||||||||
| 109 | elapsedTime | ||||||||||||||||||||||||||||||||||||||||||
| 110 | memorySeconds | ||||||||||||||||||||||||||||||||||||||||||
| 111 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | next if ! exists $app->{ $duration_field }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( $app->{ $duration_field } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | $app->{ $duration_field . '_fmt' } = Time::Duration::duration( | ||||||||||||||||||||||||||||||||||||||||||
| 115 | $duration_field eq 'elapsedTime' | ||||||||||||||||||||||||||||||||||||||||||
| 116 | ? $app->{ $duration_field } / 1000 | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | : $app->{ $duration_field } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | foreach my $time_field ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 123 | finishedTime | ||||||||||||||||||||||||||||||||||||||||||
| 124 | startedTime | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | next if ! exists $app->{ $time_field }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( $app->{ $time_field } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $app->{ $time_field . '_fmt' } = $format_epoch->( $app->{ $time_field } / 1000); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ( $app->{name} =~ m{ \Q-oozie-oozi-W\E \z }xms ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my %name = map { @{ $_ } > 1 ? @{ $_ } : ( $_->[0] => 1 ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | map { [ split m{ [=] }xms, $_, 2 ] } | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | split m{ [:] }xms, $app->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $name{workflow_name} = delete $name{W} if $name{W}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | $name{action_name} = delete $name{A} if $name{A}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $name{action_type} = delete $name{T} if $name{T}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $name{id} = delete $name{ID} if $name{ID}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $app->{oozie_meta} = \%name; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $app->{oozie_id} = $name{id} if $name{id}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | push @{ $apps_by_state{ $app->{state} } ||= [] }, $app; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$apps_by_state{$app->{"state"}} ||= []
MC/DC0%0/1
$apps_by_state{$app->{"state"}} ||= []
$apps_by_state{$app->{"state"}}
Truth table0%0/2
A
A= $apps_by_state{$app->{"state"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my %total_res; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | foreach my $app ( @{ $apps_by_state{RUNNING} }) { | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $total_res{allocatedMB} += $app->{allocatedMB}; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $total_res{allocatedVCores} += $app->{allocatedVCores}; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( $total_res{allocatedMB} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $total_res{allocatedMB_fmt} = $self->format_bytes( $total_res{allocatedMB} * 1024**2 ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( $total_res{allocatedVCores} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | $total_res{allocatedVCores_fmt} = sprintf '%s vCore%s', | ||||||||||||||||||||||||||||||||||||||||||
| 159 | $total_res{allocatedVCores}, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $total_res{allocatedVCores} > 1 ? 's' : '', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my @grouped; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | foreach my $ordered_state (qw( | |||||||||||||||||||||||||||||||||||||||||
| 166 | RUNNING | ||||||||||||||||||||||||||||||||||||||||||
| 167 | ACCEPTED | ||||||||||||||||||||||||||||||||||||||||||
| 168 | FINISHED | ||||||||||||||||||||||||||||||||||||||||||
| 169 | KILLED | ||||||||||||||||||||||||||||||||||||||||||
| 170 | FAILED | ||||||||||||||||||||||||||||||||||||||||||
| 171 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | push @grouped, { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | state => lc( $ordered_state ), | ||||||||||||||||||||||||||||||||||||||||||
| 174 | state_fmt => ucfirst( lc $ordered_state ), | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | apps => delete( $apps_by_state{$ordered_state} ) || [], | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $apps_by_state{$ordered_state} || []
MC/DC0%0/1
delete $apps_by_state{$ordered_state} || []
delete $apps_by_state{$ordered_state}
Truth table0%0/2
A
A= delete $apps_by_state{$ordered_state}
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | # TODO: possibly needs to be removed if we are sure that the code above | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # is handling all of the possible states. So, this is a "just in case" part | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # | ||||||||||||||||||||||||||||||||||||||||||
| 182 | push @grouped, { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | state => 'rest', | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | apps => [ map { @{ $_ } } values %apps_by_state ], | |||||||||||||||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | # Spark jobs are returned like this for whatever reason. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ( my $apps = $grouped[-1]->{apps} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ( Ref::Util::is_arrayref $apps && Ref::Util::is_arrayref $apps->[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Ref::Util::XS::is_arrayref($apps) and Ref::Util::XS::is_arrayref($apps->[0])
MC/DC0%0/2
Ref::Util::XS::is_arrayref($apps) and Ref::Util::XS::is_arrayref($apps->[0])
Ref::Util::XS::is_arrayref($apps)
Ref::Util::XS::is_arrayref($apps->[0])
Truth table0%0/3
A and B
A= Ref::Util::XS::is_arrayref($apps)B= Ref::Util::XS::is_arrayref($apps->[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $grouped[-1]->{apps} = [ @{ $apps->[0] } ]; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | grouped_apps => [ grep { @{ $_->{apps} } > 0 } @grouped ], | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | total_apps => scalar @{ $apps }, | |||||||||||||||||||||||||||||||||||||||||
| 197 | resources => \%total_res, | ||||||||||||||||||||||||||||||||||||||||||
| 198 | user => $user, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub format_bytes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_bytes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $bytes = shift; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | return sprintf '%.2f GB', $bytes / 1024**3; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | __END__ | ||||||||||||||||||||||||||||||||||||||||||