IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 3:52:15 PM (16 years ago)
Author:
eugene
Message:

various updates from trunk (mostly magic state handling, dqstats)

Location:
branches/eam_branches/20091201/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ippTools/src

    • Property svn:ignore
      •  

        old new  
        1616difftool
        1717disttool
         18dqstatstool
        1819faketool
        1920flatcorr
         
        3637stamp-h1
        3738warptool
         39
  • branches/eam_branches/20091201/ippTools/src/magicdstool.c

    r25935 r26857  
    4444static bool tocleanupMode(pxConfig *config);
    4545
    46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psMetadata *where, const char *state);
     46static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psString extraSetString, psMetadata *where, const char *state);
    4747
    4848# define MODECASE(caseName, func) \
     
    326326    PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false);
    327327
     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
    328335    PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false);
    329336    if (magic_ds_id) {
    330337
    331         return setmagicDSRunState(config, magic_ds_id, NULL, state);
     338        return setmagicDSRunState(config, magic_ds_id, setString, NULL, state);
    332339
    333340    } else if (!strcmp(state, "full")) {
     
    336343    }
    337344    // we can transition by query as well
     345
    338346
    339347    psMetadata *where = psMetadataAlloc();
     
    342350    PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");
    343351
    344 
    345352    if (psListLength(where->list) < 2) {
    346353        psError(PS_ERR_UNKNOWN, true, "at least 2 search arguments are required");
     
    353360        psMetadataAddS32(where, PS_LIST_TAIL, "re_place", 0, ">", 0);
    354361    }
    355     bool result = setmagicDSRunState(config, magic_ds_id, where, state);
     362    bool result = setmagicDSRunState(config, magic_ds_id, setString, where, state);
    356363    psFree(where);
    357364
     
    445452{
    446453    // 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;
    448455
    449456    if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) {
     
    472479    psString stage= psMetadataLookupStr(NULL, row, "stage");
    473480    psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id");
     481    psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id");
    474482
    475483    ippStage stageNum = ippStringToStage(stage);
     
    499507    }
    500508
    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)) {
    502510        psError(PS_ERR_UNKNOWN, false, "database error");
    503511        return false;
     
    518526{
    519527    // 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;
    521529
    522530    if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) {
     
    545553    psString stage = psMetadataLookupStr(NULL, row, "stage");
    546554    psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id");
     555    psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id");
    547556
    548557    ippStage stageNum = ippStringToStage(stage);
     
    570579        return false;
    571580    }
    572     if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id, stage_id)) {
     581    if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id)) {
    573582        psError(PS_ERR_UNKNOWN, false, "database error");
    574583        return false;
     
    598607    PXOPT_LOOKUP_STR(recovery_path_base, config->args, "-recovery_path_base", false, false);
    599608    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);
    600611
    601612    if (setmagicked && (fault != 0)) {
     
    620631    }
    621632
    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        )) {
    623643            // rollback
    624644        if (!psDBRollback(config->dbh)) {
     
    699719
    700720        // set magicDSRun.state to 'full'
    701         if (!setmagicDSRunState(config, magic_ds_id, NULL, "full")) {
     721        if (!setmagicDSRunState(config, magic_ds_id, NULL, NULL, "full")) {
    702722            psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64,
    703723                magic_ds_id);
     
    901921    if (!((strcmp(state, "new") == 0) ||
    902922          (strcmp(state, "full") == 0) ||
     923          (strcmp(state, "failed_revert") == 0) ||
     924          (strcmp(state, "failed_cleanup") == 0) ||
    903925          (strcmp(state, "restored") == 0) ||
    904926          (strcmp(state, "censored") == 0) ||
     
    914936}
    915937
    916 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psMetadata *where, const char *state)
     938static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psString extraSetStr, psMetadata *where, const char *state)
    917939{
    918940    PS_ASSERT_PTR_NON_NULL(state, false);
     
    924946    }
    925947
    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 : "");
    927950    if (magic_ds_id) {
    928951        psStringAppend(&query, " WHERE magic_ds_id = %" PRId64, magic_ds_id);
     
    936959    }
    937960
    938     if (!p_psDBRunQueryF(config->dbh, query, state)) {
     961    if (!p_psDBRunQuery(config->dbh, query)) {
    939962        psError(PS_ERR_UNKNOWN, false,
    940963                "failed to change state for magic_id %" PRId64, magic_ds_id);
Note: See TracChangeset for help on using the changeset viewer.