| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# See copyright, etc in below POD section. |
|
2
|
|
|
|
|
|
|
###################################################################### |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Schedule::Load::Hold; |
|
5
|
|
|
|
|
|
|
require 5.004; |
|
6
|
1
|
|
|
1
|
|
4
|
use Schedule::Load; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Sys::Hostname; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4552
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
43
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION $AUTOLOAD); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
545
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
###################################################################### |
|
14
|
|
|
|
|
|
|
#### Configuration Section |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = '3.064'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
###################################################################### |
|
19
|
|
|
|
|
|
|
#### Creators |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
|
22
|
4
|
|
|
4
|
0
|
20
|
my $proto = shift; |
|
23
|
4
|
|
33
|
|
|
27
|
my $class = ref($proto) || $proto; |
|
24
|
4
|
|
|
|
|
48
|
my $self = { |
|
25
|
|
|
|
|
|
|
req_hostname=>hostname(),# Host making the request |
|
26
|
|
|
|
|
|
|
req_pid=>$$, # Process ID making the request |
|
27
|
|
|
|
|
|
|
req_time=>time(), # When the request was issued |
|
28
|
|
|
|
|
|
|
req_user=>$ENV{USER}, # User name |
|
29
|
|
|
|
|
|
|
req_pri=>0, # Request priority, maybe negative for better |
|
30
|
|
|
|
|
|
|
hold_key=>undef, # Key for looking up the request |
|
31
|
|
|
|
|
|
|
hold_load=>1, # Load to apply to the host |
|
32
|
|
|
|
|
|
|
hold_time=>70, # Seconds to hold for |
|
33
|
|
|
|
|
|
|
comment=>"", # Information for printing |
|
34
|
|
|
|
|
|
|
allocated=>undef, # If set, chooser allocated this hold |
|
35
|
|
|
|
|
|
|
@_,}; |
|
36
|
4
|
|
|
|
|
113
|
bless $self, $class; |
|
37
|
4
|
50
|
|
|
|
101
|
$self->hold_key or carp "%Warning: No hold_key specified,"; |
|
38
|
4
|
|
|
|
|
14
|
return $self; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub set_fields { |
|
42
|
4
|
|
|
4
|
0
|
6
|
my $self = shift; |
|
43
|
4
|
|
|
|
|
50
|
my %params = (@_); |
|
44
|
4
|
|
|
|
|
7
|
foreach my $key (keys %{$self}) { |
|
|
4
|
|
|
|
|
28
|
|
|
45
|
40
|
100
|
|
|
|
115
|
$self->{$key} = $params{$key} if exists $params{$key}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
###################################################################### |
|
50
|
|
|
|
|
|
|
#### Special accessors |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
0
|
sub req_age { return (time() - $_[0]->req_time); } |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub compare_pri_time { |
|
55
|
|
|
|
|
|
|
# Sort comparison for ordering requests |
|
56
|
|
|
|
|
|
|
# This must return a consistent order, thus the hold_key is required as part of the compare. |
|
57
|
|
|
|
|
|
|
# For speed this doesn't use accessors - generally don't do this. |
|
58
|
0
|
|
0
|
0
|
0
|
0
|
return ($_[0]->{req_pri} <=> $_[1]->{req_pri} |
|
59
|
|
|
|
|
|
|
|| $_[0]->{req_time} <=> $_[1]->{req_time} |
|
60
|
|
|
|
|
|
|
|| $_[0]->{hold_key} cmp $_[1]->{hold_key}); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
###################################################################### |
|
64
|
|
|
|
|
|
|
#### Accessors |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
67
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
|
68
|
1
|
50
|
|
|
|
6
|
my $type = ref($self) or croak "$self is not an ".__PACKAGE__." object"; |
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
22
|
(my $field = $AUTOLOAD) =~ s/.*://; # Remove package |
|
71
|
1
|
50
|
|
|
|
7
|
if (exists ($self->{$field})) { |
|
72
|
1
|
|
|
3
|
1
|
73
|
eval "sub $field { return \$_[0]->{$field}; }"; |
|
|
3
|
|
|
|
|
17
|
|
|
73
|
1
|
|
|
|
|
11
|
return $self->{$field}; |
|
74
|
|
|
|
|
|
|
} else { |
|
75
|
0
|
|
|
|
|
0
|
croak "$type->$field: Unknown ".__PACKAGE__." field $field"; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
0
|
|
|
0
|
|
|
sub DESTROY {} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
###################################################################### |
|
81
|
|
|
|
|
|
|
###################################################################### |
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
__END__ |