lib/Lustre/Info/Export.pm

filter: Statementstmt 11.1% 7 / 63 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 20.0% 2 / 10 Podpod 62.5% 5 / 8 totaltotal 13.0% 14 / 107 CC 17 SCAR 37.1
CC
17
Cov
8%
get_brw_stats
90.0
collect_brw_stats
30.0
collect_export_stats
20.0
CRAP 40.8
↑ Summary lib/Lustre/Info/OST.pm »
1 #
2 # Lustre NID/export Subclass
3 #
4 # (C) 2010 Adrian Ulrich - <adrian.ulrich@id.ethz.ch>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the same terms as Perl itself.
8 #
9 #
10 package Lustre::Info::Export;
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 ##########################################################################
16 # Returns a new Export Object
17 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
18 0 my($classname, %args) = @_;
19 0 my $self = { super=>$args{super}, export=>$args{export}, export_stats=>{}, graph_stats=>[{},{}] };
20 0 bless($self,$classname);
21 }
22  
23 ##########################################################################
24 # Return name of this nid
25 0 ▶sub get_name {
Subroutine get_name: not called CC=1 SCAR=6.9
Pod documented
26 0 my($self) = @_;
27 0 return $self->{export};
28 }
29  
30 ##########################################################################
31 # AB(uses) the OST-Module to get statistics for this client
32 0 ▶sub collect_export_stats {
Subroutine collect_export_stats: not called CC=4 SCAR=30.0
Pod documented
33 0 my($self, $ostlist) = @_;
34
35 0 ▶ $ostlist = $self->{super}->get_ost_list if !$ostlist;
Branch: 1 branch
BranchTrueFalseTotal
unless $ostlist 0 0 0
36
37 0 foreach my $ost (@$ostlist) {
38 0 ▶ $self->{export_stats}->{$ost} ||= $self->{super}->get_ost($ost); # Creates a new ost-object if empty
Condition0%0/3
$self->{"export_stats"}{$ost} ||= $self->{"super"}->get_ost($ost)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"export_stats"}{$ost} ||= $self->{"super"}->get_ost($ost)
$self->{"export_stats"}{$ost} $self->{"super"}->get_ost($ost)
Truth table0%0/3
A ||= B
A= $self->{"export_stats"}{$ost}B= $self->{"super"}->get_ost($ost)
ABresult
1X1
011
000
39 0 $self->{export_stats}->{$ost}->collect_client_stats([$self->get_name]); # collect stats for this-client only
40 }
41
42 0 return undef;
43 }
44  
45 ##########################################################################
46 # Return per-ost statistics of this NID/EXPORT
47 0 ▶sub get_export_stats {
Subroutine get_export_stats: not called CC=2 SCAR=17.9
Pod documented
48 0 my($self) = @_;
49
50 0 my $es = $self->{export_stats};
51 0 my $r = {};
52 0 foreach my $ost_name (keys(%$es)) {
53 0 my $ost_ref = $es->{$ost_name};
54 0 my $stats = $ost_ref->get_client_stats;
55 0 $r->{$ost_name} = $stats->{$self->get_name};
56 }
57 0 return $r;
58 }
59  
60 ##########################################################################
61 # Undocumented alias for get_export_stats
62 0 ▶sub get_client_stats {
Subroutine get_client_stats: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my($self) = @_;
64 0 return $self->get_export_stats;
65 }
66  
67 ##########################################################################
68 # undocumented alias for collect_export_stats
69 0 ▶sub collect_client_stats {
Subroutine collect_client_stats: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my($self) = @_;
71 0 return $self->collect_export_stats;
72 }
73  
74 0 ▶sub collect_brw_stats {
Subroutine collect_brw_stats: not called CC=5 SCAR=34.0
Pod documented
75 0 my($self, $ostlist) = @_;
76
77 0 ▶ $ostlist = $self->{super}->get_ost_list if !$ostlist;
Branch: 1 branch
BranchTrueFalseTotal
unless $ostlist 0 0 0
78
79 0 my $own_name = $self->get_name;
80 0 my $tstamp = 0;
81 0 my $junk = {};
82 0 foreach my $ost (@$ostlist) {
83 0 my $pfs_file = "/proc/fs/lustre/obdfilter/$ost/exports/$own_name/brw_stats";
84 0 ▶ next unless -f $pfs_file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $pfs_file 0 0 0
85 0 my $ref = $self->{super}->_parse_brw_file($pfs_file);
86 0 ▶ $tstamp ||= $ref->{timestamp};
Condition0%0/3
$tstamp ||= $ref->{"timestamp"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tstamp ||= $ref->{"timestamp"}
$tstamp $ref->{"timestamp"}
Truth table0%0/3
A ||= B
A= $tstampB= $ref->{"timestamp"}
ABresult
1X1
011
000
87 0 $junk = $self->{super}->sum_up_deep(2, $ref->{data}, $junk);
88 }
89
90 0 $junk->{timestamp} = $tstamp; # Add first timestamp to ref (as expected by get_*_stats)
91
92 0 my $stats_ref = $self->{graph_stats};
93 0 shift(@$stats_ref);
94 0 push(@$stats_ref, $junk);
95 0 return $junk;
96 }
97  
98 0 ▶sub get_brw_stats {
Subroutine get_brw_stats: not called CC=9 SCAR=45.0
Pod documented
99 0 my($self) = @_;
100
101 0 my $r1 = $self->{graph_stats}->[0];
102 0 my $r2 = $self->{graph_stats}->[1];
103 0 ▶ my $ts1 = $r1->{timestamp} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $ts1 = $r1->{"timestamp"} or return undef 0 0 0
104 0 ▶ my $ts2 = $r2->{timestamp} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $ts2 = $r2->{"timestamp"} or return undef 0 0 0
105 0 my $junk = {};
106
107 0 foreach my $label (keys(%$r1)) {
108 0 my $rx = $r1->{$label};
109 0 ▶ next if ref($rx) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $rx ne "HASH" 0 0 0
110 0 ▶ next if !exists($r2->{$label});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r2->{$label} 0 0 0
111
112 0 foreach my $line (keys(%$rx)) {
113 0 ▶ next if !exists($r2->{$label}->{$line});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r2->{$label}{$line} 0 0 0
114 0 foreach my $action (keys(%{$rx->{$line}})) {
115 0 my $value = $r2->{$label}->{$line}->{$action} - $r1->{$label}->{$line}->{$action};
116 0 $junk->{$label}->{$line}->{$action} = $value;
117 }
118 }
119 }
120 0 return({_slice=>($ts2-$ts1), data=>$junk});
121 }
122  
123  
124 1 1;
125 __END__
↑ Summary lib/Lustre/Info/OST.pm »