IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 23, 2011, 1:46:37 PM (15 years ago)
Author:
bills
Message:

For get_image jobs store bundles in nebulous. Keep track of the files in new table pstampFile.
Delete them when cleaning up the request.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_get_image_job.pl

    r30663 r32785  
    2525
    2626my $output_base;
     27my $bundleroot;
    2728
    2829my $verbose;
    29 my $ipprc;
     30my $imagedbname;
    3031my $dbname;
    3132my $dbserver;
     
    4142        'rownum=s'        =>      \$rownum,
    4243        'output_base=s'   =>      \$output_base,
     44        'bundleroot=s'    =>      \$bundleroot,
     45        'imagedbname=s'   =>      \$imagedbname,
    4346        'dbname=s'        =>      \$dbname,
    4447        'dbserver=s'      =>      \$dbserver,
     
    5255
    5356my_die( $err, $PS_EXIT_PROG_ERROR) if $err;
     57
     58my $ipprc = PS::IPP::Config->new();
    5459
    5560my $params_file = $output_base . ".mdc";
     
    9196my $missing_tools;
    9297my $dist_bundle   = can_run('dist_bundle.pl') or (warn "Can't find dist_bundle.pl" and $missing_tools = 1);
     98my $pstamptool   = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1);
    9399if ($missing_tools) {
    94100    warn("Can't find required tools.");
     
    96102}
    97103
     104$pstamptool .= " -dbname $dbname" if $dbname;
     105$pstamptool .= " -dbserver $dbserver" if $dbserver;
     106
    98107my $outdir = dirname($output_base);
    99108my $basename = basename($path_base);
    100 my $outroot = $output_base ."_" . $basename;
    101109my $results_file = $output_base . ".bundle_results";
     110my $outroot;
     111if ($bundleroot) {
     112    my (undef, undef, undef, $mday, $month, $year) = gmtime(time());
     113    $month += 1;
     114    $year += 1900;
     115
     116    # This will generate an outroot like:
     117    # neb://any/pstamp/bundles/2011/11/22/14026916_1_1_o5739g0358o.353654.wrp.215092.skycell.2083.025
     118
     119    $outroot = $bundleroot . sprintf("/%4d/%02d/%02d/${job_id}_", $year, $month, $mday) . basename($output_base) . "_". $basename;
     120} else {
     121    $outroot = $output_base ."_" . $basename;
     122}
    102123
    103124{
     
    105126    $command .= " --results_file $results_file";
    106127    $command .= " --component $component --path_base $path_base --outroot $outroot";
    107 #    XXX: we need to do some work if we want to support muggle bundles
    108 #    $command .= " --no_magic if $no_magic";
     128    #    XXX: we need to do some work if we want to support muggle bundles
     129    #    $command .= " --no_magic if $no_magic";
    109130    $command .= " --magicked" if $magicked;
    110     $command .= " --dbname $dbname" if $dbname;
     131    $command .= " --dbname $imagedbname" if $imagedbname;
    111132    $command .= " --verbose" if $verbose;
    112133    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    147168}
    148169
     170if ($bundleroot) {
     171    {
     172        # delete any existing pstampFile in case this job has faulted and
     173        # been reverted
     174        my $command = "$pstamptool -deletefile -job_id $job_id";
     175        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     176            run(command => $command, verbose => $verbose);
     177        unless ($success) {
     178            my_die("Unable to perform $command: $error_code", $error_code >> 8);
     179        }
     180    }
     181    my $linkname = "$outdir/$file_name";
     182    if (-l $linkname or -e $linkname) {
     183        unlink $linkname or my_die("Failed to unlink existing symlink: $linkname", $PS_EXIT_UNKNOWN_ERROR);
     184    }
     185    my $bundle_name = dirname($outroot) . "/$file_name";
     186    my $resolved = $ipprc->file_resolve($bundle_name);
     187    if (!$resolved) {
     188        my_die("failed to resolve $bundle_name", $PS_EXIT_UNKNOWN_ERROR);
     189    }
     190    symlink $resolved, $linkname or my_die("failed to create symlink to $resolved in $outdir",
     191        $PS_EXIT_UNKNOWN_ERROR);
     192
     193    my $command = "$pstamptool -addfile -job_id $job_id -path $bundle_name";
     194    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     195        run(command => $command, verbose => $verbose);
     196    unless ($success) {
     197        my_die("Unable to perform $command: $error_code", $error_code >> 8);
     198    }
     199}
     200
     201
    149202print REGLIST "$file_name|$bytes|$md5sum|tgz|\n";
    150203
Note: See TracChangeset for help on using the changeset viewer.