File Coverage

blib/lib/MooseFS/Info.pm
Criterion Covered Total %
statement 12 34 35.2
branch 0 8 0.0
condition 0 12 0.0
subroutine 4 6 66.6
pod 0 1 0.0
total 16 61 26.2


line stmt bran cond sub pod time code
1             package MooseFS::Info;
2 1     1   75830 use strict;
  1         3  
  1         34  
3 1     1   6 use warnings;
  1         3  
  1         30  
4 1     1   1104 use IO::Socket::INET;
  1         34006  
  1         8  
5 1     1   1692 use Moo;
  1         20367  
  1         7  
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)>', 510, 0);
13 0           my $header = $self->myrecv($s, 8);
14 0           my ($cmd, $length) = unpack('(LL)>', $header);
15 0 0 0       if ($cmd == 511 and $length == 52) {
    0 0        
    0 0        
    0 0        
16 0           my $data = $self->myrecv($s, $length);
17 0           my ($total, $avail, $trspace, $trfiles, $respace, $refiles, $nodes, $chunks, $tdcopies) = unpack("(QQQLQLLLL)>", $data);
18 0           $self->info({
19             total_space => $total,
20             avail_space => $avail,
21             trash_space => $trspace,
22             trash_files => $trfiles,
23             reserved_space => $respace,
24             reserved_files => $refiles,
25             all_fs_objects => $nodes,
26             chunks => $chunks,
27             regular_chunk_copies => $tdcopies,
28             });
29             } elsif ($cmd == 511 and $length == 60) {
30 0           my $data = $self->myrecv($s, $length);
31 0           my ($total, $avail, $trspace, $trfiles, $respace, $refiles, $nodes, $dirs, $files, $chunks, $tdcopies) = unpack("(QQQLQLLLLLL)>", $data);
32 0           $self->info({
33             total_space => $total,
34             avail_space => $avail,
35             trash_space => $trspace,
36             trash_files => $trfiles,
37             reserved_space => $respace,
38             reserved_files => $refiles,
39             all_fs_objects => $nodes,
40             directories => $dirs,
41             files => $files,
42             chunks => $chunks,
43             regular_chunk_copies => $tdcopies,
44             });
45             } elsif ($cmd == 511 and $length == 68) {
46 0           my $data = $self->myrecv($s, $length);
47 0           my ($v1, $v2, $v3, $total, $avail, $trspace, $trfiles, $respace, $refiles, $nodes, $dirs, $files, $chunks, $allcopies, $tdcopies) = unpack("(SCCQQQLQLLLLLLL)>", $data);
48 0           $self->info({
49             version => "$v1.$v2.$v3",
50             total_space => $total,
51             avail_space => $avail,
52             trash_space => $trspace,
53             trash_files => $trfiles,
54             reserved_space => $respace,
55             reserved_files => $refiles,
56             all_fs_objects => $nodes,
57             directories => $dirs,
58             files => $files,
59             chunks => $chunks,
60             all_chunk_copies => $allcopies,
61             regular_chunk_copies => $tdcopies,
62             });
63             } elsif ($cmd == 511 and $length == 76) {
64 0           my $data = $self->myrecv($s, $length);
65 0           my ($v1, $v2, $v3, $memusage, $total, $avail, $trspace, $trfiles, $respace, $refiles, $nodes, $dirs, $files, $chunks, $allcopies, $tdcopies) = unpack('(SCCQQQQLQLLLLLLL)>', $data);
66 0           $self->info({
67             version => "$v1.$v2.$v3",
68             total_space => $total,
69             avail_space => $avail,
70             trash_space => $trspace,
71             trash_files => $trfiles,
72             reserved_space => $respace,
73             reserved_files => $refiles,
74             all_fs_objects => $nodes,
75             directories => $dirs,
76             files => $files,
77             chunks => $chunks,
78             all_chunk_copies => $allcopies,
79             regular_chunk_copies => $tdcopies,
80             memusage => $memusage,
81             });
82             };
83 0           for my $key ( keys %{ $self->info } ) {
  0            
84 0     0     has $key => (is => 'ro', lazy => 1, default => sub {$self->info->{$key}} );
  0            
85             };
86             };
87              
88             1;