line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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::StorageUnit; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
71
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use NBU::Media; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
1
|
|
|
1
|
|
14
|
use Exporter (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
15
|
1
|
|
|
1
|
|
4
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
16
|
1
|
|
|
1
|
|
42
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
160
|
|
17
|
1
|
|
|
1
|
|
2
|
$VERSION = do { my @r=(q$Revision: 1.21 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
14
|
|
18
|
1
|
|
|
|
|
22
|
@ISA = qw(); |
19
|
1
|
|
|
|
|
2
|
@EXPORT = qw(); |
20
|
1
|
|
|
|
|
6
|
@EXPORT_OK = qw(); |
21
|
1
|
|
|
|
|
1412
|
%EXPORT_TAGS = qw(); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %stuList; |
25
|
|
|
|
|
|
|
my %populated; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %types = ( |
28
|
|
|
|
|
|
|
1 => "Disk", |
29
|
|
|
|
|
|
|
2 => "Media Manager", |
30
|
|
|
|
|
|
|
3 => "NDMP", |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
35
|
0
|
|
|
|
|
|
my $stu = {}; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
bless $stu, $proto; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if (@_) { |
40
|
0
|
|
|
|
|
|
$stu->{LABEL} = shift; |
41
|
0
|
|
|
|
|
|
my $type; |
42
|
0
|
0
|
0
|
|
|
|
if (@_ && exists($types{$type = shift})) { |
43
|
0
|
|
|
|
|
|
$stu->{TYPE} = $types{$type}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
0
|
|
|
|
|
|
$stu->{TYPE} = $type; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$stuList{$stu->{LABEL}} = $stu; |
51
|
0
|
|
|
|
|
|
return $stu; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub populate { |
55
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
56
|
0
|
|
|
|
|
|
my $targetMaster = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if (!defined($targetMaster)) { |
59
|
0
|
|
|
|
|
|
my @masters = NBU->masters; $targetMaster = $masters[0]; |
|
0
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$populated{$targetMaster->name} = 0; |
63
|
0
|
|
|
|
|
|
my $pipe = NBU->cmd("bpstulist -M ".$targetMaster->name." |"); |
64
|
0
|
|
|
|
|
|
while (<$pipe>) { |
65
|
0
|
|
|
|
|
|
my ($label, $type, $hostName, |
66
|
|
|
|
|
|
|
$robotType, $robotNumber, $density, |
67
|
|
|
|
|
|
|
$count, |
68
|
|
|
|
|
|
|
$maxFragmentSize, |
69
|
|
|
|
|
|
|
$path, |
70
|
|
|
|
|
|
|
$onDemand, |
71
|
|
|
|
|
|
|
$maxMPXperDrive, |
72
|
|
|
|
|
|
|
$ndmpAttachHostName, |
73
|
|
|
|
|
|
|
) = split; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $stu; |
76
|
0
|
|
|
|
|
|
$stu = NBU::StorageUnit->new($label); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$stu->{TYPE} = $type; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$stu->{MASTER} = $targetMaster; |
81
|
0
|
0
|
|
|
|
|
if ($hostName !~ /_STU_NO_DEV_HOST/) { |
82
|
0
|
|
|
|
|
|
my $mm = $stu->{HOST} = NBU::Host->new($hostName); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$mm->mediaManager(1); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
# If this is a robot storage unit, we inform the robot so it can know which storage units |
88
|
|
|
|
|
|
|
# make use of its services. |
89
|
0
|
0
|
|
|
|
|
if (defined(my $robot = $stu->{ROBOT} = NBU::Robot->new($robotNumber, $robotType, undef))) { |
90
|
0
|
|
|
|
|
|
$mm->roboticMediaManager(1); |
91
|
0
|
|
|
|
|
|
$robot->known($stu); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ($type == 1) { |
|
|
0
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$stu->{CONCURRENTJOBS} = $count; |
99
|
0
|
|
|
|
|
|
$stu->{PATH} = $path; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
elsif ($type == 2) { |
102
|
0
|
|
|
|
|
|
$stu->{DRIVECOUNT} = $count; |
103
|
0
|
|
|
|
|
|
$stu->{DENSITY} = $density; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$stu->{ONDEMAND} = $onDemand; |
107
|
0
|
|
|
|
|
|
$stu->{MAXMPX} = $maxMPXperDrive; |
108
|
0
|
|
|
|
|
|
$stu->{MAXFRAGSIZE} = $maxFragmentSize; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$populated{$targetMaster->name} += 0; |
111
|
|
|
|
|
|
|
} |
112
|
0
|
|
|
|
|
|
close($pipe); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub list { |
117
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
118
|
0
|
|
|
|
|
|
my $targetMaster = shift; |
119
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
if (!defined($targetMaster)) { |
121
|
0
|
|
|
|
|
|
for my $master (NBU->masters) { |
122
|
0
|
0
|
|
|
|
|
$proto->populate($master) if (!exists($populated{$master->name})); |
123
|
|
|
|
|
|
|
} |
124
|
0
|
|
|
|
|
|
return (values %stuList); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
else { |
127
|
0
|
0
|
|
|
|
|
$proto->populate($targetMaster) if (!exists($populated{$targetMaster->name})); |
128
|
0
|
|
|
|
|
|
my @list; |
129
|
0
|
|
|
|
|
|
for my $su (values %stuList) { |
130
|
0
|
0
|
0
|
|
|
|
push @list, $su if (defined($su->master) && ($su->master == $targetMaster)); |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
return (@list); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub byLabel { |
137
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
138
|
0
|
|
|
|
|
|
my $label = shift; |
139
|
0
|
|
|
|
|
|
my $targetMaster = shift; |
140
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
return $stuList{$label} if (exists($stuList{$label})); |
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
|
if (!defined($targetMaster)) { |
144
|
0
|
|
|
|
|
|
for my $master (NBU->masters) { |
145
|
0
|
0
|
|
|
|
|
$proto->populate($master) if (!exists($populated{$master->name})); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
else { |
149
|
0
|
0
|
|
|
|
|
$proto->populate($targetMaster) if (!exists($populated{$targetMaster->name})); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
if (!exists($stuList{$label})) { |
153
|
0
|
|
|
|
|
|
my $stu = $proto->new($label); |
154
|
0
|
|
|
|
|
|
$stu->{MASTER} = $targetMaster; |
155
|
|
|
|
|
|
|
} |
156
|
0
|
|
|
|
|
|
return $stuList{$label}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub master { |
160
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
return $self->{MASTER}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub host { |
166
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
return $self->{HOST}; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# |
172
|
|
|
|
|
|
|
# Return a list of all media servers known to the target master. If no |
173
|
|
|
|
|
|
|
# target master is supplied, return all known media servers. |
174
|
|
|
|
|
|
|
sub mediaServers { |
175
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
176
|
0
|
|
|
|
|
|
my $targetMaster = shift; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
my %names; |
180
|
|
|
|
|
|
|
my @list; |
181
|
0
|
|
|
|
|
|
for my $su ($proto->list($targetMaster)) { |
182
|
0
|
0
|
|
|
|
|
next if (!defined($su->host)); |
183
|
|
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
if (!exists($names{$su->host->name})) { |
185
|
0
|
|
|
|
|
|
push @list, $su->host; |
186
|
|
|
|
|
|
|
} |
187
|
0
|
|
|
|
|
|
$names{$su->host->name} += 1; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
return (@list); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub type { |
194
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
return $self->{TYPE}; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub path { |
200
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
201
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
if (@_) { |
203
|
0
|
|
|
|
|
|
my $path = shift; |
204
|
0
|
|
|
|
|
|
$self->{PATH} = $path; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
return $self->{PATH}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub density { |
211
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
return $NBU::Media::densities{$self->{DENSITY}}; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub driveCount { |
217
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
return $self->{DRIVECOUNT}; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub label { |
223
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
return $self->{LABEL}; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub robot { |
229
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
230
|
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
return $self->{ROBOT}; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub onDemand { |
235
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
return $self->{ONDEMAND}; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# |
241
|
|
|
|
|
|
|
# NBU stores the maximum number of multiplexed jobs per storage unit but this routine |
242
|
|
|
|
|
|
|
# maps the degenerate case to 0 so a simple test for multi-plexing can be done on its |
243
|
|
|
|
|
|
|
# return value |
244
|
|
|
|
|
|
|
sub mpx { |
245
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
246
|
|
|
|
|
|
|
|
247
|
0
|
0
|
|
|
|
|
if ($self->{MAXPX} == 1) { |
248
|
0
|
|
|
|
|
|
return 0; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
else { |
251
|
0
|
|
|
|
|
|
return $self->{MAXMPX}; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub maximumFragmentSize { |
256
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
return $self->{MAXFRAGSIZE}; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
1; |
262
|
|
|
|
|
|
|
__END__ |