IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32785


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.

Location:
trunk/pstamp/scripts
Files:
3 edited

Legend:

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

    r27874 r32785  
    2323
    2424use PS::IPP::Config qw( :standard );
     25use PS::IPP::PStamp::Job qw( :standard );
    2526
    2627my $req_id;
     
    9596}
    9697
     98{
     99    my $command = "$pstamptool -listfile -req_id $req_id";
     100    $command   .= " -dbname $dbname" if $dbname;
     101    $command   .= " -dbserver $dbserver" if $dbserver;
     102    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     103        run(command => $command, verbose => $verbose);
     104    unless ($success) {
     105        die("Unable to perform $command error code: $error_code");
     106    }
     107    my $output = join "", @$stdout_buf;
     108    if ($output) {
     109        my $files = parse_md_fast($mdcParser, $output);
     110        foreach my $file (@$files) {
     111            $ipprc->file_delete($file->{path});
     112        }
     113    }
     114}
     115
    97116# now go find the workdir for this request
    98117# XXX: we finally *have* to store this in the database
  • 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
  • trunk/pstamp/scripts/pstamp_job_run.pl

    r31508 r32785  
    8888my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    8989
     90my $params = read_params_file($outputBase);
     91
    9092my $jobStatus;
    9193if ($jobType eq "stamp") {
    92     my $params = read_params_file($outputBase);
    9394
    9495    my $argString;
     
    272273} elsif ($jobType eq "get_image") {
    273274
    274     my $uri = "";
     275    my $pstamp_bundle_root = metadataLookupStr($ipprc->{_siteConfig}, "PSTAMP_BUNDLE_ROOT");
     276    my $imagedb = $params->{imagedb};
     277
    275278    my $command = "$pstamp_get_image_job --job_id $job_id --output_base $outputBase --rownum $rownum";
     279    $command .= " --bundleroot $pstamp_bundle_root" if $pstamp_bundle_root;
     280    $command .= " --imagedb $imagedb" if $imagedb;
    276281    $command .= " --dbname $dbname" if $dbname;
    277282    $command .= " --dbserver $dbserver" if $dbserver;
Note: See TracChangeset for help on using the changeset viewer.