line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Proc::JobQueue::Move; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# $Id: Move.pm 13853 2009-07-24 00:59:44Z david $ |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
3923
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
168
|
|
7
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
261
|
|
8
|
|
|
|
|
|
|
require Proc::JobQueue; |
9
|
|
|
|
|
|
|
require Proc::JobQueue::Job; |
10
|
|
|
|
|
|
|
our @ISA = qw(Proc::JobQueue::Job); |
11
|
4
|
|
|
4
|
|
48
|
use Tie::Function::Examples qw(%q_shell); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
478
|
|
12
|
4
|
|
|
4
|
|
22
|
use Proc::JobQueue qw(my_hostname is_remote_host); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1927
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %destinations; |
15
|
|
|
|
|
|
|
my $copies_running = 0; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $debug = $Proc::JobQueue::debug; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new |
20
|
|
|
|
|
|
|
{ |
21
|
40
|
|
|
40
|
0
|
1229
|
my ($pkg, $opts, $config, $from_file, $to_file, $to_host, $from_host) = @_; |
22
|
40
|
|
33
|
|
|
614
|
$pkg->SUPER::new( |
|
|
|
33
|
|
|
|
|
23
|
|
|
|
|
|
|
from_host => $from_host || my_hostname(), |
24
|
|
|
|
|
|
|
config => $config, |
25
|
|
|
|
|
|
|
opts => $opts, |
26
|
|
|
|
|
|
|
from => $from_file, |
27
|
|
|
|
|
|
|
to => $to_file, |
28
|
|
|
|
|
|
|
to_host => $to_host || my_hostname(), |
29
|
|
|
|
|
|
|
desc => "move to $to_host:$to_file", |
30
|
|
|
|
|
|
|
priority => 10, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub command |
35
|
|
|
|
|
|
|
{ |
36
|
40
|
|
|
40
|
0
|
71
|
my ($job) = @_; |
37
|
40
|
50
|
|
|
|
561
|
if (is_remote_host($job->{to_host})) { |
38
|
0
|
0
|
|
|
|
0
|
my $compress = $job->{config}{compress_network_copies} ? "-C" : ""; |
39
|
0
|
|
|
|
|
0
|
return "scp -q -o StrictHostKeyChecking=no -o BatchMode=yes $compress $q_shell{$job->{from}} $q_shell{$job->{to_host}}:$q_shell{$job->{to}} && rm $q_shell{$job->{from}}"; |
40
|
|
|
|
|
|
|
} else { |
41
|
|
|
|
|
|
|
# maybe it's on another filesystem |
42
|
40
|
|
|
|
|
2286
|
return "mv $q_shell{$job->{from}} $q_shell{$job->{to}}"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub runnable |
47
|
|
|
|
|
|
|
{ |
48
|
121
|
|
|
121
|
1
|
1232
|
my ($job) = @_; |
49
|
121
|
|
|
|
|
968
|
return ! $destinations{$job->{to_host}}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub start |
53
|
|
|
|
|
|
|
{ |
54
|
40
|
|
|
40
|
1
|
195
|
my $job = shift; |
55
|
40
|
|
|
|
|
566
|
$job->SUPER::start(@_); |
56
|
40
|
|
|
|
|
102149
|
$destinations{$job->{to_host}} = 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub finished |
60
|
|
|
|
|
|
|
{ |
61
|
60
|
|
|
60
|
1
|
674
|
my $job = shift; |
62
|
60
|
|
|
|
|
564
|
$destinations{$job->{to_host}} = 0; |
63
|
60
|
|
|
|
|
538
|
$job->SUPER::finished(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub success |
67
|
|
|
|
|
|
|
{ |
68
|
40
|
|
|
40
|
0
|
93
|
my ($job) = @_; |
69
|
40
|
|
|
|
|
3004
|
unlink($job->{from}); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |