- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/magictool.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ippTools/src
- Property svn:ignore
-
old new 1 *.la 2 *.lo 1 3 .deps 2 4 .gdb_history … … 4 6 Makefile 5 7 Makefile.in 8 addtool 9 caltool 10 camtool 11 chiptool 6 12 config.h 7 13 config.h.in 8 stamp-h1 9 *.la 10 *.lo 14 detselect 15 dettool 16 difftool 17 disttool 18 dqstatstool 19 faketool 20 flatcorr 21 guidetool 22 magicdstool 23 magictool 24 pstamptool 25 pubtool 26 pxadmin 27 pxdata.c 28 pxinject 11 29 pxtoolsErrorCodes.c 12 30 pxtoolsErrorCodes.h 13 pxadmin14 pxinject15 pztool16 31 pzgetexp 17 32 pzgetimfiles 33 pztool 34 receivetool 18 35 regtool 19 guidetool 20 chiptool 21 camtool 36 stacktool 37 stamp-h1 22 38 warptool 23 difftool24 stacktool25 faketool26 dettool27 detselect28 pxdata.c29 magictool30 magicdstool31 caltool32 flatcorr33 pstamptool34 disttool35 receivetool36 37 pubtool
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ippTools/src/magictool.c
r24949 r27840 114 114 // Required 115 115 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 116 PXOPT_LOOKUP_STR(label, config->args, "-label", true, false); 116 117 117 118 // Optional 118 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 119 PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", false, false); 120 PXOPT_LOOKUP_STR(note, config->args, "-note", false, false); 119 121 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 120 122 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); … … 133 135 psString query = pxDataGet("magictool_definebyquery_select.sql"); 134 136 if (!query) { 135 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");137 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 136 138 return false; 137 139 } … … 149 151 // what if no skycells for the diff run completed? 150 152 151 if (!rerun) { 152 psStringAppend(&queryWhereStr, "\n%s magic_id IS NULL", queryWhereStr ? "AND" : "WHERE"); 153 psStringAppend(&queryWhereStr, "\n%s magic_id IS NULL", queryWhereStr ? "AND" : "WHERE"); 154 psString rerunWhereStr = NULL; 155 if (rerun) { 156 psStringAppend(&rerunWhereStr, "\n WHERE magicRun.label = '%s'", label); 153 157 } 154 158 … … 174 178 queryWhereStr = psStringCopy(""); 175 179 } 176 177 if (!p_psDBRunQueryF(config->dbh, query, diffWhereStr, diffWhereStr, queryWhereStr)) { 180 if (!rerunWhereStr) { 181 rerunWhereStr = psStringCopy(""); 182 } 183 184 if (!p_psDBRunQueryF(config->dbh, query, diffWhereStr, diffWhereStr, rerunWhereStr, queryWhereStr)) { 178 185 psError(PS_ERR_UNKNOWN, false, "database error"); 179 186 psFree(diffWhereStr); 180 187 psFree(queryWhereStr); 188 psFree(rerunWhereStr); 181 189 psFree(query); 182 190 return false; … … 184 192 psFree(diffWhereStr); 185 193 psFree(queryWhereStr); 194 psFree(rerunWhereStr); 186 195 psFree(query); 187 196 } … … 236 245 237 246 // create a new magicRun for this group 238 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, inverse, "new", workdir, "dirty", label, 239 dvodb, registered, 0); 247 magicRunRow *run = magicRunRowAlloc(0, 248 exp_id, 249 diff_id, 250 inverse, 251 "new", // state 252 workdir, 253 "dirty", // workdir_state 254 label, 255 data_group ? data_group : label, 256 dvodb, 257 registered, 258 0, // fault 259 note); 240 260 if (!run) { 241 261 psAbort("failed to alloc magicRun object"); … … 331 351 "dirty", // workdir_state 332 352 label, 353 NULL, // data_group 333 354 dvodb, 334 355 registered, 335 0 356 0, // fault 357 NULL 336 358 ); 337 359 … … 412 434 psString query = pxDataGet("magictool_inputskyfile.sql"); 413 435 if (!query) { 414 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");436 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 415 437 return false; 416 438 } … … 485 507 psString query = pxDataGet("magictool_totree.sql"); 486 508 if (!query) { 487 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");509 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 488 510 return false; 489 511 } … … 558 580 559 581 if (fault > 0) { 560 char *query = "UPDATE magicRun SET fault = %d , state = 'full'WHERE magic_id = %" PRId64;582 char *query = "UPDATE magicRun SET fault = %d WHERE magic_id = %" PRId64; 561 583 if (!p_psDBRunQueryF(config->dbh, query, fault, magic_id)) { 562 584 psError(PS_ERR_UNKNOWN, false, … … 597 619 return false; 598 620 } 621 psS32 numUpdated = psDBAffectedRows(config->dbh); 622 psLogMsg("magictool", PS_LOG_INFO, "Reverted %d magic runs", numUpdated); 623 599 624 return true; 600 625 } … … 620 645 psString query = pxDataGet("magictool_inputs.sql"); 621 646 if (!query) { 622 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");647 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 623 648 return false; 624 649 } … … 790 815 psString query = pxDataGet("magictool_toprocess_inputs.sql"); 791 816 if (!query) { 792 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");817 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 793 818 return false; 794 819 } … … 852 877 853 878 // look for tree nodes that need to be processed 879 880 // first find incomplete magicRuns 854 881 query = pxDataGet("magictool_toprocess_runs.sql"); 855 882 if (!query) { 856 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 857 return false; 858 } 859 883 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 884 return false; 885 } 886 887 // we limit the query even though it is cheap (only magic_id is selected) 888 889 // XXX: if the first 1000 unfinished magicRuns have no ready nodes 890 // that haven't faulted, later runs won't get returned even though 891 // they have work to do. When we used a limit of 100 we actually ran 892 // into this problem. Since we're using labels a limit of 1000 will 893 // probably be ok. 860 894 { 861 psString limitString = psDBGenerateLimitSQL( 100 );895 psString limitString = psDBGenerateLimitSQL( 1000 ); 862 896 psStringAppend(&query, " %s", limitString); 863 897 psFree(limitString); … … 895 929 query = pxDataGet("magictool_toprocess_tree.sql"); 896 930 if (!query) { 897 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");931 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 898 932 return false; 899 933 } … … 908 942 psAbort("failed to lookup value for magic_id column"); 909 943 } 910 944 911 945 whereString = NULL; 912 946 psStringAppend(&whereString, "\nAND (magic_id = %" PRId64 ")", magic_id); … … 1026 1060 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1027 1061 PXOPT_COPY_STR(config->args, where, "-node", "node", "=="); 1028 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");1029 1062 PXOPT_COPY_S16(config->args, where, "-fault", "magicNodeResult.fault", "=="); 1063 pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "=="); 1030 1064 1031 1065 psString query = pxDataGet("magictool_revertnode.sql"); 1032 1066 if (!query) { 1033 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1067 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1034 1068 return false; 1035 1069 } … … 1052 1086 1053 1087 psS32 numUpdated = psDBAffectedRows(config->dbh); 1054 psLogMsg("magictool", PS_LOG_INFO, " Updated %d magic nodes", numUpdated);1088 psLogMsg("magictool", PS_LOG_INFO, "Reverted %d magic nodes", numUpdated); 1055 1089 1056 1090 return true; … … 1068 1102 psString query = pxDataGet("magictool_tomask.sql"); 1069 1103 if (!query) { 1070 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1104 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1071 1105 return false; 1072 1106 } … … 1156 1190 psString query = pxDataGet("magictool_addmask.sql"); 1157 1191 if (!query) { 1158 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1192 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1159 1193 if (!psDBRollback(config->dbh)) { 1160 1194 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1263 1297 psString query = pxDataGet("magictool_mask.sql"); 1264 1298 if (!query) { 1265 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1299 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1266 1300 return false; 1267 1301 } … … 1393 1427 } 1394 1428 1395 static bool censorStage(pxConfig *config, psString stage, psString whereClause)1396 {1397 psString queryFile = NULL;1398 psStringAppend(&queryFile, "magictool_censor_%s.sql", stage);1399 psString query = pxDataGet(queryFile);1400 if (!query) {1401 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", queryFile);1402 psFree(queryFile);1403 if (!psDBRollback(config->dbh)) {1404 psError(PS_ERR_UNKNOWN, false, "database error");1405 }1406 return false;1407 }1408 psFree(queryFile);1409 1410 psStringAppend(&query, " WHERE %s", whereClause);1411 1412 if (!p_psDBRunQuery(config->dbh, query)) {1413 psError(PS_ERR_UNKNOWN, false, "database error");1414 psFree(query);1415 if (!psDBRollback(config->dbh)) {1416 psError(PS_ERR_UNKNOWN, false, "database error");1417 }1418 return false;1419 }1420 psFree(query);1421 1422 return true;1423 }1424 1425 1429 static bool censorrunMode(pxConfig *config) 1426 1430 { 1427 1431 PS_ASSERT_PTR_NON_NULL(config, false); 1428 1432 1429 psError(PS_ERR_PROGRAMMING, true, "-censorrun mode not ready yet");1430 return false;1431 1432 1433 psMetadata *where = psMetadataAlloc(); 1434 1435 PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", false, false); 1436 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 1437 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 1438 1439 if (!magic_id) { 1440 if (!exp_id && !label) { 1441 psError(PS_ERR_UNKNOWN, true, "either -magic_id or exp_id and label is required"); 1442 return false; 1443 } 1444 } 1433 1445 1434 1446 // at least one of these required 1435 1447 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1436 1448 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 1449 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1437 1450 1438 1451 if (!psListLength(where->list)) { … … 1470 1483 // Now queue any destreaked files to be re-verted 1471 1484 1472 // note: on failure censorStage issues the rollback1473 if (! censorStage(config, "raw", whereClause)) {1485 // note: on failure pxmagicRestoreStage issues the rollback 1486 if (!pxmagicRestoreStage(config, "raw", whereClause, "goto_censored")) { 1474 1487 psFree(whereClause); 1475 1488 return false; 1476 1489 } 1477 if (! censorStage(config, "chip", whereClause)) {1490 if (!pxmagicRestoreStage(config, "chip", whereClause, "goto_censored")) { 1478 1491 psFree(whereClause); 1479 1492 return false; 1480 1493 } 1481 if (! censorStage(config, "camera", whereClause)) {1494 if (!pxmagicRestoreStage(config, "camera", whereClause, "goto_censored")) { 1482 1495 psFree(whereClause); 1483 1496 return false; 1484 1497 } 1485 if (! censorStage(config, "warp", whereClause)) {1498 if (!pxmagicRestoreStage(config, "warp", whereClause, "goto_censored")) { 1486 1499 psFree(whereClause); 1487 1500 return false; 1488 1501 } 1489 if (! censorStage(config, "diff", whereClause)) {1502 if (!pxmagicRestoreStage(config, "diff", whereClause, "goto_censored")) { 1490 1503 psFree(whereClause); 1491 1504 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
