- Timestamp:
- Feb 10, 2010, 3:52:15 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/ippTools/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
magicdstool.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ippTools/src
- Property svn:ignore
-
branches/eam_branches/20091201/ippTools/src/magicdstool.c
r25935 r26857 44 44 static bool tocleanupMode(pxConfig *config); 45 45 46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, ps Metadata *where, const char *state);46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psString extraSetString, psMetadata *where, const char *state); 47 47 48 48 # define MODECASE(caseName, func) \ … … 326 326 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 327 327 328 // optional 329 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 330 psString setString = NULL; 331 if (set_label) { 332 psStringAppend(&setString, ", label = '%s'", set_label); 333 } 334 328 335 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false); 329 336 if (magic_ds_id) { 330 337 331 return setmagicDSRunState(config, magic_ds_id, NULL, state);338 return setmagicDSRunState(config, magic_ds_id, setString, NULL, state); 332 339 333 340 } else if (!strcmp(state, "full")) { … … 336 343 } 337 344 // we can transition by query as well 345 338 346 339 347 psMetadata *where = psMetadataAlloc(); … … 342 350 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 343 351 344 345 352 if (psListLength(where->list) < 2) { 346 353 psError(PS_ERR_UNKNOWN, true, "at least 2 search arguments are required"); … … 353 360 psMetadataAddS32(where, PS_LIST_TAIL, "re_place", 0, ">", 0); 354 361 } 355 bool result = setmagicDSRunState(config, magic_ds_id, where, state);362 bool result = setmagicDSRunState(config, magic_ds_id, setString, where, state); 356 363 psFree(where); 357 364 … … 445 452 { 446 453 // first query the magicDSRun to find the stage and the stage_id 447 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64;454 psString query = "SELECT stage, stage_id, magic_id from magicDSRun where magic_ds_id = %" PRId64; 448 455 449 456 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { … … 472 479 psString stage= psMetadataLookupStr(NULL, row, "stage"); 473 480 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 481 psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id"); 474 482 475 483 ippStage stageNum = ippStringToStage(stage); … … 499 507 } 500 508 501 if (!p_psDBRunQueryF(config->dbh, query, magic_ ds_id, stage_id, component)) {509 if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id, component)) { 502 510 psError(PS_ERR_UNKNOWN, false, "database error"); 503 511 return false; … … 518 526 { 519 527 // first query the magicDSRun to find the stage and the stage_id 520 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64;528 psString query = "SELECT stage, stage_id, magic_id from magicDSRun where magic_ds_id = %" PRId64; 521 529 522 530 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { … … 545 553 psString stage = psMetadataLookupStr(NULL, row, "stage"); 546 554 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 555 psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id"); 547 556 548 557 ippStage stageNum = ippStringToStage(stage); … … 570 579 return false; 571 580 } 572 if (!p_psDBRunQueryF(config->dbh, query, magic_ ds_id, stage_id)) {581 if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id)) { 573 582 psError(PS_ERR_UNKNOWN, false, "database error"); 574 583 return false; … … 598 607 PXOPT_LOOKUP_STR(recovery_path_base, config->args, "-recovery_path_base", false, false); 599 608 PXOPT_LOOKUP_BOOL(setmagicked, config->args, "-setmagicked", false); 609 PXOPT_LOOKUP_F32(streak_frac, config->args, "-streak_frac", false, false); 610 PXOPT_LOOKUP_F32(run_time, config->args, "-run_time", false, false); 600 611 601 612 if (setmagicked && (fault != 0)) { … … 620 631 } 621 632 622 if (!magicDSFileInsert(config->dbh, magic_ds_id, component, backup_path_base, recovery_path_base, fault, "full")) { 633 if (!magicDSFileInsert(config->dbh, 634 magic_ds_id, 635 component, 636 backup_path_base, 637 recovery_path_base, 638 streak_frac, 639 run_time, 640 fault, 641 "full" // data_state 642 )) { 623 643 // rollback 624 644 if (!psDBRollback(config->dbh)) { … … 699 719 700 720 // set magicDSRun.state to 'full' 701 if (!setmagicDSRunState(config, magic_ds_id, NULL, "full")) {721 if (!setmagicDSRunState(config, magic_ds_id, NULL, NULL, "full")) { 702 722 psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64, 703 723 magic_ds_id); … … 901 921 if (!((strcmp(state, "new") == 0) || 902 922 (strcmp(state, "full") == 0) || 923 (strcmp(state, "failed_revert") == 0) || 924 (strcmp(state, "failed_cleanup") == 0) || 903 925 (strcmp(state, "restored") == 0) || 904 926 (strcmp(state, "censored") == 0) || … … 914 936 } 915 937 916 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, ps Metadata *where, const char *state)938 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psString extraSetStr, psMetadata *where, const char *state) 917 939 { 918 940 PS_ASSERT_PTR_NON_NULL(state, false); … … 924 946 } 925 947 926 psString query = psStringCopy("UPDATE magicDSRun SET state = '%s'"); 948 psString query = NULL; 949 psStringAppend(&query, "UPDATE magicDSRun SET state = '%s' %s\n", state, extraSetStr ? extraSetStr : ""); 927 950 if (magic_ds_id) { 928 951 psStringAppend(&query, " WHERE magic_ds_id = %" PRId64, magic_ds_id); … … 936 959 } 937 960 938 if (!p_psDBRunQuery F(config->dbh, query, state)) {961 if (!p_psDBRunQuery(config->dbh, query)) { 939 962 psError(PS_ERR_UNKNOWN, false, 940 963 "failed to change state for magic_id %" PRId64, magic_ds_id);
Note:
See TracChangeset
for help on using the changeset viewer.
