Changeset 25793
- Timestamp:
- Oct 7, 2009, 1:05:22 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (3 diffs)
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/pstamp.md (modified) (1 diff)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/pstamptool_pendingdependent.sql (added)
-
ippTools/share/pstamptool_pendingjob.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 diff)
-
ippTools/src/pstamptool.c (modified) (5 diffs)
-
ippTools/src/pstamptool.h (modified) (1 diff)
-
ippTools/src/pstamptoolConfig.c (modified) (3 diffs)
-
pstamp/scripts/pstampparse.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r25776 r25793 128 128 } 129 129 130 sub lookup { 130 sub lookup 131 { 131 132 my $ipprc = shift; 132 133 my $image_db = shift; … … 296 297 297 298 # if uri is nil this will get overridded below 298 # ( this isfor raw stage)299 # (we do this here for raw stage) 299 300 $out->{image} = $image->{uri}; 300 301 if ($set_class_id) { … … 302 303 $out->{component} = $class_id; 303 304 } 305 my $stage_id; 306 if ($img_type eq "raw") { 307 $stage_id = $image->{exp_id}; 308 } elsif ($img_type eq "chip") { 309 $stage_id = $image->{chip}; 310 } elsif ($img_type eq "warp") { 311 $stage_id = $image->{warp_id}; 312 } elsif ($img_type eq "diff") { 313 $stage_id = $image->{diff_id}; 314 } elsif ($img_type eq "stack") { 315 $stage_id = $image->{stack_id}; 316 } 317 $image->{stage_id} = $stage_id; 318 $image->{stage} = $img_type; 319 $image->{image_db} = $image_db; 304 320 305 321 # find the mask and weight images 306 322 if ($base) { 307 $out->{image} = $ipprc->filename($image_name, $base, $class_id) if $image_name;323 $out->{image} = $ipprc->filename($image_name, $base, $class_id) if $image_name; 308 324 $out->{mask} = $ipprc->filename($mask_name, $base, $class_id) if $mask_name; 309 325 $out->{weight} = $ipprc->filename($weight_name, $base, $class_id) if $weight_name; -
trunk/dbconfig/changes.txt
r25711 r25793 1300 1300 1301 1301 ALTER TABLE pstampJob ADD COLUMN options BIGINT; 1302 ALTER TABLE pstampJob ADD COLUMN dep_id BIGINT; 1303 CREATE TABLE pstampDependent ( 1304 dep_id BIGINT AUTO_INCREMENT, 1305 stage VARCHAR(64), 1306 stage_id BIGINT, 1307 need_magic TINYINT, 1308 image_db VARCHAR(64), 1309 rlabel VARCHAR(64), 1310 PRIMARY KEY(dep_id) 1311 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1312 -
trunk/dbconfig/pstamp.md
r25711 r25793 40 40 outputBase STR 255 41 41 options S64 64 42 dep_id S64 0 42 43 END 44 45 pstampDependent METADATA 46 dep_id S64 0 # Primary Key AUTO_INCREMENT 47 state STR 64 48 stage STR 64 49 stage_id S64 0 50 imagedb STR 64 51 rlabel STR 64 52 no_magic BOOL f 53 END -
trunk/ippTools/share/Makefile.am
r25789 r25793 201 201 pstamptool_datastore.sql \ 202 202 pstamptool_listjob.sql \ 203 pstamptool_pendingdependent.sql \ 203 204 pstamptool_pendingjob.sql \ 204 205 pstamptool_pendingreq.sql \ -
trunk/ippTools/share/pstamptool_pendingjob.sql
r25199 r25793 1 1 SELECT pstampJob.* 2 2 FROM pstampJob 3 JOIN pstampRequest using(req_id) 3 JOIN pstampRequest USING(req_id) 4 LEFT JOIN pstampDependent USING(dep_id) 4 5 WHERE pstampRequest.state = 'run' 5 6 AND pstampRequest.fault = 0 6 7 AND pstampJob.state = 'run' 7 8 AND pstampJob.fault = 0 9 AND (dep_id = 0 OR pstampDependent.state = 'full') -
trunk/ippTools/share/pxadmin_create_tables.sql
r25711 r25793 1250 1250 outputBase VARCHAR(255), 1251 1251 options BIGINT, 1252 dep_id BIGINT, 1252 1253 PRIMARY KEY(job_id, req_id), 1253 1254 KEY(job_id), 1254 1255 FOREIGN KEY(req_id) REFERENCES pstampRequest(req_id) 1256 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1257 1258 CREATE TABLE pstampDependent ( 1259 dep_id BIGINT AUTO_INCREMENT, 1260 state VARCHAR(64), 1261 stage VARCHAR(64), 1262 stage_id BIGINT, 1263 image_db VARCHAR(64), 1264 rlabel VARCHAR(64), 1265 need_magic TINYINT, 1266 PRIMARY KEY(dep_id) 1255 1267 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1256 1268 -
trunk/ippTools/src/pstamptool.c
r25711 r25793 48 48 static bool projectMode(pxConfig *config); 49 49 static bool modprojectMode(pxConfig *config); 50 static bool getdependentMode(pxConfig *config); 51 static bool pendingdependentMode(pxConfig *config); 52 static bool updatedependentMode(pxConfig *config); 50 53 51 54 # define MODECASE(caseName, func) \ … … 85 88 MODECASE(PSTAMPTOOL_MODE_MODPROJECT, modprojectMode); 86 89 MODECASE(PSTAMPTOOL_MODE_PROJECT, projectMode); 90 MODECASE(PSTAMPTOOL_MODE_GETDEPENDENT, getdependentMode); 91 MODECASE(PSTAMPTOOL_MODE_PENDINGDEPENDENT, pendingdependentMode); 92 MODECASE(PSTAMPTOOL_MODE_UPDATEDEPENDENT, updatedependentMode); 87 93 default: 88 94 psAbort("invalid option (this should not happen)"); … … 545 551 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 546 552 PXOPT_LOOKUP_S64(options, config->args, "-options", false, false); 553 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", false, false); 547 554 548 555 // unless the job is being inserted with stop state require outputBase … … 570 577 exp_id, 571 578 outputBase, 572 options 579 options, 580 dep_id 573 581 )) { 574 582 psError(PS_ERR_UNKNOWN, false, "database error"); … … 896 904 } 897 905 906 static bool getdependentMode(pxConfig *config) 907 { 908 PS_ASSERT_PTR_NON_NULL(config, false); 909 910 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 911 PXOPT_LOOKUP_S64(stage_id, config->args, "-stage_id", true, false); 912 PXOPT_LOOKUP_STR(imagedb, config->args, "-imagedb", true, false); 913 PXOPT_LOOKUP_STR(rlabel, config->args, "-rlabel", false, false); 914 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 915 PXOPT_LOOKUP_BOOL(no_create, config->args, "-no_create", false); 916 917 psString query = pxDataGet("pstamptool_pendingdependent.sql"); 918 if (!query) { 919 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 920 return false; 921 } 922 if (!p_psDBRunQuery(config->dbh, query)) { 923 psError(PS_ERR_UNKNOWN, false, "database error"); 924 psFree(query); 925 return false; 926 } 927 psFree(query); 928 929 psArray *output = p_psDBFetchResult(config->dbh); 930 if (!output) { 931 psError(PS_ERR_UNKNOWN, false, "database error"); 932 return false; 933 } 934 if (psArrayLength(output)) { 935 psMetadata *dep = output->data[0]; 936 psS64 dep_id = psMetadataLookupS64(NULL, dep, "dep_id"); 937 if (!dep_id) { 938 psError(PS_ERR_UNKNOWN, false, "database error"); 939 return false; 940 } 941 printf("%" PRId64 "\n", dep_id); 942 return true; 943 } 944 if (no_create) { 945 return true; 946 } 947 // no existing dependent that matches, insert one 948 949 if (!pstampDependentInsert( 950 config->dbh, 951 0, // dep_id 952 "new", // state 953 stage, 954 stage_id, 955 imagedb, 956 rlabel, 957 no_magic 958 )) { 959 psError(PS_ERR_UNKNOWN, false, "failed to insert pstampDependent"); 960 return false; 961 } 962 963 psS64 dep_id = psDBLastInsertID(config->dbh); 964 965 printf("%" PRId64 "\n", dep_id); 966 967 return true; 968 } 969 970 static bool pendingdependentMode(pxConfig *config) 971 { 972 PS_ASSERT_PTR_NON_NULL(config, false); 973 974 psMetadata *where = psMetadataAlloc(); 975 976 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 977 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 978 979 psString query = pxDataGet("pstamptool_pendingdependent.sql"); 980 if (!query) { 981 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 982 return false; 983 } 984 985 if (psListLength(where->list)) { 986 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampDependent"); 987 psStringAppend(&query, " AND %s", whereClause); 988 psFree(whereClause); 989 } 990 psFree(where); 991 992 // treat limit == 0 as "no limit" 993 if (limit) { 994 psString limitString = psDBGenerateLimitSQL(limit); 995 psStringAppend(&query, " %s", limitString); 996 psFree(limitString); 997 } 998 999 if (!p_psDBRunQuery(config->dbh, query)) { 1000 psError(PS_ERR_UNKNOWN, false, "database error"); 1001 psFree(query); 1002 return false; 1003 } 1004 psFree(query); 1005 1006 psArray *output = p_psDBFetchResult(config->dbh); 1007 if (!output) { 1008 psError(PS_ERR_UNKNOWN, false, "database error"); 1009 return false; 1010 } 1011 if (!psArrayLength(output)) { 1012 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 1013 psFree(output); 1014 return true; 1015 } 1016 1017 // negative simple so the default is true 1018 if (!ippdbPrintMetadatas(stdout, output, "pstampDependent", !simple)) { 1019 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1020 psFree(output); 1021 return false; 1022 } 1023 1024 psFree(output); 1025 1026 return true; 1027 } 1028 static bool updatedependentMode(pxConfig *config) 1029 { 1030 PS_ASSERT_PTR_NON_NULL(config, false); 1031 1032 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", true, false); 1033 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 1034 1035 char *query ="UPDATE pstampDependent" 1036 " SET state = '%s'" 1037 " WHERE dep_id = %" PRId64; 1038 1039 if (!p_psDBRunQueryF(config->dbh, query, state, dep_id)) { 1040 psError(PS_ERR_UNKNOWN, false, "database error"); 1041 psFree(query); 1042 return false; 1043 } 1044 1045 psU64 affected = psDBAffectedRows(config->dbh); 1046 if (affected != 1) { 1047 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 1048 PRIu64 " rows were modified", affected); 1049 return false; 1050 } 1051 1052 return true; 1053 } -
trunk/ippTools/src/pstamptool.h
r25199 r25793 43 43 PSTAMPTOOL_MODE_MODPROJECT, 44 44 PSTAMPTOOL_MODE_PROJECT, 45 PSTAMPTOOL_MODE_GETDEPENDENT, 46 PSTAMPTOOL_MODE_PENDINGDEPENDENT, 47 PSTAMPTOOL_MODE_UPDATEDEPENDENT, 45 48 } pstamptoolMode; 46 49 -
trunk/ippTools/src/pstamptoolConfig.c
r25711 r25793 112 112 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-exp_id", 0, "define exposure id", 0); 113 113 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-options", 0, "define options", 0); 114 psMetadataAddS64(addjobArgs, PS_LIST_TAIL, "-dep_id", 0, "define job dep_id", 0); 114 115 psMetadataAddS16(addjobArgs, PS_LIST_TAIL, "-fault", 0, "define job result", 0); 115 116 … … 143 144 psMetadataAddBool(revertjobArgs, PS_LIST_TAIL, "-all", 0, "revert all faulted jobs", false); 144 145 psMetadataAddU64(revertjobArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 146 147 // -getdependent 148 psMetadata *getdependentArgs = psMetadataAlloc(); 149 psMetadataAddS64(getdependentArgs, PS_LIST_TAIL, "-stage_id", 0, "define id for dependent run (required)", 0); 150 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-stage", 0, "define stage for dependent run (required)", NULL); 151 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-imagedb", 0, "define imagedb for depenent run (required)", NULL); 152 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-rlabel", 0, "define label for dependent run", NULL); 153 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-no_magic", 0, "define no_magic", false); 154 psMetadataAddBool(getdependentArgs,PS_LIST_TAIL, "-no_create", 0, "if no run exists do not create one", false); 155 156 // -updatedependent 157 psMetadata *updatedependentArgs = psMetadataAlloc(); 158 psMetadataAddS64(updatedependentArgs, PS_LIST_TAIL, "-dep_id", 0, "define id for dependent run (required)", 0); 159 psMetadataAddStr(updatedependentArgs, PS_LIST_TAIL, "-set_state", 0, "new value for state (required)", NULL); 160 161 // -pendingdependent 162 psMetadata *pendingdependentArgs = psMetadataAlloc(); 163 psMetadataAddS64(pendingdependentArgs, PS_LIST_TAIL, "-stage_id", 0, "define id for dependent run", 0); 164 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-stage", 0, "define stage for dependent run", NULL); 165 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-imagedb", 0, "define imagedb for depenent run", NULL); 166 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-rlabel", 0, "define label for dependent run", NULL); 167 psMetadataAddBool(pendingdependentArgs,PS_LIST_TAIL, "-no_magic", 0, "define no_magic", false); 168 psMetadataAddBool(pendingdependentArgs,PS_LIST_TAIL, "-no_create", 0, "if no run exists do not create one", false); 169 psMetadataAddU64(pendingdependentArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 170 psMetadataAddBool(pendingdependentArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 145 171 146 172 // -addproject … … 189 215 PXOPT_ADD_MODE("-moddatastore", "", PSTAMPTOOL_MODE_MODDATASTORE, moddatastoreArgs); 190 216 217 PXOPT_ADD_MODE("-getdependent", "", PSTAMPTOOL_MODE_GETDEPENDENT, getdependentArgs); 218 PXOPT_ADD_MODE("-updatedependent", "", PSTAMPTOOL_MODE_UPDATEDEPENDENT, updatedependentArgs); 219 PXOPT_ADD_MODE("-pendingdependent","", PSTAMPTOOL_MODE_PENDINGDEPENDENT, pendingdependentArgs); 220 191 221 PXOPT_ADD_MODE("-addproject", "", PSTAMPTOOL_MODE_ADDPROJECT, addprojectArgs); 192 222 PXOPT_ADD_MODE("-modproject", "", PSTAMPTOOL_MODE_MODPROJECT, modprojectArgs); -
trunk/pstamp/scripts/pstampparse.pl
r25776 r25793 72 72 } 73 73 74 # just deal with these arguments once and for all 75 $pstamptool .= " -dbname $dbname" if $dbname; 76 $pstamptool .= " -dbserver $dbserver" if $dbserver; 77 74 78 # list_job is a deugging mode 75 79 $no_update = 1 if $mode eq "list_job"; … … 105 109 if ($req_id and !$no_update) { 106 110 my $command = "$pstamptool -listreq -name $req_name -not_req_id $req_id"; 107 $command .= " -dbname $dbname" if $dbname;108 $command .= " -dbserver $dbserver" if $dbserver;109 111 # no verbose so that error message about request not found doesn't appear in parse_error.txt 110 112 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 127 129 my $command = "$pstamptool -updatereq -req_id $req_id -name $req_name"; 128 130 $command .= " -outProduct $product"; 129 $command .= " -dbname $dbname" if $dbname;130 $command .= " -dbserver $dbserver" if $dbserver;131 131 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 132 run(command => $command, verbose => $verbose); … … 398 398 my $newState = "run"; 399 399 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 403 408 $newState = 'stop'; 404 409 $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 } 410 422 } 411 423 } … … 416 428 $command .= " -fault $fault" if $fault; 417 429 $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; 420 431 421 432 if ($mode eq "list_job") { … … 594 605 my $command = "$pstamptool -addjob -req_id $req_id -job_type $job_type" 595 606 . " -rownum $rownum -state stop -fault $fault"; 596 $command .= " -dbname $dbname" if $dbname;597 $command .= " -dbserver $dbserver" if $dbserver;598 607 599 608 if ($mode eq "list_job") { … … 718 727 } 719 728 729 sub 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 720 761 sub my_die 721 762 {
Note:
See TracChangeset
for help on using the changeset viewer.
