IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23885 for trunk/ippTools/src


Ignore:
Timestamp:
Apr 16, 2009, 12:39:27 PM (17 years ago)
Author:
Paul Price
Message:

Modifying distribution client workflow (currently composed of receivetool and associated tables) since Bill points out that a fileset is composed of files, and we don't want to download them all serially.

Location:
trunk/ippTools/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/receivetool.c

    r23880 r23885  
    3333static bool definesourceMode(pxConfig *config);
    3434static bool listMode(pxConfig *config);
    35 static bool definerunMode(pxConfig *config);
     35static bool addfilesetMode(pxConfig *config);
    3636static bool updatelastMode(pxConfig *config);
    37 static bool pendingrunMode(pxConfig *config);
     37static bool pendingfilesetMode(pxConfig *config);
     38static bool addfileMode(pxConfig *config);
     39static bool pendingfileMode(pxConfig *config);
    3840static bool addresultMode(pxConfig *config);
    3941static bool revertMode(pxConfig *config);
     
    6062        MODECASE(RECEIVETOOL_MODE_DEFINESOURCE, definesourceMode);
    6163        MODECASE(RECEIVETOOL_MODE_LIST, listMode);
    62         MODECASE(RECEIVETOOL_MODE_DEFINERUN, definerunMode);
     64        MODECASE(RECEIVETOOL_MODE_ADDFILESET, addfilesetMode);
    6365        MODECASE(RECEIVETOOL_MODE_UPDATELAST, updatelastMode);
    64         MODECASE(RECEIVETOOL_MODE_PENDINGRUN, pendingrunMode);
     66        MODECASE(RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetMode);
     67        MODECASE(RECEIVETOOL_MODE_ADDFILE, addfileMode);
     68        MODECASE(RECEIVETOOL_MODE_PENDINGFILE, pendingfileMode);
    6569        MODECASE(RECEIVETOOL_MODE_ADDRESULT, addresultMode);
    6670        MODECASE(RECEIVETOOL_MODE_REVERT, revertMode);
     
    100104
    101105    if (!receiveSourceInsert(config->dbh, 0, source, product, workdir, comment, last)) {
    102         psError(PS_ERR_UNKNOWN, false, "database error");
     106        psError(PS_ERR_UNKNOWN, false, "Database error");
    103107        return false;
    104108    }
     
    159163}
    160164
    161 static bool definerunMode(pxConfig *config)
     165static bool addfilesetMode(pxConfig *config)
    162166{
    163167    PS_ASSERT_PTR_NON_NULL(config, false);
     
    167171    PXOPT_LOOKUP_STR(fileset, config->args, "-fileset",  true, false);
    168172
    169     if (!receiveRunInsert(config->dbh, 0, source_id, fileset)) {
    170         psError(PS_ERR_UNKNOWN, false, "database error");
     173    if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) {
     174        psError(PS_ERR_UNKNOWN, false, "Database error");
    171175        return false;
    172176    }
     
    198202
    199203
    200 static bool pendingrunMode(pxConfig *config)
     204static bool pendingfilesetMode(pxConfig *config)
    201205{
    202206    PS_ASSERT_PTR_NON_NULL(config, false);
     
    207211    PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
    208212    PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "==");
    209     PXOPT_COPY_S64(config->args, where, "-comment", "receiveSource.comment", "LIKE");
    210 
    211     psString query = pxDataGet("receivetool_pendingrun.sql");
     213    PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE");
     214
     215    psString query = pxDataGet("receivetool_pendingfileset.sql");
    212216    if (!query) {
    213217        psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement");
     
    240244        return true;
    241245    }
    242     if (!ippdbPrintMetadatas(stdout, output, "receiveRun", true)) {
     246    if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", true)) {
    243247        psError(PS_ERR_UNKNOWN, false, "Failed to print array");
    244248        psFree(output);
     
    250254}
    251255
     256static bool addfileMode(pxConfig *config)
     257{
     258    PS_ASSERT_PTR_NON_NULL(config, false);
     259
     260    // required
     261    PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false);
     262    PXOPT_LOOKUP_STR(file, config->args, "-file",  true, false);
     263
     264    if (!receiveFileInsert(config->dbh, 0, fileset_id, file)) {
     265        psError(PS_ERR_UNKNOWN, false, "Database error");
     266        return false;
     267    }
     268
     269    return true;
     270}
     271
     272static bool pendingfileMode(pxConfig *config)
     273{
     274    PS_ASSERT_PTR_NON_NULL(config, false);
     275
     276    psMetadata *where = psMetadataAlloc(); // WHERE conditions
     277
     278    // required
     279    PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
     280    PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "==");
     281    PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE");
     282    PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "==");
     283
     284    psString query = pxDataGet("receivetool_pendingfile.sql");
     285    if (!query) {
     286        psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement");
     287        psFree(where);
     288        return false;
     289    }
     290
     291    if (psListLength(where->list)) {
     292        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     293        psStringAppend(&query, " AND %s", whereClause);
     294        psFree(whereClause);
     295    }
     296    psFree(where);
     297
     298    if (!p_psDBRunQueryF(config->dbh, query)) {
     299        psError(PS_ERR_UNKNOWN, false, "Database error");
     300        psFree(query);
     301        return false;
     302    }
     303    psFree(query);
     304
     305    psArray *output = p_psDBFetchResult(config->dbh);
     306    if (!output) {
     307        psError(PS_ERR_UNKNOWN, false, "Database error");
     308        return false;
     309    }
     310    if (!psArrayLength(output)) {
     311        psTrace("receivetool", PS_LOG_INFO, "No rows found");
     312        psFree(output);
     313        return true;
     314    }
     315    if (!ippdbPrintMetadatas(stdout, output, "receiveFile", true)) {
     316        psError(PS_ERR_UNKNOWN, false, "Failed to print array");
     317        psFree(output);
     318        return false;
     319    }
     320    psFree(output);
     321
     322    return true;
     323}
     324
    252325static bool addresultMode(pxConfig *config)
    253326{
     
    255328
    256329    // required
    257     PXOPT_LOOKUP_S64(receive_id, config->args, "-source_id", true, false);
     330    PXOPT_LOOKUP_S64(fileset_id, config->args, "-source_id", true, false);
    258331
    259332    // optional
     
    262335    PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false);
    263336
    264     if (!receiveResultInsert(config->dbh, receive_id, dtime_copy, dtime_extract, fault)) {
     337    if (!receiveResultInsert(config->dbh, fileset_id, dtime_copy, dtime_extract, fault)) {
    265338        psError(PS_ERR_UNKNOWN, false, "Database error");
    266339        return false;
     
    276349    psMetadata *where = psMetadataAlloc(); // WHERE conditions
    277350
    278     PXOPT_COPY_S64(config->args, where, "-receive_id", "receiveResult.receive_id", "==");
     351    PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveResult.fileset_id", "==");
    279352    PXOPT_COPY_S32(config->args, where, "-fault", "receiveResult.fault", "==");
    280353    PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
  • trunk/ippTools/src/receivetool.h

    r23880 r23885  
    2727    RECEIVETOOL_MODE_DEFINESOURCE,
    2828    RECEIVETOOL_MODE_LIST,
    29     RECEIVETOOL_MODE_DEFINERUN,
     29    RECEIVETOOL_MODE_ADDFILESET,
    3030    RECEIVETOOL_MODE_UPDATELAST,
    31     RECEIVETOOL_MODE_PENDINGRUN,
     31    RECEIVETOOL_MODE_PENDINGFILESET,
     32    RECEIVETOOL_MODE_ADDFILE,
     33    RECEIVETOOL_MODE_PENDINGFILE,
    3234    RECEIVETOOL_MODE_ADDRESULT,
    3335    RECEIVETOOL_MODE_REVERT,
  • trunk/ippTools/src/receivetoolConfig.c

    r23880 r23885  
    5757    psMetadataAddStr(listArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
    5858
    59     // -definerun
    60     psMetadata *definerunArgs = psMetadataAlloc();
    61     psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-source_id", 0, "define source_id (required)", 0);
    62     psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-fileset", 0, "define fileset (required)", NULL);
     59    // -addfileset
     60    psMetadata *addfilesetArgs = psMetadataAlloc();
     61    psMetadataAddS64(addfilesetArgs, PS_LIST_TAIL, "-source_id", 0, "define source_id (required)", 0);
     62    psMetadataAddStr(addfilesetArgs, PS_LIST_TAIL, "-fileset", 0, "define fileset (required)", NULL);
    6363
    6464    // -updatelast
     
    6767    psMetadataAddStr(updatelastArgs, PS_LIST_TAIL, "-fileset", 0, "define last fileset (required)", NULL);
    6868
    69     // -pendingrun
    70     psMetadata *pendingrunArgs = psMetadataAlloc();
    71     psMetadataAddStr(pendingrunArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
    72     psMetadataAddStr(pendingrunArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL);
    73     psMetadataAddStr(pendingrunArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
     69    // -pendingfileset
     70    psMetadata *pendingfilesetArgs = psMetadataAlloc();
     71    psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
     72    psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL);
     73    psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
     74
     75    // -addfile
     76    psMetadata *addfileArgs = psMetadataAlloc();
     77    psMetadataAddS64(addfileArgs, PS_LIST_TAIL, "-fileset_id", 0, "define fileset_id (required)", 0);
     78    psMetadataAddStr(addfileArgs, PS_LIST_TAIL, "-file", PS_META_DUPLICATE_OK, "define file (multiple OK, required)", NULL);
     79
     80    // -pendingfile
     81    psMetadata *pendingfileArgs = psMetadataAlloc();
     82    psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
     83    psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL);
     84    psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
     85    psMetadataAddS64(pendingfileArgs, PS_LIST_TAIL, "-fileset_id", 0, "search on fileset_id", 0);
    7486
    7587    // -addresult
    7688    psMetadata *addresultArgs = psMetadataAlloc();
    77     psMetadataAddS64(addresultArgs, PS_LIST_TAIL, "-receive_id", 0, "define receive_id (required)", 0);
     89    psMetadataAddS64(addresultArgs, PS_LIST_TAIL, "-file_id", 0, "define receive_id (required)", 0);
    7890    psMetadataAddF32(addresultArgs, PS_LIST_TAIL, "-dtime_copy", 0, "define time to copy", NAN);
    7991    psMetadataAddF32(addresultArgs, PS_LIST_TAIL, "-dtime_extract", 0, "define time to extract", NAN);
     
    8294    // -revert
    8395    psMetadata *revertArgs = psMetadataAlloc();
    84     psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-receive_id", 0, "search on receive_id", 0);
     96    psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-file_id", 0, "search on file_id", 0);
     97    psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-fileset_id", 0, "search on fileset_id", 0);
    8598    psMetadataAddS32(revertArgs, PS_LIST_TAIL, "-fault", 0, "search on fault code", 0);
    8699    psMetadataAddStr(revertArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
     
    93106    PXOPT_ADD_MODE("-definesource", "", RECEIVETOOL_MODE_DEFINESOURCE, definesourceArgs);
    94107    PXOPT_ADD_MODE("-list", "", RECEIVETOOL_MODE_LIST, listArgs);
    95     PXOPT_ADD_MODE("-definerun", "", RECEIVETOOL_MODE_DEFINERUN, definerunArgs);
     108    PXOPT_ADD_MODE("-addfileset", "", RECEIVETOOL_MODE_ADDFILESET, addfilesetArgs);
    96109    PXOPT_ADD_MODE("-updatelast", "", RECEIVETOOL_MODE_UPDATELAST, updatelastArgs);
    97     PXOPT_ADD_MODE("-pendingrun", "", RECEIVETOOL_MODE_PENDINGRUN, pendingrunArgs);
     110    PXOPT_ADD_MODE("-pendingfileset", "", RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetArgs);
     111    PXOPT_ADD_MODE("-addfile", "", RECEIVETOOL_MODE_ADDFILE, addfileArgs);
     112    PXOPT_ADD_MODE("-pendingfile", "", RECEIVETOOL_MODE_PENDINGFILE, pendingfileArgs);
    98113    PXOPT_ADD_MODE("-addresult", "", RECEIVETOOL_MODE_ADDRESULT, addresultArgs);
    99114    PXOPT_ADD_MODE("-revert", "", RECEIVETOOL_MODE_REVERT, revertArgs);
Note: See TracChangeset for help on using the changeset viewer.