| 1 | |||||||||||||||||||||||||||||||||||||||
| 2 | package Proc::JobQueue::Move; | ||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||
| 4 | # $Id: Move.pm 13853 2009-07-24 00:59:44Z david $ | ||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 3 | require Proc::JobQueue; | |||||||||||||||||||||||||||||||||||||
| 9 | 3 | require Proc::JobQueue::Job; | |||||||||||||||||||||||||||||||||||||
| 10 | 3 | our @ISA = qw(Proc::JobQueue::Job); | |||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Tie::Function::Examples qw(%q_shell); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Proc::JobQueue qw(my_hostname is_remote_host); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 3 | my %destinations; | |||||||||||||||||||||||||||||||||||||
| 15 | 3 | my $copies_running = 0; | |||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my $debug = $Proc::JobQueue::debug; | |||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | sub new | ||||||||||||||||||||||||||||||||||||||
| 20 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 21 | 40 | my ($pkg, $opts, $config, $from_file, $to_file, $to_host, $from_host) = @_; | |||||||||||||||||||||||||||||||||||||
| 22 | 40 | ▶ | $pkg->SUPER::new( | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$from_host || my_hostname()
$to_host || my_hostname()
MC/DC0%0/2
$from_host || my_hostname()
$from_host
my_hostname()
MC/DC0%0/2
$to_host || my_hostname()
$to_host
my_hostname()
Truth table33%1/3
A || B
A= $from_hostB= my_hostname()
Truth table33%1/3
A || B
A= $to_hostB= my_hostname()
| |||||||||||||||||||||||||||||||||||||||
| 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 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=3 SCAR=15.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 36 | 40 | my ($job) = @_; | |||||||||||||||||||||||||||||||||||||
| 37 | 40 | ▶ | if (is_remote_host($job->{to_host})) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $compress = $job->{config}{compress_network_copies} ? "-C" : ""; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 39 | 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 | return "mv $q_shell{$job->{from}} $q_shell{$job->{to}}"; | |||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | sub runnable | ||||||||||||||||||||||||||||||||||||||
| 47 | 90 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
runnable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 48 | 90 | my ($job) = @_; | |||||||||||||||||||||||||||||||||||||
| 49 | 90 | return ! $destinations{$job->{to_host}}; | |||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||
| 52 | sub start | ||||||||||||||||||||||||||||||||||||||
| 53 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 54 | 40 | my $job = shift; | |||||||||||||||||||||||||||||||||||||
| 55 | 40 | $job->SUPER::start(@_); | |||||||||||||||||||||||||||||||||||||
| 56 | 40 | $destinations{$job->{to_host}} = 1; | |||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | sub finished | ||||||||||||||||||||||||||||||||||||||
| 60 | 60 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
finished: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 61 | 60 | my $job = shift; | |||||||||||||||||||||||||||||||||||||
| 62 | 60 | $destinations{$job->{to_host}} = 0; | |||||||||||||||||||||||||||||||||||||
| 63 | 60 | $job->SUPER::finished(@_); | |||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | sub success | ||||||||||||||||||||||||||||||||||||||
| 67 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
success: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 68 | 40 | my ($job) = @_; | |||||||||||||||||||||||||||||||||||||
| 69 | 40 | unlink($job->{from}); | |||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | 3 | 1; | |||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||||||||||||