Changeset 18619
- Timestamp:
- Jul 18, 2008, 12:56:11 PM (18 years ago)
- Location:
- trunk/pstamp/scripts
- Files:
-
- 2 edited
-
dquery_finish.pl (modified) (3 diffs)
-
dqueryparse.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/dquery_finish.pl
r18588 r18619 67 67 exit ($PS_EXIT_CONFIG_ERROR) unless defined $outputDataStoreRoot; # lookup failure outputs a message 68 68 69 my $response_file = "$outputDataStoreRoot/$product/$req_name/response.fits"; 69 my $out_dir = "$outputDataStoreRoot/$product/$req_name"; 70 if (! -e $out_dir ) { 71 # something must have gone wrong at the parse stage 72 print STDERR "output fileset directory $out_dir does not exist\n" if $verbose; 73 if (! mkdir $out_dir ) { 74 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 75 die "cannot create output directory $out_dir"; 76 } 77 } elsif (! -d $out_dir) { 78 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 79 die "output fileset directory $out_dir exists but is not a directory"; 80 } 81 82 83 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 70 84 71 85 my $request_fault = 0; 72 if (-e $response_file) { 86 my @jobs; 87 { 88 my $command = "$pstamptool -listjob -req_id $req_id"; 89 $command .= " -dbname $dbname" if $dbname; 90 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 91 run(command => $command, verbose => $verbose); 92 unless ($success) { 93 die("Unable to perform $command error code: $error_code"); 94 } 95 my $output = join "", @$stdout_buf; 96 if (!$output) { 97 if ($verbose) { 98 print STDERR "Request $req_id produced no jobs.\n"; 99 } 100 # assume that the parser set the fault 101 } else { 102 my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc for jobs list"); 103 my $jobs = parse_md_list($metadata); 104 @jobs = @$jobs; 105 } 106 } 73 107 74 # the job generated a response file put it into the Data Store 75 # XXX: for now we have one response file. In the real system we may have multiple jobs with 76 # multiple response files 108 my ($REGLIST, $reg_list) = tempfile("$out_dir/reqlist.XXXX", UNLINK => !$save_temps); 109 foreach my $job (@jobs) { 110 my $job_id = $job->{job_id}; 111 my $response_file = "response${job_id}.fits"; 112 my $response_path = "$out_dir/$response_file"; 77 113 78 my $command = "echo 'response.fits|||table|' | $dsreg --add $req_name --product $product --list -"; 114 if (-e $response_path) { 115 # the job generated a response file put it into the Data Store 116 print $REGLIST "$response_file|||table|\n"; 117 } else { 118 print STDERR "detect_query response file for job $job_id not found\n"; 119 $request_fault = $PS_EXIT_UNKNOWN_ERROR; 120 } 121 } 122 close $REGLIST; 123 124 if (-s $reg_list) { 125 my $command = "$dsreg --add $req_name --product $product --list $reg_list"; 79 126 $command .= " --type MOPS_DETECTABILITY_RESPONSE"; 80 127 $command .= " --dbname $dbname" if $dbname; … … 85 132 $request_fault = $error_code >> 8; 86 133 print STDERR "Unable to perform $command return code: $request_fault"; 134 # fall through to stop request 87 135 } 88 89 } else {90 print STDERR "detect_query response file not found\n";91 $request_fault = $PS_EXIT_UNKNOWN_ERROR;92 136 } 93 137 94 # set the request's state to stop 95 { 96 my $command = "$pstamptool -processedreq -req_id $req_id -state stop -fault $request_fault"; 138 stop_request($req_id, $request_fault, $verbose); 139 140 exit 0; 141 142 sub stop_request { 143 my $req_id = shift; 144 my $fault = shift; 145 my $verbose = shift; 146 147 my $command = "$pstamptool -processedreq -req_id $req_id -state stop"; 148 $command .= " -fault $fault" if $fault; 97 149 $command .= " -dbname $dbname" if $dbname; 98 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 102 154 } 103 155 } 104 -
trunk/pstamp/scripts/dqueryparse.pl
r18587 r18619 86 86 my (undef, $extname, $extver, $req_name) = split " ", $fields_output; 87 87 88 die "$req_file is missing one of EXTNAME EXTVER or QUERY_ID" 89 if !(defined($extname) and defined($extver) and defined($req_name)); 90 88 91 die "$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table" 89 92 if $extname ne "MOPS_DETECTABILITY_QUERY"; 90 die "$req_file does not have a QUERY_ID" if ! $req_name;91 93 die "$req_file is version $extver expecting 1" if $extver ne 1; 92 94 … … 130 132 $job_id = join "", @$stdout_buf; 131 133 chomp $job_id; 134 if ($job_id && -e $response_file) { 135 rename $response_file, "$out_dir/response${job_id}.fits"; 136 } 132 137 $result = 0; 133 138 } else { … … 136 141 } 137 142 } 143 138 144 139 145 {
Note:
See TracChangeset
for help on using the changeset viewer.
