| 1 | # | ||||||||||
| 2 | # Copyright (c) 2002 Paul Winkeler. All Rights Reserved. | ||||||||||
| 3 | # This program is free software; you may redistribute it and/or modify it under | ||||||||||
| 4 | # the same terms as Perl itself. | ||||||||||
| 5 | # | ||||||||||
| 6 | package NBU::Mount; | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use NBU::Drive; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use NBU::Path; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | $VERSION = do { my @r=(q$Revision: 1.13 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; | |||||||||
| 19 | 1 | @ISA = qw(); | |||||||||
| 20 | 1 | @EXPORT = qw(); | |||||||||
| 21 | 1 | @EXPORT_OK = qw(); | |||||||||
| 22 | 1 | %EXPORT_TAGS = qw(); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 26 | 0 | my $class = shift; | |||||||||
| 27 | 0 | my $mount = { | |||||||||
| 28 | }; | ||||||||||
| 29 | |||||||||||
| 30 | 0 | bless $mount, $class; | |||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | my ($job, $volume, $drive, $tm) = @_; | |||||||||
| 34 | |||||||||||
| 35 | # | ||||||||||
| 36 | # The bpdbjobs output, for example, is devoid of drive | ||||||||||
| 37 | # references hence we may not be able to record an actual | ||||||||||
| 38 | # mount event at this time... | ||||||||||
| 39 | 0 | ▶ | if (defined($drive)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | $mount->drive($drive)->use($mount, $tm); | |||||||||
| 41 | 0 | $volume->mount($mount, $drive, $tm); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | $mount->{JOB} = $job; | |||||||||
| 45 | 0 | $mount->{TARGET} = $volume; | |||||||||
| 46 | 0 | $mount->{MOUNTTIME} = $tm; | |||||||||
| 47 | 0 | ▶ | $mount->{MOUNTDELAY} = $tm - $volume->selected | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | if ($volume->selected); | ||||||||||
| 49 | |||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | return $mount; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub job { | ||||||||
|
Subroutine
job: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | |||||||||||
| 58 | 0 | return $self->{JOB}; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub unmount { | ||||||||
|
Subroutine
unmount: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 62 | 0 | my $self = shift; | |||||||||
| 63 | 0 | my $job = $self->{JOB}; | |||||||||
| 64 | |||||||||||
| 65 | 0 | my $tm = $self->{UNMOUNTTIME} = shift; | |||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | if (defined($job->mount)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 0 | ▶ | if ($job->mount == $self) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | $job->mount(undef); | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | $self->drive->free($tm, $self->usedBy) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | if ($self->drive); | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | return $self->{UNMOUNTTIME}; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub start { | ||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 81 | 0 | my $self = shift; | |||||||||
| 82 | |||||||||||
| 83 | 0 | return $self->{MOUNTTIME}; | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | sub stop { | ||||||||
|
Subroutine
stop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 87 | 0 | my $self = shift; | |||||||||
| 88 | |||||||||||
| 89 | 0 | return $self->{UNMOUNTTIME}; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 0 | ▶ | sub startPositioning { | ||||||||
|
Subroutine
startPositioning: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 93 | 0 | my $self = shift; | |||||||||
| 94 | 0 | my $fileNumber = shift; | |||||||||
| 95 | 0 | my $tm = shift; | |||||||||
| 96 | |||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 0 | ▶ | sub positioned { | ||||||||
|
Subroutine
positioned: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 100 | 0 | my $self = shift; | |||||||||
| 101 | 0 | my $tm = shift; | |||||||||
| 102 | |||||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | sub mountPoint { | ||||||||
|
Subroutine
mountPoint: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 106 | 0 | my $self = shift; | |||||||||
| 107 | |||||||||||
| 108 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | 0 | $self->{MP} = shift; | |||||||||
| 110 | } | ||||||||||
| 111 | 0 | return $self->{MP}; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | sub drive { | ||||||||
|
Subroutine
drive: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 115 | 0 | my $self = shift; | |||||||||
| 116 | |||||||||||
| 117 | 0 | return $self->mountPoint(@_); | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub path { | ||||||||
|
Subroutine
path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 121 | 0 | my $self = shift; | |||||||||
| 122 | |||||||||||
| 123 | 0 | return $self->mountPoint(@_); | |||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | 0 | ▶ | sub target { | ||||||||
|
Subroutine
target: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 127 | 0 | my $self = shift; | |||||||||
| 128 | |||||||||||
| 129 | 0 | return $self->{TARGET}; | |||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | 0 | ▶ | sub volume { | ||||||||
|
Subroutine
volume: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 133 | 0 | my $self = shift; | |||||||||
| 134 | |||||||||||
| 135 | 0 | return $self->target(@_); | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | 0 | ▶ | sub file { | ||||||||
|
Subroutine
file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 139 | 0 | my $self = shift; | |||||||||
| 140 | |||||||||||
| 141 | 0 | return $self->target(@_); | |||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | 0 | ▶ | sub usedBy { | ||||||||
|
Subroutine
usedBy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 145 | 0 | my $self = shift; | |||||||||
| 146 | |||||||||||
| 147 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 0 | $self->{USEDBY} = shift; | |||||||||
| 149 | } | ||||||||||
| 150 | 0 | return $self->{USEDBY}; | |||||||||
| 151 | } | ||||||||||
| 152 | |||||||||||
| 153 | 0 | ▶ | sub read { | ||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 154 | 0 | my $self = shift; | |||||||||
| 155 | |||||||||||
| 156 | 0 | my ($fragmentNumber, $size, $speed) = @_; | |||||||||
| 157 | |||||||||||
| 158 | 0 | $self->{FRAGMENT} = $fragmentNumber; | |||||||||
| 159 | |||||||||||
| 160 | # | ||||||||||
| 161 | # Grow size and keep running average speed | ||||||||||
| 162 | 0 | $self->{SIZE} += $size; | |||||||||
| 163 | 0 | $self->{READINGTIME} += ($size / $speed); | |||||||||
| 164 | 0 | $self->{SPEED} = $self->{SIZE} / $self->{READINGTIME}; | |||||||||
| 165 | |||||||||||
| 166 | 0 | $self->volume->read($size, $speed); | |||||||||
| 167 | |||||||||||
| 168 | 0 | return $self; | |||||||||
| 169 | } | ||||||||||
| 170 | |||||||||||
| 171 | 0 | ▶ | sub write { | ||||||||
|
Subroutine
write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 172 | 0 | my $self = shift; | |||||||||
| 173 | |||||||||||
| 174 | 0 | my ($fragmentNumber, $size, $speed) = @_; | |||||||||
| 175 | |||||||||||
| 176 | 0 | $self->{FRAGMENT} = $fragmentNumber; | |||||||||
| 177 | |||||||||||
| 178 | # | ||||||||||
| 179 | # Grow size and keep running average speed | ||||||||||
| 180 | 0 | $self->{SIZE} += $size; | |||||||||
| 181 | 0 | $self->{WRITINGTIME} += ($size / $speed); | |||||||||
| 182 | 0 | $self->{SPEED} = $self->{SIZE} / $self->{WRITINGTIME}; | |||||||||
| 183 | |||||||||||
| 184 | 0 | $self->volume->write($size, $speed); | |||||||||
| 185 | |||||||||||
| 186 | 0 | return $self; | |||||||||
| 187 | } | ||||||||||
| 188 | |||||||||||
| 189 | 0 | ▶ | sub speed { | ||||||||
|
Subroutine
speed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 190 | 0 | my $self = shift; | |||||||||
| 191 | |||||||||||
| 192 | 0 | return $self->{SPEED}; | |||||||||
| 193 | } | ||||||||||
| 194 | |||||||||||
| 195 | 0 | ▶ | sub writeTime { | ||||||||
|
Subroutine
writeTime: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 196 | 0 | my $self = shift; | |||||||||
| 197 | |||||||||||
| 198 | 0 | ▶ | if (my $speed = $self->{SPEED}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 199 | 0 | my $size = $self->{SIZE}; | |||||||||
| 200 | 0 | return ($size / $speed); | |||||||||
| 201 | } | ||||||||||
| 202 | 0 | return undef; | |||||||||
| 203 | } | ||||||||||
| 204 | |||||||||||
| 205 | 0 | ▶ | sub dataRead { | ||||||||
|
Subroutine
dataRead: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 206 | 0 | my $self = shift; | |||||||||
| 207 | |||||||||||
| 208 | 0 | return $self->data(@_); | |||||||||
| 209 | } | ||||||||||
| 210 | |||||||||||
| 211 | 0 | ▶ | sub dataWritten { | ||||||||
|
Subroutine
dataWritten: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 212 | 0 | my $self = shift; | |||||||||
| 213 | |||||||||||
| 214 | 0 | return $self->data(@_); | |||||||||
| 215 | } | ||||||||||
| 216 | |||||||||||
| 217 | 0 | ▶ | sub data { | ||||||||
|
Subroutine
data: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 218 | 0 | my $self = shift; | |||||||||
| 219 | |||||||||||
| 220 | 0 | return $self->{SIZE}; | |||||||||
| 221 | } | ||||||||||
| 222 | |||||||||||
| 223 | 1 | 1; | |||||||||
| 224 | |||||||||||
| 225 | __END__ | ||||||||||