blib/lib/Net/CascadeCopy.pm

filter: Statementstmt 94.9% 264 / 278 Branchbran 77.1% 71 / 92 Conditioncond 72.7% 8 / 11 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 96.9% 32 / 33 Podpod 100% 4 / 4 totaltotal 90.1% 383 / 425 CC 60 SCAR 16.7
CC
60
Cov
90%
_start_process
12.6
_transfer_loop
9.0
_human_friendly_time
7.3
CRAP 5.3
↑ Summary
1 package Net::CascadeCopy;
2 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 34 our $VERSION = '0.2.6'; # VERSION
6  
7 34 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 34 ▶use Benchmark;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 34 ▶use Log::Log4perl qw(:easy);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 34 ▶use POSIX ":sys_wait_h"; # imports WNOHANG
Subroutine BEGIN: called CC=1 SCAR=0.0
12 34 ▶use Proc::Queue size => 32, debug => 0, trace => 0, delay => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 34 my $logger = get_logger( 'default' );
15  
16 34 ▶has data => ( is => 'ro', isa => 'HashRef', default => sub { return {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
17  
18 34 has total_time => ( is => 'rw', isa => 'Num', default => 0 );
19  
20 34 has ssh => ( is => 'ro', isa => 'Str', default => "ssh" );
21 34 has ssh_args => ( is => 'ro', isa => 'Str', default => "-x -A" );
22  
23 34 has command => ( is => 'ro', isa => 'Str', required => 1 );
24 34 has command_args => ( is => 'ro', isa => 'Str', default => "" );
25  
26 34 has source_path => ( is => 'ro', isa => 'Str', required => 1 );
27 34 has target_path => ( is => 'ro', isa => 'Str', required => 1 );
28  
29 34 has output => ( is => 'ro', isa => 'Str', default => "" );
30  
31 # maximum number of failures per server
32 34 has max_failures => ( is => 'ro', isa => 'Num', default => 3 );
33  
34 # maximum processes per remote server
35 34 has max_forks => ( is => 'ro', isa => 'Num', default => 2 );
36  
37 # keep track of child processes
38 34 ▶has children => ( is => 'ro', isa => 'HashRef', default => sub { return {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
39  
40 # for testing purposes
41 34 ▶has transfer_map => ( is => 'ro', isa => 'HashRef', default => sub { return {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
42  
43 # sort order
44 34 ▶has sort_order => ( is => 'ro', isa => 'HashRef', default => sub { return {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
45  
46 47 ▶sub add_group {
Subroutine add_group: called CC=3 SCAR=11.0
Pod documented
47 47 my ( $self, $group, $servers_a ) = @_;
48  
49 47 $logger->info( "Adding group: $group: ",
50 join( ", ", @$servers_a ),
51 );
52  
53 # initialize data structures
54 47 for my $server ( @{ $servers_a } ) {
55 253 $self->data->{remaining}->{ $group }->{$server} = 1;
56  
57 253 ▶ unless ( defined $self->sort_order->{ $group }->{ $server } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->sort_order->{$group}{$server}) 252 1 253
58 252 $self->sort_order->{ $group }->{ $server } = scalar keys %{ $self->sort_order->{ $group } };
59 }
60 }
61  
62 # first server to transfer from is the current server
63 47 $self->data->{available}->{ $group }->{localhost} = 1;
64  
65 # initialize data structures
66 47 $self->data->{completed}->{ $group } = [];
67  
68 }
69  
70 6 ▶sub get_groups {
Subroutine get_groups: called CC=2 SCAR=6.9
Pod documented
71 6 my ( $self ) = @_;
72  
73 6 my @groups;
74  
75 6 for my $group ( keys %{ $self->sort_order } ) {
76 7 push @groups, $group;
77 }
78  
79 6 return @groups;
80 }
81  
82 11 ▶sub transfer {
Subroutine transfer: called CC=2 SCAR=6.9
Pod documented
83 11 my ( $self ) = @_;
84  
85 11 my $transfer_start = new Benchmark;
86  
87 LOOP:
88 11 while ( 1 ) {
89 109 ▶ last LOOP unless $self->_transfer_loop( $transfer_start );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_transfer_loop($transfer_start) 1 98 99
90 98 sleep 1;
91 }
92 }
93  
94 153 ▶sub _transfer_loop {
Subroutine _transfer_loop: called CC=9 SCAR=22.0
95 153 my ( $self, $transfer_start ) = @_;
96  
97 153 $self->_check_for_completed_processes();
98  
99 # keep track if there are any remaining servers in any groups
100 153 my ( $remaining_flag, $available_flag );
101  
102 # handle completed processes
103 153 ▶ if ( ! scalar keys %{ $self->data->{remaining} } && ! $self->data->{running} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %{$self->data->{"remaining"};} or $self->data->{"running"}) 6 147 153
Condition100%3/3
scalar keys %{$self->data->{"remaining"};} or $self->data->{"running"}
l!l&&r!l&&!r
14256
MC/DC100%2/2
scalar keys %{$self->data->{"remaining"};} or $self->data->{"running"}
scalar keys %{$self->data->{"remaining"};} $self->data->{"running"}
Truth table100%3/3
A or B
A= scalar keys %{$self->data->{"remaining"};}B= $self->data->{"running"}
ABresult
1X1
011
000
104 6 my $transfer_end = new Benchmark;
105 6 my $transfer_diff = timediff( $transfer_end, $transfer_start );
106 6 my $transfer_time = $self->_human_friendly_time( $transfer_diff->[0] );
107 6 $logger->warn( "Job completed in $transfer_time" );
108  
109 6 my $total_time = $self->_human_friendly_time( $self->total_time );
110 6 $logger->info ( "Cumulative tansfer time of all jobs: $total_time" );
111  
112 6 my $savings = $self->total_time - $transfer_diff->[0];
113 6 ▶ if ( $savings ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($savings) 2 4 6
114 2 $savings = $self->_human_friendly_time( $savings );
115 2 $logger->info( "Approximate Time Saved: $savings" );
116 }
117  
118 6 my $failure_count;
119 6 for my $group ( $self->get_groups() ) {
120 7 my ( $errors, $failures ) = $self->_get_failed_count( $group );
121 7 $failure_count += $failures;
122 }
123  
124 6 ▶ if ( $failure_count ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($failure_count) { } 1 5 6
125 1 $logger->fatal( "$failure_count Fatal Errors" );
126 }
127 else {
128 5 $logger->warn( "Completed successfully" );
129 }
130 6 return;
131 }
132  
133 # start new transfers to remaining servers
134 147 for ( 0, 1 ) {
135 # code_smell: start 2 transfers each round to keep the
136 # test cases from breaking. need to refactor test cases!
137 276 for my $group ( $self->_get_remaining_groups() ) {
138 # group contains servers that still need to be tranferred
139  
140 300 ▶ if ( $self->_get_available_servers( $group ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_get_available_servers($group)) 144 156 300
141 # reserve a server to start a new transfer from
142 144 my $source = $self->_reserve_available_server( $group );
143 144 my $target = $self->_reserve_remaining_server( $group );
144 144 $self->_start_process( $group, $source, $target );
145 }
146 }
147 }
148  
149 121 return 1;
150 }
151  
152 95 ▶sub _human_friendly_time {
Subroutine _human_friendly_time: called CC=5 SCAR=19.9
153 95 my ( $self, $seconds ) = @_;
154  
155 95 ▶ return "0 secs" unless $seconds;
Branch: 1 branch
BranchTrueFalseTotal
unless $seconds 0 95 95
156  
157 95 my @time_string;
158  
159 95 ▶ if ( $seconds > 3600 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds > 3600) 0 95 95
160 0 my $hours = int( $seconds / 3600 );
161 0 $seconds = $seconds % 3600;
162 0 push @time_string, "$hours hrs";
163 }
164 95 ▶ if ( $seconds > 60 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds > 60) 0 95 95
165 0 my $minutes = int( $seconds / 60 );
166 0 $seconds = $seconds % 60;
167 0 push @time_string, "$minutes mins";
168 }
169 95 ▶ if ( $seconds ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds) 95 0 95
170 95 push @time_string, "$seconds secs";
171 }
172  
173 95 return join " ", @time_string;
174 }
175  
176 82 ▶sub _print_status {
Subroutine _print_status: called CC=6 SCAR=17.9
177 82 my ( $self, $group ) = @_;
178  
179 # completed procs
180 82 my $completed = 0;
181 82 ▶ if ( $self->data->{completed}->{ $group } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"completed"}{$group}) 82 0 82
182 82 $completed = scalar @{ $self->data->{completed}->{ $group } };
183 }
184  
185 # running procs
186 82 my $running = 0;
187 82 ▶ if ( $self->data->{running} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"running"}) 82 0 82
188 82 for my $pid ( keys %{ $self->data->{running} } ) {
189 90 ▶ if ( $self->data->{running}->{ $pid }->{group} eq $group ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"running"}{$pid}{"group"} eq $group) 57 33 90
190 57 $running++;
191 }
192 }
193 }
194  
195 # unstarted
196 82 my $unstarted = 0;
197 82 ▶ if ( $self->data->{remaining}->{ $group } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"remaining"}{$group}) 68 14 82
198 68 $unstarted = scalar keys %{ $self->data->{remaining}->{ $group } };
199 }
200  
201 # failed
202 82 my ( $errors, $failures ) = $self->_get_failed_count( $group );
203  
204 82 $logger->info( "\U$group: ",
205 "completed:$completed ",
206 "running:$running ",
207 "left:$unstarted ",
208 "errors:$errors ",
209 "failures:$failures ",
210 );
211 }
212  
213 144 ▶sub _start_process {
Subroutine _start_process: called CC=11 SCAR=25.3
214 144 my ( $self, $group, $source, $target ) = @_;
215  
216 144 $self->transfer_map->{$source}->{$target} += 1;
217  
218 144 my $f=fork;
219 144 ▶ if (defined ($f) and $f==0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $f and $f == 0) { } 26 118 144
Condition66%2/3
defined $f and $f == 0
!ll&&!rl&&r
011826
MC/DC50%1/2
defined $f and $f == 0
defined $f $f == 0
Truth table66%2/3
A and B
A= defined $fB= $f == 0
ABresult
0X0
100
111
220  
221 26 my $target_path = $self->target_path;
222  
223 26 my $command;
224 26 ▶ if ( $source eq "localhost" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source eq 'localhost') { } 7 19 26
225 7 $command = join( " ",
226 $self->command,
227 $self->command_args,
228 $self->source_path,
229 "$target:$target_path"
230 );
231 } else {
232 19 $command = join( " ",
233 $self->ssh,
234 $self->ssh_args,
235 $source,
236 $self->command,
237 $self->command_args,
238 $self->target_path,
239 "$target:$target_path"
240 );
241 }
242  
243 26 print "COMMAND: $command\n";
244  
245 26 ▶ my $output = $self->output || "";
Condition50%1/2
$self->output || ''
l!l
026
MC/DC0%0/1
$self->output || ''
$self->output
Truth table50%1/2
A
A= $self->output
Aresult
11
00
246 26 ▶ if ( $output eq "stdout" ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($output eq 'stdout') { } 0 26 26
elsif ($output eq 'log') { } 0 26 26
247 # don't modify command
248 } elsif ( $output eq "log" ) {
249 # redirect all child output to log
250 0 $command = "$command >> ccp.$source.$target.log 2>&1"
251 } else {
252 # default is to redirectout stdout to /dev/null
253 26 $command = "$command >/dev/null"
254 }
255  
256 26 $logger->info( "Starting: ($group) $source => $target" );
257 26 $logger->debug( "Starting new child: $command" );
258  
259 26 system( $command );
260  
261 26 ▶ if ($? == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($? == -1) { } 0 26 26
elsif ($? & 127) { } 0 26 26
262 0 $logger->logconfess( "failed to execute: $!" );
263 } elsif ($? & 127) {
264 0 ▶ $logger->logconfess( sprintf "child died with signal %d, %s coredump",
Branch: 1 branch
BranchTrueFalseTotal
$? & 128 ? : 0 0 0
265 ($? & 127), ($? & 128) ? 'with' : 'without'
266 );
267 } else {
268 26 my $exit_status = $? >> 8;
269 26 ▶ if ( $exit_status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit_status) 1 25 26
270 1 $logger->error( "child exit status: $exit_status" );
271 }
272 26 exit $exit_status;
273 }
274 } else {
275 118 my $start = new Benchmark;
276 118 $self->data->{running}->{ $f } = { group => $group,
277 source => $source,
278 target => $target,
279 start => $start,
280 };
281 }
282 }
283  
284 176 ▶sub _check_for_completed_processes {
Subroutine _check_for_completed_processes: called CC=6 SCAR=17.9
285 176 my ( $self ) = @_;
286  
287 176 ▶ return unless $self->data->{running};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"running"} 55 121 176
288  
289 # find any processes that ended and reschedule the source and
290 # target servers in the available pool
291 121 for my $pid ( keys %{ $self->data->{running} } ) {
292 237 ▶ if ( waitpid( $pid, WNOHANG) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&CORE::GLOBAL::waitpid($pid, 1)) 82 155 237
293  
294 # check the exit status of the command.
295 82 ▶ if ( $? ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($?) { } 1 81 82
296 1 $self->_failed_process( $pid );
297 } else {
298 81 $self->_succeeded_process( $pid );
299 }
300 }
301 }
302  
303 121 ▶ unless ( keys %{ $self->data->{running} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$self->data->{"running"};}) 34 87 121
304 34 delete $self->data->{running};
305 }
306 }
307  
308 81 ▶sub _succeeded_process {
Subroutine _succeeded_process: called CC=1 SCAR=0.0
309 81 my ( $self, $pid ) = @_;
310  
311 81 my $group = $self->data->{running}->{ $pid }->{group};
312 81 my $source = $self->data->{running}->{ $pid }->{source};
313 81 my $target = $self->data->{running}->{ $pid }->{target};
314 81 my $start = $self->data->{running}->{ $pid }->{start};
315  
316 # calculate time for this transfer
317 81 my $end = new Benchmark;
318 81 my $diff = timediff( $end, $start );
319  
320 # keep track of transfer time totals
321 81 $self->total_time( $self->total_time + $diff->[0] );
322  
323 81 my $time = $self->_human_friendly_time( $diff->[0] );
324 81 $logger->warn( "Succeeded: ($group) $source => $target ($time)" );
325  
326 81 $self->_mark_available( $group, $source );
327 81 $self->_mark_completed( $group, $target );
328 81 $self->_mark_available( $group, $target );
329  
330 81 delete $self->data->{running}->{ $pid };
331  
332 81 $self->_print_status( $group );
333 }
334  
335 1 ▶sub _failed_process {
Subroutine _failed_process: called CC=3 SCAR=11.3
336 1 my ( $self, $pid ) = @_;
337  
338 1 my $group = $self->data->{running}->{ $pid }->{group};
339 1 my $source = $self->data->{running}->{ $pid }->{source};
340 1 my $target = $self->data->{running}->{ $pid }->{target};
341 1 my $start = $self->data->{running}->{ $pid }->{start};
342  
343 # calculate time for this transfer
344 1 my $end = new Benchmark;
345 1 my $diff = timediff( $end, $start );
346 # keep track of transfer time totals
347 1 $self->total_time( $self->total_time + $diff->[0] );
348  
349 1 $logger->warn( "Failed: ($group) $source => $target ($diff->[0] seconds)" );
350  
351 # there was an error during the transfer, reschedule
352 # it at the end of the list
353 1 $self->_mark_available( $group, $source );
354 1 my $fail_count = $self->_mark_failed( $group, $target );
355 1 ▶ if ( ! $self->_get_available_servers( $group ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->_get_available_servers($group)) { } 1 0 1
elsif ($fail_count >= $self->max_failures) { } 0 0 0
356 1 $logger->fatal( "Error: no available servers in '$group' to handle $target" );
357 1 $self->_mark_failed( $group, $target, 1 );
358 }
359 elsif ( $fail_count >= $self->max_failures ) {
360 0 $logger->fatal( "Error: giving up on ($group) $target" );
361 } else {
362 0 $self->_mark_remaining( $group, $target );
363 }
364  
365 1 delete $self->data->{running}->{ $pid };
366  
367 1 $self->_print_status( $group );
368 }
369  
370 513 ▶sub _get_available_servers {
Subroutine _get_available_servers: called CC=6 SCAR=18.0
371 513 my ( $self, $group ) = @_;
372 513 ▶ return unless $self->data->{available};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"available"} 0 513 513
373 513 ▶ return unless $self->data->{available}->{ $group };
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"available"}{$group} 0 513 513
374  
375 513 my @available;
376 513 for my $host ( $self->_sort_servers( $group, keys %{ $self->data->{available}->{ $group } } ) ) {
377 619 ▶ if ( $self->children->{$host} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->children->{$host}) 258 361 619
378 258 ▶ next if $self->children->{$host} >= $self->max_forks;
Branch: 1 branch
BranchTrueFalseTotal
if $self->children->{$host} >= $self->max_forks 124 134 258
379 }
380 495 push @available, $host;
381 }
382  
383 513 return @available;
384 }
385  
386 144 ▶sub _reserve_available_server {
Subroutine _reserve_available_server: called CC=2 SCAR=6.9
387 144 my ( $self, $group ) = @_;
388  
389 144 my ( $server ) = $self->_get_available_servers( $group );
390 144 $logger->debug( "Reserving ($group) $server" );
391  
392 # only one transfer from localhost to each dc
393 144 ▶ if ( $server eq "localhost" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server eq "localhost") 42 102 144
394 42 delete $self->data->{available}->{$group}->{localhost};
395 }
396  
397 144 $self->children->{ $server }++;
398 144 return $server;
399 }
400  
401 216 ▶sub _get_remaining_servers {
Subroutine _get_remaining_servers: called CC=3 SCAR=11.0
402 216 my ( $self, $group ) = @_;
403  
404 216 ▶ return unless $self->data->{remaining};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"remaining"} 0 216 216
405  
406 216 ▶ return unless $self->data->{remaining}->{ $group };
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"remaining"}{$group} 6 210 216
407  
408 210 my @hosts = $self->_sort_servers( $group, keys %{ $self->data->{remaining}->{ $group } } );
409 210 return @hosts;
410 }
411  
412 867 ▶sub _sort_servers {
Subroutine _sort_servers: called CC=1 SCAR=0.0
413 867 my ( $self, $group, @servers ) = @_;
414  
415 # sort servers based on original insertion order
416 867 @servers = sort { $self->sort_order->{$group}->{$a} <=> $self->sort_order->{$group}->{$b} } @servers;
417  
418 867 return @servers;
419 }
420  
421 144 ▶sub _reserve_remaining_server {
Subroutine _reserve_remaining_server: called CC=4 SCAR=13.9
422 144 my ( $self, $group ) = @_;
423  
424 144 ▶ if ( $self->_get_remaining_servers( $group ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_get_remaining_servers($group)) 144 0 144
425 144 my $server = ( $self->_sort_servers( $group, keys %{ $self->data->{remaining}->{ $group } } ) )[0];
426 144 delete $self->data->{remaining}->{ $group }->{$server};
427 144 $logger->debug( "Reserving ($group) $server" );
428  
429 # delete remaining data structure as groups are completed
430 144 ▶ unless ( scalar keys %{ $self->data->{remaining}->{ $group } } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %{$self->data->{"remaining"}{$group};}) 15 129 144
431 15 $logger->debug( "Group empty: $group" );
432 15 delete $self->data->{remaining}->{ $group };
433 15 ▶ unless ( scalar ( keys %{ $self->data->{remaining} } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %{$self->data->{"remaining"};}) 12 3 15
434 12 $logger->debug( "No servers remaining" );
435 12 delete $self->data->{remaining};
436 }
437 }
438 144 return $server;
439 }
440 }
441  
442 276 ▶sub _get_remaining_groups {
Subroutine _get_remaining_groups: called CC=3 SCAR=11.0
443 276 my ( $self ) = @_;
444 276 ▶ return unless $self->data->{remaining};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data->{"remaining"} 5 271 276
445 271 my @keys = sort keys %{ $self->data->{remaining} };
446 271 ▶ return unless scalar @keys;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @keys 10 261 271
447 261 return @keys;
448 }
449  
450 163 ▶sub _mark_available {
Subroutine _mark_available: called CC=4 SCAR=13.9
451 163 my ( $self, $group, $server ) = @_;
452  
453 # only the initial transfer to each dc comes from localhost. iff
454 # first transfer (from localhost) succeeded, then don't reschedule
455 # for future syncs
456 163 ▶ if ( $server eq "localhost" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server eq "localhost") 34 129 163
457  
458 34 ▶ if ( $self->data->{completed}->{ $group } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"completed"}{$group}) 34 0 34
459  
460 34 delete $self->data->{available}->{ $group }->{$server};
461 34 return;
462 }
463 }
464  
465 129 $logger->debug( "Server available: ($group) $server" );
466 129 $self->data->{available}->{ $group }->{$server} = 1;
467  
468 # reduce count of number of active processes on this server
469 129 ▶ if ( $self->children->{$server} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->children->{$server}) 48 81 129
470 48 $self->children->{$server}--;
471 }
472 }
473  
474 0 ▶sub _mark_remaining {
Subroutine _mark_remaining: not called CC=1 SCAR=6.9
475 0 my ( $self, $group, $server ) = @_;
476  
477 0 $logger->debug( "Server remaining: ($group) $server" );
478 0 $self->data->{remaining}->{ $group }->{$server} = 1;
479 }
480  
481 81 ▶sub _mark_completed {
Subroutine _mark_completed: called CC=1 SCAR=0.0
482 81 my ( $self, $group, $server ) = @_;
483  
484 81 $logger->debug( "Server completed: ($group) $server" );
485 81 push @{ $self->data->{completed}->{ $group } }, $server;
486 }
487  
488 2 ▶sub _mark_failed {
Subroutine _mark_failed: called CC=2 SCAR=6.9
489 2 my ( $self, $group, $server, $fatal ) = @_;
490  
491 2 $logger->debug( "Server failed: ($group) $server" );
492  
493 2 ▶ if ( $fatal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fatal) { } 1 1 2
494 1 $self->data->{failed}->{ $group }->{ $server } = $self->max_failures;
495 }
496 else {
497 1 $self->data->{failed}->{ $group }->{ $server }++;
498 }
499  
500 2 my $failures = $self->data->{failed}->{ $group }->{ $server };
501 2 $logger->debug( "$failures failures for ($group) $server" );
502 2 return $failures;
503 }
504  
505 89 ▶sub _get_failed_count {
Subroutine _get_failed_count: called CC=5 SCAR=16.2
506 89 my ( $self, $group ) = @_;
507  
508 89 my $errors = 0;
509 89 my $failures = 0;
510  
511 89 ▶ if ( $self->data->{failed} && $self->data->{failed}->{ $group } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"failed"} and $self->data->{"failed"}{$group}) 2 87 89
Condition66%2/3
$self->data->{"failed"} and $self->data->{"failed"}{$group}
!ll&&!rl&&r
8702
MC/DC50%1/2
$self->data->{"failed"} and $self->data->{"failed"}{$group}
$self->data->{"failed"} $self->data->{"failed"}{$group}
Truth table66%2/3
A and B
A= $self->data->{"failed"}B= $self->data->{"failed"}{$group}
ABresult
0X0
100
111
512 2 for my $server ( keys %{ $self->data->{failed}->{ $group }} ) {
513 2 $errors += $self->data->{failed}->{ $group }->{ $server };
514 2 ▶ if ( $self->data->{failed}->{ $group }->{ $server } >= $self->max_failures ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->data->{"failed"}{$group}{$server} >= $self->max_failures) 2 0 2
515 2 $failures++;
516 }
517 }
518 }
519  
520 89 return ( $errors, $failures );
521 }
522  
523 # tracing all the attempted transfers
524 16 ▶sub get_transfer_map {
Subroutine get_transfer_map: called CC=1 SCAR=0.0
Pod documented
525 16 my ( $self ) = @_;
526  
527 16 return $self->transfer_map;
528 }
529  
530  
531 34 1;
532  
533 __END__
↑ Summary