File Coverage

blib/lib/MooseFS/CheckInfo.pm
Criterion Covered Total %
statement 12 34 35.2
branch 0 8 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 0 1 0.0
total 16 52 30.7


line stmt bran cond sub pod time code
1             package MooseFS::CheckInfo;
2 1     1   72584 use strict;
  1         2  
  1         40  
3 1     1   6 use warnings;
  1         2  
  1         27  
4 1     1   1116 use IO::Socket::INET;
  1         41690  
  1         11  
5 1     1   2470 use Moo;
  1         28652  
  1         8  
6              
7             extends 'MooseFS';
8              
9             sub BUILD {
10 0     0 0   my $self = shift;
11 0           my $s = $self->sock;
12 0           print $s pack('(LL)>', 512, 0);
13 0           my $header = $self->myrecv($s, 8);
14 0           my ($cmd, $length) = unpack('(LL)>', $header);
15 0 0 0       if ( $cmd == 513 and $length >= 36 ) {
16 0           my $data = $self->myrecv($s, $length);
17 0           my $d = substr($data, 0, 36);
18 0           my ($loopstart, $loopend, $files, $ugfiles, $mfiles, $chunks, $ugchunks, $mchunks, $msgbuffleng) = unpack('(LLLLLLLLL)>', $d);
19 0           my ($messages, $truncated);
20 0 0         if ($loopstart > 0) {
21 0 0         if ($msgbuffleng > 0 ) {
22 0 0         if ($msgbuffleng == 100000) {
23 0           $truncated = 'first 100k';
24             } else {
25 0           $truncated = 'no';
26             };
27 0           $messages = substr($data, 36);
28             };
29             } else {
30 0           $messages = 'no data';
31             };
32 0           $self->info({
33             check_loop_start_time => $loopstart,
34             check_loop_end_time => $loopend,
35             files => $files,
36             under_goal_files => $ugfiles,
37             missing_files => $mfiles,
38             chunks => $chunks,
39             under_goal_chunks => $ugchunks,
40             missing_chunks => $mchunks,
41             msgbuffleng => $msgbuffleng,
42             important_messages => $messages,
43             truncated => $truncated,
44             });
45             }
46 0           for my $key ( keys %{ $self->info } ) {
  0            
47 0     0     has $key => (is => 'ro', lazy => 1, default => sub {$self->info->{$key}} );
  0            
48             };
49             }
50              
51             1;