Parent Directory
|
Revision Log
Revision 1.1 - (view) (download) (as text)
1 : | olson | 1.1 | |
2 : | # | ||
3 : | # Finish a job that has its work directories over on the | ||
4 : | # lustre spool directory by copying them back and then | ||
5 : | # setting the job to done. | ||
6 : | # | ||
7 : | |||
8 : | use Data::Dumper; | ||
9 : | use Carp; | ||
10 : | use strict; | ||
11 : | use FIG; | ||
12 : | use FIG_Config; | ||
13 : | use File::Basename; | ||
14 : | use GenomeMeta; | ||
15 : | use JobError; | ||
16 : | use File::Basename; | ||
17 : | |||
18 : | @ARGV == 1 or die "Usage: $0 job-dir\n"; | ||
19 : | |||
20 : | my $jobdir = shift; | ||
21 : | |||
22 : | -d $jobdir or die "$0: job dir $jobdir does not exist\n"; | ||
23 : | |||
24 : | my $job = new Job48($jobdir); | ||
25 : | $job or die "cannot create job for $jobdir"; | ||
26 : | |||
27 : | my $hostname = `hostname`; | ||
28 : | chomp $hostname; | ||
29 : | |||
30 : | my $genome = &FIG::file_head("$jobdir/GENOME_ID"); | ||
31 : | chomp $genome; | ||
32 : | $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n"; | ||
33 : | |||
34 : | my $meta = new GenomeMeta($genome, "$jobdir/meta.xml"); | ||
35 : | |||
36 : | my $genome_dir = "$jobdir/rp/$genome"; | ||
37 : | |||
38 : | $meta->set_metadata("lustre_stage_in.hostname", $hostname); | ||
39 : | |||
40 : | $meta->add_log_entry($0, "copy lustre spooled job back to $jobdir"); | ||
41 : | |||
42 : | # | ||
43 : | # Find any directories in the jobdir that are symlinked to the lustre spool. Copy | ||
44 : | # the contents back here. | ||
45 : | # | ||
46 : | opendir(D, $jobdir) or &fatal("cannot opendir $jobdir: $!"); | ||
47 : | for my $f (readdir(D)) | ||
48 : | { | ||
49 : | my $path = "$jobdir/$f"; | ||
50 : | next unless -l $path; | ||
51 : | my $targ = readlink($path); | ||
52 : | if (!$targ) | ||
53 : | { | ||
54 : | warn "Error reading symlink $path: $!"; | ||
55 : | next | ||
56 : | } | ||
57 : | |||
58 : | if ($targ =~ /^$FIG_Config::lustre_spool_dir/) | ||
59 : | { | ||
60 : | warn "Copying back data from $targ to $path\n"; | ||
61 : | unlink($path); | ||
62 : | my $targ_dir = dirname($targ); | ||
63 : | if ($targ_dir eq '' or ! -d $targ_dir) | ||
64 : | { | ||
65 : | warn "Some error extracting dirname '$targ_dir' from target '$targ'\n"; | ||
66 : | next; | ||
67 : | } | ||
68 : | my $tar_cmd = "tar -C $targ_dir -c -p -f - $f | tar -C $jobdir -x -p -f -"; | ||
69 : | warn "Execute $tar_cmd\n"; | ||
70 : | my $rc = system($tar_cmd); | ||
71 : | if ($rc != 0) | ||
72 : | { | ||
73 : | &fatal("Error $rc running tar cmd $tar_cmd\n"); | ||
74 : | } | ||
75 : | } | ||
76 : | } | ||
77 : | |||
78 : | if (open(D, ">$jobdir/DONE")) | ||
79 : | { | ||
80 : | print D time . "\n"; | ||
81 : | close(D); | ||
82 : | } | ||
83 : | else | ||
84 : | { | ||
85 : | warn "Error opening $jobdir/DONE: $!\n"; | ||
86 : | } | ||
87 : | |||
88 : | unlink("$jobdir/ACTIVE"); | ||
89 : | |||
90 : | exit(0); | ||
91 : | |||
92 : | sub fatal | ||
93 : | { | ||
94 : | my($msg) = @_; | ||
95 : | |||
96 : | if ($meta) | ||
97 : | { | ||
98 : | $meta->add_log_entry($0, ['fatal error', $msg]); | ||
99 : | } | ||
100 : | |||
101 : | flag_error($genome, $job->id, $jobdir, $meta, "luster_stage_in"); | ||
102 : | |||
103 : | croak "$0: $msg"; | ||
104 : | } | ||
105 : |
MCS Webmaster | ViewVC Help |
Powered by ViewVC 1.0.3 |