MooseFS/Server.pm

filter: Statementstmt 44.7% 17 / 38 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 1 totaltotal 36.2% 21 / 58 CC 6 SCAR 30.0
CC
6
Cov
36%
BUILD
42.0
__ANON__
2.0
__ANON__
2.0
CRAP 20.2
« MooseFS/CheckInfo.pm ↑ Summary MooseFS.pm »
1 package MooseFS::Server;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 extends 'MooseFS';
8  
9 has count => (
10 is => 'rw',
11 0 ▶ default => sub { 0 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
12 2 );
13  
14 has list => (
15 is => 'rw',
16 0 ▶ default => sub { [] }
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 2 );
18  
19 has info => (
20 is => 'rw',
21 0 ▶ default => sub { {} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 2 );
23  
24 0 ▶sub BUILD {
Subroutine BUILD: not called CC=6 SCAR=37.4
Pod undocumented
25 0 my $self = shift;
26 0 my $s = $self->sock;
27 0 print $s pack('(LL)>', 500, 0);
28 0 my $header = $self->myrecv($s, 8);
29 0 my ($cmd, $length) = unpack('(LL)>', $header);
30 0 ▶ if ( $cmd == 501 and $length % 54 == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd == 501 and $length % 54 == 0) 0 0 0
Condition0%0/3
$cmd == 501 and $length % 54 == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd == 501 and $length % 54 == 0
$cmd == 501 $length % 54 == 0
Truth table0%0/3
A and B
A= $cmd == 501B= $length % 54 == 0
ABresult
0X0
100
111
31 0 my $data = $self->myrecv($s, $length);
32 0 my $count = $length / 54;
33 0 $self->count($count);
34 0 for my $num ( 0 .. $count - 1 ) {
35 0 my $d = substr($data, $num*54, 54);
36 0 my ($v1, $v2, $v3, $ip1, $ip2, $ip3, $ip4, $port, $used, $total, $chunks, $tdused, $tdtotal, $tdchunks, $errcnt) = unpack('(SCCCCCCSQQLQQLL)>', $d);
37 0 ▶ my $percent = $total > 0 ? ($used * 100)/$total : '';
Branch: 1 branch
BranchTrueFalseTotal
$total > 0 ? : 0 0 0
38 0 ▶ my $tdpercent = $tdtotal > 0 ? ($tdused * 100)/$tdtotal : '';
Branch: 1 branch
BranchTrueFalseTotal
$tdtotal > 0 ? : 0 0 0
39 0 my $ip = "$ip1.$ip2.$ip3.$ip4";
40 0 push @{$self->list}, $ip;
41 0 $self->info->{$ip} = {
42 version => "$v1.$v2.$v3",
43 port => $port,
44 used => $used,
45 total => $total,
46 chunks => $chunks,
47 percent_used => $percent,
48 tdused => $tdused,
49 tdtotal => $tdtotal,
50 tdchunks => $tdchunks,
51 tdpercent_used => $tdpercent,
52 errcnt => $errcnt,
53 };
54 }
55 }
56 }
57  
58 2 1;
« MooseFS/CheckInfo.pm ↑ Summary MooseFS.pm »