line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Qudo::Job; |
2
|
33
|
|
|
33
|
|
414
|
use strict; |
|
33
|
|
|
|
|
63
|
|
|
33
|
|
|
|
|
1061
|
|
3
|
33
|
|
|
33
|
|
155
|
use warnings; |
|
33
|
|
|
|
|
61
|
|
|
33
|
|
|
|
|
38003
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
0
|
|
|
0
|
0
|
|
my ($class, %args) = @_; |
7
|
0
|
|
|
|
|
|
bless {%args}, $class; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
sub id { $_[0]->{job_data}->{job_id} } |
11
|
0
|
|
|
0
|
0
|
|
sub uniqkey { $_[0]->{job_data}->{job_uniqkey} } |
12
|
0
|
|
|
0
|
0
|
|
sub func_id { $_[0]->{job_data}->{func_id} } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub funcname { |
15
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
16
|
0
|
|
|
|
|
|
$self->manager->funcid_to_name($self->func_id, $self->db); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
0
|
|
sub retry_cnt { $_[0]->{job_data}->{job_retry_cnt} } |
20
|
0
|
|
|
0
|
0
|
|
sub grabbed_until { $_[0]->{job_data}->{job_grabbed_until} } |
21
|
0
|
|
|
0
|
0
|
|
sub priority { $_[0]->{job_data}->{job_priority} } |
22
|
0
|
|
|
0
|
0
|
|
sub arg : lvalue { $_[0]->{job_data}->{job_arg} } |
23
|
0
|
|
|
0
|
0
|
|
sub arg_origin : lvalue { $_[0]->{arg_origin} } |
24
|
0
|
|
|
0
|
0
|
|
sub db { $_[0]->{db} } |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
0
|
|
sub manager { $_[0]->{manager} } |
27
|
0
|
|
|
0
|
0
|
|
sub job_start_time : lvalue { $_[0]->{job_start_time} } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub completed { |
30
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$self->{_complete} = 1; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
return unless $self->funcname->set_job_status; |
35
|
0
|
|
|
|
|
|
$self->manager->set_job_status($self, 'completed'); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
0
|
|
sub is_completed { $_[0]->{_complete} } |
39
|
0
|
|
|
0
|
0
|
|
sub is_aborted { $_[0]->{_abort} } |
40
|
0
|
|
|
0
|
0
|
|
sub is_failed { $_[0]->{_fail} } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub reenqueue { |
43
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
44
|
0
|
|
|
|
|
|
$self->manager->reenqueue($self, $args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub dequeue { |
48
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
49
|
0
|
|
|
|
|
|
$self->manager->dequeue($self); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub error { |
53
|
0
|
|
|
0
|
0
|
|
my ($self, ) = @_; |
54
|
0
|
|
|
|
|
|
return $self->{_error} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub failed { |
58
|
0
|
|
|
0
|
0
|
|
my ($self, $error) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->{_fail} = 1; |
61
|
0
|
|
|
|
|
|
$self->{_error} = $error; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($self->funcname->set_job_status) { |
64
|
0
|
|
|
|
|
|
$self->manager->set_job_status($self, 'failed'); |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
$self->manager->job_failed($self, $error); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub abort { |
70
|
0
|
|
|
0
|
0
|
|
my ($self, $error) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->{_abort} = 1; |
73
|
0
|
|
0
|
|
|
|
$error ||= 'abort!!'; |
74
|
0
|
|
|
|
|
|
$self->{_error} = $error; |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if ($self->funcname->set_job_status) { |
77
|
0
|
|
|
|
|
|
$self->manager->set_job_status($self, 'abort'); |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
$self->manager->job_failed($self, $error); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub replace { |
83
|
0
|
|
|
0
|
0
|
|
my ($self, @jobs) = @_; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $db = $self->manager->driver_for($self->db); |
86
|
0
|
|
|
|
|
|
$db->dbh->begin_work; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
for my $job (@jobs) { |
89
|
0
|
|
|
|
|
|
$self->manager->enqueue(@$job, $self->db); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->completed; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$db->dbh->commit; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|