| 1 | package Gearman::Objects; | ||||||||||||||||||||||||||||
| 2 | 18 | ▶ | use version (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 18 | $Gearman::Objects::VERSION = version->declare("2.003_001"); | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Gearman::Objects - a parent class for L<Gearman::Client> and L<Gearman::Worker> | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 METHODS | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 18 | ▶ | use constant DEFAULT_PORT => 4730; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 18 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 18 | ▶ | use IO::Socket::IP (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 18 | ▶ | use IO::Socket::SSL (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 18 | ▶ | use Socket (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 18 | use List::MoreUtils qw/ | |||||||||||||||||||||||||||
| 23 | first_index | ||||||||||||||||||||||||||||
| 24 | 18 | ▶ | /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 18 | use fields qw/ | |||||||||||||||||||||||||||
| 27 | debug | ||||||||||||||||||||||||||||
| 28 | job_servers | ||||||||||||||||||||||||||||
| 29 | js_count | ||||||||||||||||||||||||||||
| 30 | prefix | ||||||||||||||||||||||||||||
| 31 | sock_cache | ||||||||||||||||||||||||||||
| 32 | 18 | ▶ | /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub new { | ||||||||||||||||||||||||||||
| 35 | 21 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 21 | my (%opts) = @_; | |||||||||||||||||||||||||||
| 37 | 21 | ▶ | unless (ref $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 10 | $self = fields::new($self); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 21 | $self->{job_servers} = []; | |||||||||||||||||||||||||||
| 41 | 21 | $self->{js_count} = 0; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | $opts{job_servers} | ||||||||||||||||||||||||||||
| 44 | 21 | ▶ | && $self->set_job_servers($opts{job_servers}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 21 | $self->debug($opts{debug}); | |||||||||||||||||||||||||||
| 47 | 21 | $self->prefix($opts{prefix}); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 21 | $self->{sock_cache} = {}; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 21 | return $self; | |||||||||||||||||||||||||||
| 52 | } ## end sub new | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head2 job_servers([$js]) | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | getter/setter | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | C<$js> array reference, hash reference or scalar | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub job_servers { | ||||||||||||||||||||||||||||
| 63 | 9 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
job_servers: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 9 | ▶ | (@_) && $self->set_job_servers(@_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 9 | ▶ | return wantarray ? @{ $self->{job_servers} } : $self->{job_servers}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | } ## end sub job_servers | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head2 set_job_servers($js) | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | set job_servers attribute by canonicalized C<$js>_ | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub set_job_servers { | ||||||||||||||||||||||||||||
| 76 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_job_servers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 6 | my $list = $self->canonicalize_job_servers(@_); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 6 | $self->{js_count} = scalar @{$list}; | |||||||||||||||||||||||||||
| 80 | 6 | return $self->{job_servers} = $list; | |||||||||||||||||||||||||||
| 81 | } ## end sub set_job_servers | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head2 canonicalize_job_servers($js) | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | C<$js> a string, hash reference or array reference of aforementioned. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | Hash reference should contain at least host key. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | All keys: host, port (4730 on default), use_ssl, key_file, cert_file, | ||||||||||||||||||||||||||||
| 90 | ca_certs, socket_cb | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | B<return> [canonicalized list] | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =cut | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | sub canonicalize_job_servers { | ||||||||||||||||||||||||||||
| 97 | 11 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
canonicalize_job_servers: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 11 | my @in; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 11 | my $ref = ref($_[0]); | |||||||||||||||||||||||||||
| 101 | 11 | ▶ | if ($ref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 7 | ▶ | if ($ref eq "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 103 | 3 | @in = @{ $_[0] }; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | elsif ($ref eq "HASH") { | ||||||||||||||||||||||||||||
| 106 | 4 | @in = ($_[0]); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||
| 109 | 0 | Carp::croak "unsupported argument type ", ref($_[0]); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } ## end if (is_plain_ref($_[0]...)) | ||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||
| 113 | 4 | @in = @_; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 11 | my $out = []; | |||||||||||||||||||||||||||
| 117 | 11 | foreach my $i (@in) { | |||||||||||||||||||||||||||
| 118 | 11 | ▶ | if (ref($i)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 119 | 5 | ▶ | $i->{port} ||= Gearman::Objects::DEFAULT_PORT; | ||||||||||||||||||||||||||
|
Condition50%1/2
$i->{"port"} ||= 4730
MC/DC0%0/1
$i->{"port"} ||= 4730
$i->{"port"}
Truth table50%1/2
A
A= $i->{"port"}
| |||||||||||||||||||||||||||||
| 120 | } elsif ($i !~ /:/) { | ||||||||||||||||||||||||||||
| 121 | 2 | $i .= ':' . Gearman::Objects::DEFAULT_PORT; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 11 | push @{$out}, $i; | |||||||||||||||||||||||||||
| 124 | } ## end foreach (@in) | ||||||||||||||||||||||||||||
| 125 | 11 | return $out; | |||||||||||||||||||||||||||
| 126 | } ## end sub canonicalize_job_servers | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | sub debug { | ||||||||||||||||||||||||||||
| 129 | 30 | ▶ | return shift->_property("debug", @_); | ||||||||||||||||||||||||||
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =head2 func($func) | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | B<return> C<< $prefix ? $prefix\t$func : $func >> | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =cut | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | sub func { | ||||||||||||||||||||||||||||
| 139 | 6 | ▶ | my ($self, $func) = @_; | ||||||||||||||||||||||||||
|
Subroutine
func: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 6 | my $prefix = $self->prefix; | |||||||||||||||||||||||||||
| 141 | 6 | ▶ | return defined($prefix) ? join("\t", $prefix, $func) : $func; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =head2 prefix([$prefix]) | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | getter/setter | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =cut | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | sub prefix { | ||||||||||||||||||||||||||||
| 151 | 33 | ▶ | return shift->_property("prefix", @_); | ||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head2 socket($js, [$timeout]) | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | depends on C<use_ssl> | ||||||||||||||||||||||||||||
| 157 | prepare L<IO::Socket::IP> | ||||||||||||||||||||||||||||
| 158 | or L<IO::Socket::SSL> | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =over | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =item | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | C<$host_port> peer address | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =item | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | C<$timeout> default: 1 | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =back | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | B<return> depends on C<use_ssl> IO::Socket::(IP|SSL) on success | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =cut | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | sub socket { | ||||||||||||||||||||||||||||
| 177 | 3 | ▶ | my ($self, $js, $t) = @_; | ||||||||||||||||||||||||||
|
Subroutine
socket: called CC=10 SCAR=24.5
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 3 | ▶ | unless (ref($js)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | my ($h, $p) = ($js =~ /^(.*):(\d+)$/); | |||||||||||||||||||||||||||
| 180 | 0 | $js = { host => $h, port => $p }; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | my %opts = ( | ||||||||||||||||||||||||||||
| 184 | PeerPort => $js->{port}, | ||||||||||||||||||||||||||||
| 185 | PeerHost => $js->{host}, | ||||||||||||||||||||||||||||
| 186 | 3 | ▶ | Timeout => $t || 1 | ||||||||||||||||||||||||||
|
Condition100%2/2
$t || 1
MC/DC100%1/1
$t || 1
$t
Truth table100%2/2
A
A= $t
| |||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 3 | my $sc = "IO::Socket::IP"; | |||||||||||||||||||||||||||
| 190 | 3 | ▶ | if ($js->{use_ssl}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 2 | $sc = "IO::Socket::SSL"; | |||||||||||||||||||||||||||
| 192 | 2 | for (qw/ key_file cert_file ca_certs /) { | |||||||||||||||||||||||||||
| 193 | 6 | ▶ | $js->{$_} || next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | $opts{ join('_', "SSL", $_) } = $js->{$_}; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } ## end if ($js->{use_ssl}) | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 3 | ▶ | $js->{socket_cb} && $js->{socket_cb}->(\%opts); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 3 | my $s = $sc->new(%opts); | |||||||||||||||||||||||||||
| 201 | 3 | ▶ | unless ($s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | $self->debug() && Carp::carp("connection failed error='$@'", | ||||||||||||||||||||||||||||
| 203 | $js->{use_ssl} | ||||||||||||||||||||||||||||
| 204 | 2 | ▶ | ? ", ssl_error='$IO::Socket::SSL::SSL_ERROR'" | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 205 | : ""); | ||||||||||||||||||||||||||||
| 206 | } ## end unless ($s) | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 3 | return $s; | |||||||||||||||||||||||||||
| 209 | } ## end sub socket | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | =head2 sock_nodelay($sock) | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | set TCP_NODELAY on $sock, die on failure | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =cut | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | sub sock_nodelay { | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my ($self, $sock) = @_; | ||||||||||||||||||||||||||
|
Subroutine
sock_nodelay: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | setsockopt($sock, Socket::IPPROTO_TCP, Socket::TCP_NODELAY, pack("l", 1)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | or Carp::croak "setsockopt: $!"; | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | # _sock_cache($js, [$sock, $delete]) | ||||||||||||||||||||||||||||
| 224 | # | ||||||||||||||||||||||||||||
| 225 | # B<return> $sock || undef | ||||||||||||||||||||||||||||
| 226 | # | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | sub _sock_cache { | ||||||||||||||||||||||||||||
| 229 | 5 | ▶ | my ($self, $js, $sock, $delete) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_sock_cache: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 230 | 5 | my $hp = $self->_js_str($js); | |||||||||||||||||||||||||||
| 231 | 5 | ▶ | if ($sock) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 3 | $self->{sock_cache}->{$hp} = $sock; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | return $delete | ||||||||||||||||||||||||||||
| 236 | ? delete($self->{sock_cache}->{$hp}) | ||||||||||||||||||||||||||||
| 237 | 5 | ▶ | : $self->{sock_cache}->{$hp}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } ## end sub _sock_cache | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | # | ||||||||||||||||||||||||||||
| 241 | # _property($name, [$value]) | ||||||||||||||||||||||||||||
| 242 | # set/get | ||||||||||||||||||||||||||||
| 243 | sub _property { | ||||||||||||||||||||||||||||
| 244 | 63 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_property: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 245 | 63 | my $name = shift; | |||||||||||||||||||||||||||
| 246 | 63 | ▶ | $name || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 63 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 46 | $self->{$name} = shift; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 63 | return $self->{$name}; | |||||||||||||||||||||||||||
| 252 | } ## end sub _property | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | # | ||||||||||||||||||||||||||||
| 255 | #_js_str($js) | ||||||||||||||||||||||||||||
| 256 | # | ||||||||||||||||||||||||||||
| 257 | # return host:port | ||||||||||||||||||||||||||||
| 258 | sub _js_str { | ||||||||||||||||||||||||||||
| 259 | 10 | ▶ | my ($self, $js) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_js_str: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 260 | 10 | ▶ | return ref($js) eq "HASH" ? join(':', @{$js}{qw/host port/}) : $js; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | # | ||||||||||||||||||||||||||||
| 264 | # _js($js_str) | ||||||||||||||||||||||||||||
| 265 | # | ||||||||||||||||||||||||||||
| 266 | # return job_servers item || undef | ||||||||||||||||||||||||||||
| 267 | # | ||||||||||||||||||||||||||||
| 268 | sub _js { | ||||||||||||||||||||||||||||
| 269 | 1 | ▶ | my ($self, $js_str) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_js: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||
| 270 | 1 | my @s = $self->job_servers(); | |||||||||||||||||||||||||||
| 271 | 1 | ▶ | my $i = first_index { $js_str eq $self->_js_str($_) } @s; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 272 | 1 | ▶ | return ($i == -1 || $i > $#s) ? undef : $s[$i]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$i == -1 or $i > $#s
MC/DC0%0/2
$i == -1 or $i > $#s
$i == -1
$i > $#s
Truth table33%1/3
A or B
A= $i == -1B= $i > $#s
| |||||||||||||||||||||||||||||
| 273 | } ## end sub _js | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 18 | 1; | |||||||||||||||||||||||||||