IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23861


Ignore:
Timestamp:
Apr 14, 2009, 3:14:27 PM (17 years ago)
Author:
bills
Message:

add task to build data store filesets for distRuns

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/Build.PL

    r23250 r23861  
    8282        scripts/dist_component.pl
    8383        scripts/dist_advancerun.pl
     84        scripts/dist_make_fileset.pl
    8485    )],
    8586    dist_abstract => 'Scripts for running the Pan-STARRS IPP',
  • trunk/ippScripts/scripts/dist_advancerun.pl

    r23777 r23861  
    8989}
    9090
    91 # XXX we should create a file rule for this
     91# XXX should we create a file rule for this?
    9292my $outfile = "$outdir/dbinfo.$stage.$stage_id.mdc";
    9393
  • trunk/ippScripts/scripts/dist_make_fileset.pl

    r23838 r23861  
    3939
    4040# Parse the command-line arguments
    41 my ($dist_id, $dist_dir, $target_id, $stage, $stage_id, $prod_id, $product_name, $product_root, $ds_dbhost, $ds_dbname);
     41my ($dist_id, $dist_dir, $target_id, $stage, $stage_id, $prod_id, $product_name, $ds_dbhost, $ds_dbname);
    4242my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    4343
     
    5050           'prod_id=s'      => \$prod_id,    # id for the product
    5151           'product_name=s' => \$product_name,  # location of the data store directory for this product
    52            'product_root=s' => \$product_root,  # location of the data store directory for this product
    5352           'ds_dbhost=s'    => \$ds_dbhost,  # database host for the datastore database
    5453           'ds_dbname=s'    => \$ds_dbname,  # database name for the datastore database
     
    6160
    6261pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    63 pod2usage( -msg => "Required options: --dist_id --dist_dir --target_id --stage --stage_id --prod_id --product_root --ds_dbhost --ds_dbname",
     62pod2usage( -msg => "Required options: --dist_id --dist_dir --target_id --stage --stage_id --prod_id --ds_dbhost --ds_dbname",
    6463           -exitval => 3) unless
    6564    defined $dist_id and
     
    7069    defined $prod_id and
    7170    defined $product_name and
    72     defined $product_root and
    7371    defined $ds_dbhost and
    7472    defined $ds_dbname;
     
    156154
    157155# XXX: disttool -addrcdsfileset
    158 
    159 # XXX todo: add rcRun's for the destinations
     156{
     157    my $command = "$disttool -addfileset -dist_id $dist_id -prod_id $prod_id -name $fileset_name";
     158    $command .= " -dbname $dbname" if $dbname;
     159
     160    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     161        run(command => $command, verbose => $verbose);
     162    unless ($success) {
     163        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     164        &my_die("Unable to perform $command error_code: $error_code", $dist_id, $prod_id, $error_code);
     165    }
     166}
     167
    160168
    161169
     
    239247    print STDERR "$msg\n";
    240248
     249    my $command = "$disttool -addfileset -dist_id $dist_id -prod_id $prod_id -fault $fault";
     250    $command .= " -dbname $dbname" if $dbname;
     251
     252    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     253        run(command => $command, verbose => $verbose);
     254    unless ($success) {
     255        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     256        print STDERR "Unable to perform $command error_code: $error_code\n";
     257    }
    241258    exit $fault;
    242259}
  • trunk/ippTasks/Makefile.am

    r23480 r23861  
    2121        replicate.pro \
    2222        dist.pro \
     23        rcserver.pro \
    2324        pstamp.pro
    2425
  • trunk/ippTools/share/disttool_pendingfileset.sql

    r23842 r23861  
    55    stage_id,
    66    CONCAT_WS('.', distRun.outroot, CONVERT(distRun.dist_id, CHAR)) as dist_dir,
    7     rcDSProduct.*
     7    rcDSProduct.name AS product_name,
     8    rcDSProduct.prod_id,
     9    rcDSProduct.dbname AS ds_dbname,
     10    rcDSProduct.dbhost AS ds_dbhost
    811FROM rcDestination
    912JOIN rcInterest USING(dest_id)
  • trunk/ippTools/src/disttool.c

    r23842 r23861  
    4141static bool pendingfilesetMode(pxConfig *config);
    4242static bool addfilesetMode(pxConfig *config);
     43static bool pendingdatastoresMode(pxConfig *config);
    4344
    4445# define MODECASE(caseName, func) \
     
    7172        MODECASE(DISTTOOL_MODE_PENDINGFILESET, pendingfilesetMode);
    7273        MODECASE(DISTTOOL_MODE_ADDFILESET, addfilesetMode);
     74        MODECASE(DISTTOOL_MODE_PENDINGDATASTORES, pendingdatastoresMode);
    7375        default:
    7476            psAbort("invalid option (this should not happen)");
     
    893895}
    894896
     897static bool pendingdatastoresMode(pxConfig *config)
     898{
     899    PS_ASSERT_PTR_NON_NULL(config, false);
     900#ifdef notyet
     901
     902    psMetadata *where = psMetadataAlloc();
     903    PXOPT_COPY_S64(config->args, where, "-dist_id", "dist_id", "==");
     904    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     905
     906    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     907    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     908
     909    // look for "inputs" that need to processed
     910    psString query = pxDataGet("disttool_pendingfileset.sql");
     911    if (!query) {
     912        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     913        return false;
     914    }
     915
     916    if (psListLength(where->list)) {
     917        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     918        psStringAppend(&query, " AND %s", whereClause);
     919        psFree(whereClause);
     920    }
     921    psFree(where);
     922
     923    // treat limit == 0 as "no limit"
     924    if (limit) {
     925        psString limitString = psDBGenerateLimitSQL(limit);
     926        psStringAppend(&query, " %s", limitString);
     927        psFree(limitString);
     928    }
     929
     930    if (!p_psDBRunQuery(config->dbh, query)) {
     931        psError(PS_ERR_UNKNOWN, false, "database error");
     932        psFree(query);
     933        return false;
     934    }
     935    psFree(query);
     936
     937    psArray *output = p_psDBFetchResult(config->dbh);
     938    if (!output) {
     939        psErrorCode err = psErrorCodeLast();
     940        switch (err) {
     941            case PS_ERR_DB_CLIENT:
     942                psError(PXTOOLS_ERR_SYS, false, "database error");
     943            case PS_ERR_DB_SERVER:
     944                psError(PXTOOLS_ERR_PROG, false, "database error");
     945            default:
     946                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     947        }
     948
     949        return false;
     950    }
     951    if (!psArrayLength(output)) {
     952        psTrace("disttool", PS_LOG_INFO, "no rows found");
     953        psFree(output);
     954        return true;
     955    }
     956
     957    if (psArrayLength(output)) {
     958        // negative simple so the default is true
     959        if (!ippdbPrintMetadatas(stdout, output, "pendingfileset", !simple)) {
     960            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     961            psFree(output);
     962            return false;
     963        }
     964    }
     965
     966    psFree(output);
     967# endif // notdef
     968    return true;
     969}
  • trunk/ippTools/src/disttool.h

    r23842 r23861  
    3535    DISTTOOL_MODE_PENDINGFILESET,
    3636    DISTTOOL_MODE_ADDFILESET,
     37    DISTTOOL_MODE_PENDINGDATASTORES,
    3738} disttoolMode;
    3839
  • trunk/ippTools/src/disttoolConfig.c

    r23842 r23861  
    138138    psMetadataAddStr(addfilesetArgs, PS_LIST_TAIL, "-name", 0, "define file name", NULL);
    139139    psMetadataAddS32(addfilesetArgs, PS_LIST_TAIL, "-fault", 0, "define fault code", 0);
     140    //
     141    // -pendingfileset
     142    psMetadata *pendingdatastoresArgs = psMetadataAlloc();
     143    psMetadataAddS64(pendingdatastoresArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     144    psMetadataAddStr(pendingdatastoresArgs, PS_LIST_TAIL, "-label",    0, "limit results to label", NULL);
     145    psMetadataAddStr(pendingdatastoresArgs, PS_LIST_TAIL, "-stage",    0, "limit results to runs for stage", NULL);
     146    psMetadataAddU64(pendingdatastoresArgs, PS_LIST_TAIL, "-limit",  0,  "limit result set to N items", 0);
     147    psMetadataAddBool(pendingdatastoresArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
     148
    140149    psMetadata *argSets = psMetadataAlloc();
    141150    psMetadata *modes = psMetadataAlloc();
     
    151160    PXOPT_ADD_MODE("-pendingfileset",      "", DISTTOOL_MODE_PENDINGFILESET, pendingfilesetArgs);
    152161    PXOPT_ADD_MODE("-addfileset",      "", DISTTOOL_MODE_ADDFILESET, addfilesetArgs);
     162    PXOPT_ADD_MODE("-pendingdatastores",      "", DISTTOOL_MODE_PENDINGDATASTORES, pendingdatastoresArgs);
    153163
    154164    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note: See TracChangeset for help on using the changeset viewer.