Changeset 32795
- Timestamp:
- Nov 23, 2011, 2:34:18 PM (15 years ago)
- Location:
- tags/ipp-20111110
- Files:
-
- 1 added
- 10 edited
-
dbconfig/pstamp.md (modified) (1 diff, 1 prop)
-
ippTools/share/Makefile.am (modified) (1 diff, 1 prop)
-
ippTools/share/pstamptool_listfile.sql (added)
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 diff, 1 prop)
-
ippTools/src/pstamptool.c (modified) (3 diffs, 1 prop)
-
ippTools/src/pstamptool.h (modified) (1 diff, 1 prop)
-
ippTools/src/pstamptoolConfig.c (modified) (2 diffs, 1 prop)
-
pstamp (modified) (1 prop)
-
pstamp/scripts/pstamp_cleanup.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_get_image_job.pl (modified) (7 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20111110/dbconfig/pstamp.md
- Property svn:mergeinfo set to
r30314 r32795 67 67 num S64 0 # Primary Key AUTO_INCREMENT 68 68 END 69 70 pstampFile METADATA 71 file_id S64 0 # Primary Key AUTO_INCREMENT 72 job_id S64 0 73 path STR 255 74 end -
tags/ipp-20111110/ippTools/share/Makefile.am
- Property svn:mergeinfo set to
r32709 r32795 308 308 pstamptool_getdependent.sql \ 309 309 pstamptool_listjob.sql \ 310 pstamptool_listfile.sql \ 310 311 pstamptool_pendingcleanup.sql \ 311 312 pstamptool_pendingdependent.sql \ -
tags/ipp-20111110/ippTools/share/pxadmin_create_tables.sql
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20111110/ippTools/share/pxadmin_create_tables.sql (added) merged: 32694 /trunk/ippTools/share/pxadmin_create_tables.sql (added) merged: 32695,32771
r32634 r32795 1479 1479 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1480 1480 1481 CREATE TABLE pstampFile ( 1482 file_id BIGINT AUTO_INCREMENT, 1483 job_id BIGINT NOT NULL, 1484 path VARCHAR(255), 1485 PRIMARY KEY(file_id), 1486 KEY(job_id) 1487 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1488 1481 1489 CREATE TABLE pstampWebRequest ( 1482 1490 num BIGINT AUTO_INCREMENT, - Property svn:mergeinfo changed
-
tags/ipp-20111110/ippTools/src/pstamptool.c
- Property svn:mergeinfo set to
r32360 r32795 56 56 static bool revertdependentMode(pxConfig *config); 57 57 static bool getwebrequestnumMode(pxConfig *config); 58 static bool addfileMode(pxConfig *config); 59 static bool listfileMode(pxConfig *config); 60 static bool deletefileMode(pxConfig *config); 58 61 59 62 # define MODECASE(caseName, func) \ … … 103 106 MODECASE(PSTAMPTOOL_MODE_REVERTDEPENDENT, revertdependentMode); 104 107 MODECASE(PSTAMPTOOL_MODE_GETWEBREQUESTNUM, getwebrequestnumMode); 108 MODECASE(PSTAMPTOOL_MODE_ADDFILE, addfileMode); 109 MODECASE(PSTAMPTOOL_MODE_LISTFILE, listfileMode); 110 MODECASE(PSTAMPTOOL_MODE_DELETEFILE, deletefileMode); 105 111 default: 106 112 psAbort("invalid option (this should not happen)"); … … 1476 1482 return true; 1477 1483 } 1484 1485 static bool addfileMode(pxConfig *config) 1486 { 1487 PS_ASSERT_PTR_NON_NULL(config, false); 1488 1489 PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false); 1490 PXOPT_LOOKUP_STR(path, config->args, "-path", true, false); 1491 1492 if (!pstampFileInsert(config->dbh, 1493 0, // file_id 1494 job_id, 1495 path 1496 )) { 1497 psError(PS_ERR_UNKNOWN, false, "database error"); 1498 return false; 1499 } 1500 1501 psU64 affected = psDBAffectedRows(config->dbh); 1502 if (affected != 1) { 1503 psError(PS_ERR_UNKNOWN, false, 1504 "should have affected one row but %" PRIu64 " rows were modified", 1505 affected); 1506 return false; 1507 } 1508 1509 psS64 file_id = psDBLastInsertID(config->dbh); 1510 printf("%" PRId64 "\n", file_id); 1511 1512 return true; 1513 } 1514 1515 static bool listfileMode(pxConfig *config) 1516 { 1517 PS_ASSERT_PTR_NON_NULL(config, false); 1518 1519 psMetadata *where = psMetadataAlloc(); 1520 PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "=="); 1521 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 1522 PXOPT_COPY_S64(config->args, where, "-file_id", "file_id", "=="); 1523 1524 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1525 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1526 1527 if (!psListLength(where->list)) { 1528 fprintf(stderr, "search arguments are required\n"); 1529 exit (1); 1530 } 1531 1532 psString query = pxDataGet("pstamptool_listfile.sql"); 1533 if (!query) { 1534 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1535 return false; 1536 } 1537 1538 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 1539 if (psListLength(where->list)) { 1540 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1541 psStringAppend(&query, " WHERE %s", whereClause); 1542 psFree(whereClause); 1543 } 1544 psFree(where); 1545 1546 // treat limit == 0 as "no limit" 1547 if (limit) { 1548 psString limitString = psDBGenerateLimitSQL(limit); 1549 psStringAppend(&query, " %s", limitString); 1550 psFree(limitString); 1551 } 1552 1553 if (!p_psDBRunQuery(config->dbh, query)) { 1554 psError(PS_ERR_UNKNOWN, false, "database error"); 1555 psFree(query); 1556 return false; 1557 } 1558 psFree(query); 1559 1560 psArray *output = p_psDBFetchResult(config->dbh); 1561 if (!output) { 1562 psError(PS_ERR_UNKNOWN, false, "database error"); 1563 return false; 1564 } 1565 if (!psArrayLength(output)) { 1566 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 1567 psFree(output); 1568 return true; 1569 } 1570 1571 // negative simple so the default is true 1572 if (!ippdbPrintMetadatas(stdout, output, "pstampFile", !simple)) { 1573 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1574 psFree(output); 1575 return false; 1576 } 1577 1578 psFree(output); 1579 1580 return true; 1581 } 1582 1583 static bool deletefileMode(pxConfig *config) 1584 { 1585 PS_ASSERT_PTR_NON_NULL(config, false); 1586 1587 PXOPT_LOOKUP_S64(job_id, config->args, "-job_id", true, false); 1588 1589 psString query = NULL; 1590 psStringAppend(&query, "DELETE FROM pstampFile WHERE job_id = %" PRId64, job_id); 1591 1592 if (!p_psDBRunQuery(config->dbh, query)) { 1593 psError(PS_ERR_UNKNOWN, false, "database error"); 1594 psFree(query); 1595 return false; 1596 } 1597 psFree(query); 1598 1599 psU64 affected = psDBAffectedRows(config->dbh); 1600 psLogMsg("pstamptool", PS_LOG_INFO, "Deleted %" PRIu64 " rows from pstampFile", affected); 1601 1602 return true; 1603 } -
tags/ipp-20111110/ippTools/src/pstamptool.h
- Property svn:mergeinfo set to
r29248 r32795 50 50 PSTAMPTOOL_MODE_REVERTDEPENDENT, 51 51 PSTAMPTOOL_MODE_GETWEBREQUESTNUM, 52 PSTAMPTOOL_MODE_ADDFILE, 53 PSTAMPTOOL_MODE_LISTFILE, 54 PSTAMPTOOL_MODE_DELETEFILE, 52 55 } pstamptoolMode; 53 56 -
tags/ipp-20111110/ippTools/src/pstamptoolConfig.c
- Property svn:mergeinfo set to
r30543 r32795 274 274 psMetadata *modes = psMetadataAlloc(); 275 275 276 // -addfile 277 psMetadata *addfileArgs = psMetadataAlloc(); 278 psMetadataAddS64(addfileArgs, PS_LIST_TAIL, "-job_id", 0, "define job ID for file (required)", 0); 279 psMetadataAddStr(addfileArgs, PS_LIST_TAIL, "-path", 0, "define path for file (required)", NULL); 280 281 // -listfile 282 psMetadata *listfileArgs = psMetadataAlloc(); 283 psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-file_id", 0, "select by file ID", 0); 284 psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-job_id", 0, "select by job ID", 0); 285 psMetadataAddS64(listfileArgs, PS_LIST_TAIL, "-req_id", 0, "select by request ID", 0); 286 psMetadataAddU64(listfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 287 psMetadataAddBool(listfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 288 289 // -deletefile 290 psMetadata *deletefileArgs = psMetadataAlloc(); 291 psMetadataAddS64(deletefileArgs, PS_LIST_TAIL, "-job_id", 0, "select by job ID (required)", 0); 292 276 293 PXOPT_ADD_MODE("-addreq", "", PSTAMPTOOL_MODE_ADDREQ, addreqArgs); 277 294 PXOPT_ADD_MODE("-pendingreq", "", PSTAMPTOOL_MODE_PENDINGREQ, pendingreqArgs); … … 302 319 PXOPT_ADD_MODE("-project", "", PSTAMPTOOL_MODE_PROJECT, projectArgs); 303 320 PXOPT_ADD_MODE("-getwebrequestnum","", PSTAMPTOOL_MODE_GETWEBREQUESTNUM, getwebrequestnumArgs); 321 PXOPT_ADD_MODE("-addfile", "", PSTAMPTOOL_MODE_ADDFILE, addfileArgs); 322 PXOPT_ADD_MODE("-listfile", "", PSTAMPTOOL_MODE_LISTFILE, listfileArgs); 323 PXOPT_ADD_MODE("-deletefile", "", PSTAMPTOOL_MODE_DELETEFILE, deletefileArgs); 304 324 305 325 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
tags/ipp-20111110/pstamp
- Property svn:mergeinfo set to
-
tags/ipp-20111110/pstamp/scripts/pstamp_cleanup.pl
r27874 r32795 23 23 24 24 use PS::IPP::Config qw( :standard ); 25 use PS::IPP::PStamp::Job qw( :standard ); 25 26 26 27 my $req_id; … … 95 96 } 96 97 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 97 116 # now go find the workdir for this request 98 117 # XXX: we finally *have* to store this in the database -
tags/ipp-20111110/pstamp/scripts/pstamp_get_image_job.pl
r30663 r32795 25 25 26 26 my $output_base; 27 my $bundleroot; 27 28 28 29 my $verbose; 29 my $i pprc;30 my $imagedbname; 30 31 my $dbname; 31 32 my $dbserver; … … 41 42 'rownum=s' => \$rownum, 42 43 'output_base=s' => \$output_base, 44 'bundleroot=s' => \$bundleroot, 45 'imagedbname=s' => \$imagedbname, 43 46 'dbname=s' => \$dbname, 44 47 'dbserver=s' => \$dbserver, … … 52 55 53 56 my_die( $err, $PS_EXIT_PROG_ERROR) if $err; 57 58 my $ipprc = PS::IPP::Config->new(); 54 59 55 60 my $params_file = $output_base . ".mdc"; … … 91 96 my $missing_tools; 92 97 my $dist_bundle = can_run('dist_bundle.pl') or (warn "Can't find dist_bundle.pl" and $missing_tools = 1); 98 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 93 99 if ($missing_tools) { 94 100 warn("Can't find required tools."); … … 96 102 } 97 103 104 $pstamptool .= " -dbname $dbname" if $dbname; 105 $pstamptool .= " -dbserver $dbserver" if $dbserver; 106 98 107 my $outdir = dirname($output_base); 99 108 my $basename = basename($path_base); 100 my $outroot = $output_base ."_" . $basename;101 109 my $results_file = $output_base . ".bundle_results"; 110 my $outroot; 111 if ($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 } 102 123 103 124 { … … 105 126 $command .= " --results_file $results_file"; 106 127 $command .= " --component $component --path_base $path_base --outroot $outroot"; 107 # XXX: we need to do some work if we want to support muggle bundles108 # $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"; 109 130 $command .= " --magicked" if $magicked; 110 $command .= " --dbname $ dbname" if $dbname;131 $command .= " --dbname $imagedbname" if $imagedbname; 111 132 $command .= " --verbose" if $verbose; 112 133 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 147 168 } 148 169 170 if ($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 149 202 print REGLIST "$file_name|$bytes|$md5sum|tgz|\n"; 150 203 -
tags/ipp-20111110/pstamp/scripts/pstamp_job_run.pl
r31508 r32795 88 88 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 89 89 90 my $params = read_params_file($outputBase); 91 90 92 my $jobStatus; 91 93 if ($jobType eq "stamp") { 92 my $params = read_params_file($outputBase);93 94 94 95 my $argString; … … 272 273 } elsif ($jobType eq "get_image") { 273 274 274 my $uri = ""; 275 my $pstamp_bundle_root = metadataLookupStr($ipprc->{_siteConfig}, "PSTAMP_BUNDLE_ROOT"); 276 my $imagedb = $params->{imagedb}; 277 275 278 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; 276 281 $command .= " --dbname $dbname" if $dbname; 277 282 $command .= " --dbserver $dbserver" if $dbserver;
Note:
See TracChangeset
for help on using the changeset viewer.
