IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36165


Ignore:
Timestamp:
Oct 1, 2013, 10:04:02 AM (13 years ago)
Author:
bills
Message:

Catch a case where a single row creates a large number of jobs and lower
the request priority

File:
1 edited

Legend:

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

    r36143 r36165  
    240240
    241241
     242# if label is for one of the high priority channels, watch for big requests
     243my $watch_for_big_requests = (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/));
     244
     245my $big_limit = 100;    # XXX: this should be in a configuration file somewhere not hard coded
     246
     247if ($watch_for_big_requests and $nRows > $big_limit) {
     248    $label = change_to_lower_priority_label($label);
     249    $watch_for_big_requests = 0;
     250}
    242251
    243252my $num_jobs = 0;
    244 my $imageList;
    245 my $stage;
    246 my $big_limit = 100;    # XXX: this should be in a configuration file some where
     253
    247254foreach my $row (@$rows) {
    248 
    249 
    250     if (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/) and ($nRows > $big_limit or $num_jobs > $big_limit)
    251         and $req_id and !$no_update) {
    252 
    253         # This is a "big" request and it came from one of the "high priority" channels
    254         # and doesn't have a specific label assigned.
    255         # Change the label to a value that its jobs run with lower priority.
    256 
    257         my $old_label = $label;
    258         $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG';
    259         print "\nChanging label for big $old_label request to $label\n";
    260 
    261         my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
    262         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    263             run(command => $command, verbose => $verbose);
    264         unless ($success) {
    265             my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
    266         }
    267     }
    268255
    269256    # validate the paramaters
     
    278265
    279266    $num_jobs += processRow($action, $row);
     267
     268    # see whether number of jobs limit for high priority request was exceeded
     269    if ($watch_for_big_requests and $num_jobs > $big_limit) {
     270        $label = change_to_lower_priority_label($label);
     271        $watch_for_big_requests = 0;
     272    }
    280273}
    281274
     
    288281
    289282exit 0;
     283
     284# end of main function
     285
     286sub change_to_lower_priority_label {
     287    my $label = shift;
     288    my $old_label = $label;
     289    $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG';
     290    print "\nChanging label for big $old_label request to $label\n";
     291
     292    my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
     293    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     294        run(command => $command, verbose => $verbose);
     295    unless ($success) {
     296        my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     297    }
     298    return $label;
     299}
    290300
    291301sub checkRow {
     
    496506    print "\nCalling locate_images_for_row for row: $rownum\n";
    497507
    498     $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
     508    my $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
    499509
    500510    my $dtime_locate = gettimeofday() - $start_locate;
     
    588598    # information required is contained there
    589599
    590     $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,
     600    my $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,
    591601                $option_mask, $need_magic, $mjd_min, $mjd_max, $filter, $data_group, $verbose);
    592602
Note: See TracChangeset for help on using the changeset viewer.