line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package TheSchwartz::JobHandle; |
4
|
24
|
|
|
24
|
|
164
|
use strict; |
|
24
|
|
|
|
|
48
|
|
|
24
|
|
|
|
|
804
|
|
5
|
24
|
|
|
24
|
|
120
|
use base qw( Class::Accessor::Fast ); |
|
24
|
|
|
|
|
45
|
|
|
24
|
|
|
|
|
1909
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( dsn_hashed jobid client )); |
8
|
|
|
|
|
|
|
|
9
|
24
|
|
|
24
|
|
164
|
use TheSchwartz::ExitStatus; |
|
24
|
|
|
|
|
54
|
|
|
24
|
|
|
|
|
474
|
|
10
|
24
|
|
|
24
|
|
129
|
use TheSchwartz::Job; |
|
24
|
|
|
|
|
45
|
|
|
24
|
|
|
|
|
11335
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new_from_string { |
13
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
14
|
0
|
|
|
|
|
|
my ($hstr) = @_; |
15
|
0
|
|
|
|
|
|
my ( $hashdsn, $jobid ) = split /\-/, $hstr, 2; |
16
|
0
|
|
|
|
|
|
return TheSchwartz::JobHandle->new( |
17
|
|
|
|
|
|
|
{ dsn_hashed => $hashdsn, |
18
|
|
|
|
|
|
|
jobid => $jobid, |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub as_string { |
24
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
25
|
0
|
|
|
|
|
|
return join '-', $handle->dsn_hashed, $handle->jobid; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub driver { |
29
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
30
|
0
|
0
|
|
|
|
|
unless ( exists $handle->{__driver} ) { |
31
|
|
|
|
|
|
|
$handle->{__driver} |
32
|
0
|
|
|
|
|
|
= $handle->client->driver_for( $handle->dsn_hashed ); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
return $handle->{__driver}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub job { |
38
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
39
|
0
|
0
|
|
|
|
|
my $job = $handle->client->lookup_job( $handle->as_string ) or return; |
40
|
0
|
|
|
|
|
|
$job->handle($handle); |
41
|
0
|
|
|
|
|
|
return $job; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub is_pending { |
45
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
46
|
0
|
0
|
|
|
|
|
return $handle->job ? 1 : 0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub exit_status { |
50
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
51
|
0
|
0
|
|
|
|
|
my $status |
52
|
|
|
|
|
|
|
= $handle->driver->lookup( |
53
|
|
|
|
|
|
|
'TheSchwartz::ExitStatus' => $handle->jobid ) |
54
|
|
|
|
|
|
|
or return; |
55
|
0
|
|
|
|
|
|
return $status->status; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub failure_log { |
59
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
60
|
0
|
|
|
|
|
|
my @failures = $handle->driver->search( |
61
|
|
|
|
|
|
|
'TheSchwartz::Error' => { jobid => $handle->jobid }, ); |
62
|
0
|
|
|
|
|
|
return map { $_->message } @failures; |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub failures { |
66
|
0
|
|
|
0
|
0
|
|
my $handle = shift; |
67
|
0
|
|
|
|
|
|
return scalar $handle->failure_log; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |