Changeset 23894
- Timestamp:
- Apr 16, 2009, 5:54:55 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
ippScripts/scripts/receive_file.pl (modified) (6 diffs)
-
ippScripts/scripts/receive_fileset.pl (modified) (3 diffs)
-
ippScripts/scripts/receive_source.pl (modified) (3 diffs)
-
ippTools/share/pxadmin_drop_tables.sql (modified) (1 diff)
-
ippTools/share/receivetool_pendingfile.sql (modified) (1 diff)
-
ippTools/src/receivetool.c (modified) (12 diffs)
-
ippTools/src/receivetoolConfig.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/receive_file.pl
r23890 r23894 65 65 my $filename = "$tempdir/$file"; # Target filename 66 66 { 67 my $uri = "$source/ product/$fileset/$file"; # URI for datastore file67 my $uri = "$source/$product/$fileset/$file"; # URI for datastore file 68 68 my $command = "dsget --uri $uri --filename $filename"; # Command to execute 69 69 … … 81 81 82 82 my $command = "$tool -importrun -infile $filename"; # Command to execute 83 $command .= " -dbname $dbname" if defined $dbname; 83 84 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 84 85 run(command => $command, verbose => $verbose); … … 88 89 my @files = (); 89 90 { 90 my $command = "tar -C $tempdir -t vzf $filename"; # Command to execute91 my $command = "tar -C $tempdir -tzf $filename"; # Command to execute 91 92 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 92 93 run(command => $command, verbose => $verbose); 93 94 die "Unable to get listing of tar file $filename\n" unless $success; 94 95 95 foreach my $line (@$stdout_buf) { 96 my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output 97 foreach my $line ( @lines ) { 96 98 $line =~ s/\#.*$//; 97 99 next unless $line =~ /\S+/; … … 99 101 my $file = $fields[0]; # Name of file 100 102 $file =~ s|^./||; 101 push @files, $file if defined $file;103 push @files, $file if $file =~ /\S+/; 102 104 } 103 105 } … … 115 117 my $from = "$tempdir/$file"; # Source for file 116 118 my $target = "$workdir/$file"; # Target destination for file 117 my $to = $ipprc->file_ prepare( $target ); # Target for move119 my $to = $ipprc->file_create( $target ); # Target for move 118 120 system("mv $from $to") == 0 or die "Unable to move $file into workdir $workdir: $!\n"; 119 121 } … … 129 131 { 130 132 my $command = "$receivetool -addresult"; 131 $command .= " -file $file_id";133 $command .= " -file_id $file_id"; 132 134 $command .= (" -dtime_copy " . (($mjd_copy - $mjd_start) * 86400)); 133 $command .= (" -dtime_extract " . (($mjd_extract - $mjd_ start) * 86400));135 $command .= (" -dtime_extract " . (($mjd_extract - $mjd_copy) * 86400)); 134 136 $command .= " -dbname $dbname" if defined $dbname; 137 138 139 print "$command\n"; 135 140 136 141 unless (defined $no_update) { -
trunk/ippScripts/scripts/receive_fileset.pl
r23888 r23894 55 55 my @files = (); # Files to add 56 56 { 57 my $uri = "$source/ product/$fileset"; # URI for datastore fileset57 my $uri = "$source/$product/$fileset"; # URI for datastore fileset 58 58 $uri .= "/index.txt" unless $uri =~ m|/index.txt$|; 59 59 my $command = "dsfilesetls --uri $uri"; # Command to execute … … 64 64 65 65 # Get files 66 foreach my $line (@$stdout_buf) { 66 my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output 67 foreach my $line ( @lines ) { 67 68 $line =~ s/\#.*$//; 68 69 next unless $line =~ /\S+/; … … 77 78 my $command = "receivetool -addfile"; # Command to execute 78 79 $command .= " -fileset_id $fileset_id"; 79 $command .= " -file " . join(' -file', @files);80 $command .= " -file " . join(' -file ', @files); 80 81 $command .= " -dbname $dbname" if defined $dbname; 81 82 -
trunk/ippScripts/scripts/receive_source.pl
r23892 r23894 55 55 $uri .= "/index.txt" unless $uri =~ m|/index.txt$|; 56 56 my $command = "dsproductls --uri $uri"; # Command to execute 57 $command .= " --last_fileset $last_fileset" if defined $last_fileset;57 $command .= " --last_fileset $last_fileset" if defined $last_fileset; 58 58 59 59 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 61 61 die "Unable to get source listing from $source for $product\n" unless $success; 62 62 63 # Add filesets 64 my $last; # Last fileset seen 65 foreach my $line (@$stdout_buf) { 63 # Parse list of filesets 64 my @filesets = (); # Filesets to add 65 my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output 66 foreach my $line ( @lines ) { 66 67 $line =~ s/\#.*//g; 67 68 next unless $line =~ /\S+/; … … 69 70 my @fields = split(/\s+/, $line); # Fields in line 70 71 my $fileset = $fields[1]; 71 next if not defined $fileset; 72 73 my $command = "receivetool -addfileset"; # Command to execute 74 $command .= " -source_id $source_id"; 75 $command .= " -fileset $fileset"; 76 $command .= " -dbname $dbname" if defined $dbname; 77 78 unless (defined $no_update) { 79 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 run(command => $command, verbose => $verbose); 81 die "Unable to add fileset $fileset\n" unless $success; 82 $last = $fileset; 83 } 72 push @filesets, $fileset if defined $fileset and $fileset =~ /\S+/; 84 73 } 85 74 86 # Update the last fileset seen 87 if (defined $last and (not defined $last_fileset or $last ne $last_fileset)) { 88 my $command = "receivetool -updatelast"; # Command to execute 89 $command .= " -source_id $source_id"; 90 $command .= " -fileset $last"; 91 $command .= " -dbname $dbname" if defined $dbname; 75 if (scalar @filesets > 0) { 76 # Add filesets 77 { 78 my $command = "receivetool -addfileset"; # Command to execute 79 $command .= " -src_id $source_id"; 80 $command .= " -fileset " . join(' -fileset ', @filesets); 81 $command .= " -dbname $dbname" if defined $dbname; 92 82 93 unless (defined $no_update) { 94 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 95 run(command => $command, verbose => $verbose); 96 die "Unable to update last fileset to $last\n" unless $success; 83 unless (defined $no_update) { 84 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 85 run(command => $command, verbose => $verbose); 86 die "Unable to add filesets from $source for $product\n" unless $success; 87 } 88 } 89 90 # Update the last fileset seen 91 { 92 my $command = "receivetool -updatelast"; # Command to execute 93 $command .= " -src_id $source_id"; 94 my $last = pop @filesets; # Last fileset 95 $command .= " -fileset $last"; 96 $command .= " -dbname $dbname" if defined $dbname; 97 98 unless (defined $no_update) { 99 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 100 run(command => $command, verbose => $verbose); 101 die "Unable to update last fileset to $last\n" unless $success; 102 } 97 103 } 98 104 } -
trunk/ippTools/share/pxadmin_drop_tables.sql
r23688 r23894 69 69 DROP TABLE IF EXISTS rcDSFileset; 70 70 DROP TABLE IF EXISTS rcRun; 71 DROP TABLE IF EXISTS receiveSource; 72 DROP TABLE IF EXISTS receiveFileset; 73 DROP TABLE IF EXISTS receiveFile; 74 DROP TABLE IF EXISTS receiveResult; 71 75 72 76 SET FOREIGN_KEY_CHECKS=1 -
trunk/ippTools/share/receivetool_pendingfile.sql
r23885 r23894 1 SELECT * 1 SELECT 2 receiveFile.file_id, 3 source, 4 product, 5 workdir, 6 fileset, 7 file 2 8 FROM receiveFile 3 9 JOIN receiveFileset USING(fileset_id) 4 10 JOIN receiveSource USING(source_id) 5 LEFT JOIN receiveResult USING(file_id) 6 WHERE receiveFile.file_id IS NULL 11 LEFT JOIN receiveResult 12 ON receiveResult.file_id = receiveFile.file_id 13 WHERE receiveResult.file_id IS NULL -
trunk/ippTools/src/receivetool.c
r23885 r23894 95 95 96 96 // required 97 PXOPT_LOOKUP_STR(source, config->args, "-s tage", true, false);97 PXOPT_LOOKUP_STR(source, config->args, "-source", true, false); 98 98 PXOPT_LOOKUP_STR(product, config->args, "-product", true, false); 99 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 99 100 100 101 // optional 101 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);102 102 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 103 103 PXOPT_LOOKUP_STR(last, config->args, "-last", false, false); … … 168 168 169 169 // required 170 PXOPT_LOOKUP_S64(source_id, config->args, "-source_id", true, false); 171 PXOPT_LOOKUP_STR(fileset, config->args, "-fileset", true, false); 172 173 if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) { 170 PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false); 171 psMetadataItem *filesets = psMetadataLookup(config->args, "-fileset"); 172 if (!filesets) { 173 psError(PS_ERR_UNKNOWN, true, "-fileset is required"); 174 return false; 175 } 176 177 if (!psDBTransaction(config->dbh)) { 178 psError(PS_ERR_UNKNOWN, false, "Database error"); 179 return false; 180 } 181 182 psListIterator *iter = psListIteratorAlloc(filesets->data.list, PS_LIST_HEAD, false); // Iterator 183 psMetadataItem *item = NULL; // Item from iteration 184 while ((item = psListGetAndIncrement(iter))) { 185 psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad"); 186 187 if (!receiveFilesetInsert(config->dbh, 0, source_id, item->data.str)) { 188 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 189 if (!psDBTransaction(config->dbh)) { 190 psError(PS_ERR_UNKNOWN, false, "Database error"); 191 return false; 192 } 193 psFree(iter); 194 return false; 195 } 196 } 197 psFree(iter); 198 199 if (!psDBCommit(config->dbh)) { 174 200 psError(PS_ERR_UNKNOWN, false, "Database error"); 175 201 return false; … … 184 210 185 211 // required 186 PXOPT_LOOKUP_S64(source_id, config->args, "-s ource_id", true, false);212 PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false); 187 213 PXOPT_LOOKUP_STR(fileset, config->args, "-fileset", true, false); 188 214 … … 212 238 PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "=="); 213 239 PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE"); 240 241 // optional 242 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 243 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 214 244 215 245 psString query = pxDataGet("receivetool_pendingfileset.sql"); … … 227 257 psFree(where); 228 258 259 if (limit) { 260 psString limitString = psDBGenerateLimitSQL(limit); 261 psStringAppend(&query, " %s", limitString); 262 psFree(limitString); 263 } 264 229 265 if (!p_psDBRunQueryF(config->dbh, query)) { 230 266 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 244 280 return true; 245 281 } 246 if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", true)) {282 if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", !simple)) { 247 283 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 248 284 psFree(output); … … 260 296 // required 261 297 PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false); 262 PXOPT_LOOKUP_STR(file, config->args, "-file", true, false); 263 264 if (!receiveFileInsert(config->dbh, 0, fileset_id, file)) { 298 psMetadataItem *files = psMetadataLookup(config->args, "-file"); 299 if (!files) { 300 psError(PS_ERR_UNKNOWN, true, "-file is required"); 301 return false; 302 } 303 304 if (!psDBTransaction(config->dbh)) { 305 psError(PS_ERR_UNKNOWN, false, "Database error"); 306 return false; 307 } 308 309 psListIterator *iter = psListIteratorAlloc(files->data.list, PS_LIST_HEAD, false); // Iterator 310 psMetadataItem *item = NULL; // Item from iteration 311 while ((item = psListGetAndIncrement(iter))) { 312 psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad"); 313 314 if (!receiveFileInsert(config->dbh, 0, fileset_id, item->data.str)) { 315 psError(PS_ERR_UNKNOWN, false, "Unable to add file"); 316 if (!psDBTransaction(config->dbh)) { 317 psError(PS_ERR_UNKNOWN, false, "Database error"); 318 return false; 319 } 320 psFree(iter); 321 return false; 322 } 323 } 324 psFree(iter); 325 326 if (!psDBCommit(config->dbh)) { 265 327 psError(PS_ERR_UNKNOWN, false, "Database error"); 266 328 return false; … … 282 344 PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "=="); 283 345 346 // optional 347 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 348 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 349 284 350 psString query = pxDataGet("receivetool_pendingfile.sql"); 285 351 if (!query) { … … 296 362 psFree(where); 297 363 364 if (limit) { 365 psString limitString = psDBGenerateLimitSQL(limit); 366 psStringAppend(&query, " %s", limitString); 367 psFree(limitString); 368 } 369 298 370 if (!p_psDBRunQueryF(config->dbh, query)) { 299 371 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 313 385 return true; 314 386 } 315 if (!ippdbPrintMetadatas(stdout, output, "receiveFile", true)) {387 if (!ippdbPrintMetadatas(stdout, output, "receiveFile", !simple)) { 316 388 psError(PS_ERR_UNKNOWN, false, "Failed to print array"); 317 389 psFree(output); … … 328 400 329 401 // required 330 PXOPT_LOOKUP_S64(file set_id, config->args, "-source_id", true, false);402 PXOPT_LOOKUP_S64(file_id, config->args, "-file_id", true, false); 331 403 332 404 // optional … … 335 407 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 336 408 337 if (!receiveResultInsert(config->dbh, file set_id, dtime_copy, dtime_extract, fault)) {409 if (!receiveResultInsert(config->dbh, file_id, dtime_copy, dtime_extract, fault)) { 338 410 psError(PS_ERR_UNKNOWN, false, "Database error"); 339 411 return false; -
trunk/ippTools/src/receivetoolConfig.c
r23885 r23894 47 47 psMetadataAddStr(definesourceArgs, PS_LIST_TAIL, "-source", 0, "define source (required)", NULL); 48 48 psMetadataAddStr(definesourceArgs, PS_LIST_TAIL, "-product", 0, "define product (required)", NULL); 49 psMetadataAddStr(definesourceArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir ", NULL);49 psMetadataAddStr(definesourceArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 50 50 psMetadataAddStr(definesourceArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL); 51 51 psMetadataAddStr(definesourceArgs, PS_LIST_TAIL, "-last", 0, "define last fileset", NULL); … … 59 59 // -addfileset 60 60 psMetadata *addfilesetArgs = psMetadataAlloc(); 61 psMetadataAddS64(addfilesetArgs, PS_LIST_TAIL, "-s ource_id", 0, "define source_id (required)", 0);62 psMetadataAddStr(addfilesetArgs, PS_LIST_TAIL, "-fileset", 0, "define fileset (required)", NULL);61 psMetadataAddS64(addfilesetArgs, PS_LIST_TAIL, "-src_id", 0, "define source_id (required)", 0); 62 psMetadataAddStr(addfilesetArgs, PS_LIST_TAIL, "-fileset", PS_META_DUPLICATE_OK, "define fileset (multiple OK, required)", NULL); 63 63 64 64 // -updatelast 65 65 psMetadata *updatelastArgs = psMetadataAlloc(); 66 psMetadataAddS64(updatelastArgs, PS_LIST_TAIL, "-s ource_id", 0, "define source_id (required)", 0);66 psMetadataAddS64(updatelastArgs, PS_LIST_TAIL, "-src_id", 0, "define source_id (required)", 0); 67 67 psMetadataAddStr(updatelastArgs, PS_LIST_TAIL, "-fileset", 0, "define last fileset (required)", NULL); 68 68 … … 72 72 psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL); 73 73 psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL); 74 psMetadataAddU64(pendingfilesetArgs, PS_LIST_TAIL, "-limit", 0, "limit result set", 0); 75 psMetadataAddBool(pendingfilesetArgs, PS_LIST_TAIL, "-simple", 0, "use simple output format?", false); 74 76 75 77 // -addfile … … 84 86 psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL); 85 87 psMetadataAddS64(pendingfileArgs, PS_LIST_TAIL, "-fileset_id", 0, "search on fileset_id", 0); 88 psMetadataAddU64(pendingfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set", 0); 89 psMetadataAddBool(pendingfileArgs, PS_LIST_TAIL, "-simple", 0, "use simple output format?", false); 86 90 87 91 // -addresult
Note:
See TracChangeset
for help on using the changeset viewer.
