IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 7, 2009, 1:05:22 PM (17 years ago)
Author:
bills
Message:

Add new table pstampDependent. An entry gets created by the postage stamp request parser
when the source run has been cleaned. The pstampJob is blocked from running until
the system detects that the run has been updated and magicked. (This code is yet
to be developed.)

File:
1 edited

Legend:

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

    r25776 r25793  
    7272}
    7373
     74# just deal with these arguments once and for all
     75$pstamptool .= " -dbname $dbname" if $dbname;
     76$pstamptool .= " -dbserver $dbserver" if $dbserver;
     77
    7478# list_job is a deugging mode
    7579$no_update = 1 if $mode eq "list_job";
     
    105109if ($req_id and !$no_update) {
    106110    my $command = "$pstamptool -listreq  -name $req_name -not_req_id $req_id";
    107     $command .= " -dbname $dbname" if $dbname;
    108     $command .= " -dbserver $dbserver" if $dbserver;
    109111    # no verbose so that error message about request not found doesn't appear in parse_error.txt
    110112    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    127129    my $command = "$pstamptool -updatereq -req_id $req_id  -name $req_name";
    128130    $command .= " -outProduct $product";
    129     $command .= " -dbname $dbname" if $dbname;
    130     $command .= " -dbserver $dbserver" if $dbserver;
    131131    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    132132        run(command => $command, verbose => $verbose);
     
    398398        my $newState = "run";
    399399        my $fault = 0;
    400 
    401         if (($stage ne 'stack') and ($stage ne 'raw')) {
    402             if (($image->{state} eq 'goto_purged') or ($image->{data_state} eq 'purged')) {
     400        my $dep_id;
     401
     402        if ($stage ne 'raw') {
     403            my $run_state = $image->{state};
     404            my $data_state = $image->{data_state};
     405            if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or
     406                ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) {
     407                # image is gone and it's not coming back
    403408                $newState = 'stop';
    404409                $fault = $PSTAMP_GONE;
    405             } elsif (($image->{data_state} ne 'full') or ($image->{state} ne 'full' )) {
    406                 # XXX here is where we need to queue an update job
    407                 # for now just say that the image is not available
    408                 $newState = 'stop';
    409                 $fault = $PSTAMP_NOT_AVAILABLE;
     410            } elsif (($data_state ne 'full') or ($run_state ne 'full' )) {
     411                my $PSTAMP_NO_UPDATE = 2048;
     412                # for now just fault while I build pstampDependent
     413                if ($option_mask & $PSTAMP_NO_UPDATE) {
     414                    $newState = 'stop';
     415                    $fault = $PSTAMP_NOT_AVAILABLE;
     416                } else {
     417                    # cause the image to be re-made
     418                    # set up to queue an update run
     419                    queue_update_run(\$newState, \$fault, \$dep_id, $image->{image_db},
     420                        $run_state, $stage, $image->{stage_id}, $need_magic, $image->{label});
     421                }
    410422            }
    411423        }
     
    416428        $command .= " -fault $fault" if $fault;
    417429        $command .= " -exp_id $exp_id" if $exp_id;
    418         $command .= " -dbname $dbname" if $dbname;
    419         $command .= " -dbserver $dbserver" if $dbserver;
     430        $command .= " -dep_id $dep_id" if $dep_id;
    420431
    421432        if ($mode eq "list_job") {
     
    594605    my $command = "$pstamptool -addjob  -req_id $req_id -job_type $job_type"
    595606                        . " -rownum $rownum -state stop -fault $fault";
    596     $command .= " -dbname $dbname" if $dbname;
    597     $command .= " -dbserver $dbserver" if $dbserver;
    598607
    599608    if ($mode eq "list_job") {
     
    718727}
    719728
     729sub queue_update_run
     730{
     731    my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $need_magic, $label) = @_;
     732
     733    if (($state ne 'cleaned') and ($state ne 'update') and ($state ne 'goto_cleaned')) {
     734        my_die("$stage $stage_id is in unexpected state $state", $PS_EXIT_PROG_ERROR);
     735    }
     736
     737    my $dep_id;
     738    my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb";
     739    $command .= " -rlabel $label" if $label;
     740    $command .= " -no_magic" if !$need_magic;
     741    if (!$no_update) {
     742        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     743            run(command => $command, verbose => $verbose);
     744        unless ($success) {
     745            my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     746        }
     747        my $output = join "", @$stdout_buf;
     748        chomp $output;
     749        $dep_id = $output;
     750        my_die("pstamptool -getdependent returned invalid dep_id", $PS_EXIT_PROG_ERROR) if !$dep_id;
     751    } else {
     752        print STDERR "skipping $command\n";
     753        $dep_id = 42;
     754    }
     755   
     756    $$r_dep_id = $dep_id;
     757    $r_fault = 0;
     758    $r_jobState = 'blocked';
     759}
     760
    720761sub my_die
    721762{
Note: See TracChangeset for help on using the changeset viewer.