IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32468 for trunk/ippToPsps


Ignore:
Timestamp:
Sep 29, 2011, 3:33:14 PM (15 years ago)
Author:
rhenders
Message:

big changes to support multi-client loading; now locks batch table when looking for new item to process, then releases it to perform the processing; gets a list of consistently failing batches and removes them from master list to save time during main processing loop;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/load.py

    r32227 r32468  
    77import time
    88import sys
     9import os
     10import socket
    911import logging.config
    1012from xml.etree.ElementTree import ElementTree, Element, tostring
     
    3537        logger.infoPair("Batch name", batchName)
    3638
    37         Batch.publishToDatastore(datastore, ippToPspsDb, batchID, batchName, subDir, tarballFile)
    38 
     39        Batch.publishToDatastore(datastore, batchID, batchName, subDir, tarballFile)
    3940
    4041'''
     
    6768    else:
    6869        processedIDs = ippToPspsDb.getProcessedIDs(batchType, EPOCH, DVOGPC1LABEL)
    69         logger.infoPair("Processed %s items" % batchType, "%d" % len(processedIDs))
    70         ids = list(set(allIDs) - set(processedIDs))
    71         logger.infoPair("Unprocessed %s items" % batchType, "%d" % len(ids))
     70        consistaentlyFailedIDs = ippToPspsDb.getConsistentlyFailedIDs(batchType, EPOCH, DVOGPC1LABEL)
     71        ids = list(set(allIDs) - set(processedIDs) - set(consistaentlyFailedIDs))
     72        logger.infoPair("Processed items", "%d" % len(processedIDs))
     73        logger.infoPair("Consistently failing items", "%d" % len(consistaentlyFailedIDs))
     74        logger.infoPair("Unprocessed items", "%d" % len(ids))
    7275
    7376    logger.infoPair("%s items queued" % batchType, "%d" % len(ids))
    7477
    7578    # loop round IDs of all items to be processed
     79    ippToPspsDb.lockBatchTable()
    7680    for id in ids:
    7781
    78         if not FORCE and ippToPspsDb.alreadyProcessed(batchType, id, EPOCH, DVOGPC1LABEL): continue
    79         if not FORCE and ippToPspsDb.consistentlyFailed(batchType, id, EPOCH, DVOGPC1LABEL, 3): continue
     82        batchID = ippToPspsDb.createNewBatch(
     83                batchType,
     84                id,
     85                SURVEY,
     86                EPOCH,
     87                DVOGPC1LABEL,
     88                datastore.product,
     89                FORCE)
     90       
     91        if batchID < 0: continue;
     92
     93        ippToPspsDb.unlockTables()
    8094
    8195        if batchType == "P2":
     
    8599                    gpc1Db,
    86100                    ippToPspsDb,
    87                     id)
     101                    id,
     102                    batchID)
    88103        elif batchType == "ST":
    89104            batch = StackBatch(logger,
     
    92107                    gpc1Db,
    93108                    ippToPspsDb,
    94                     id)
     109                    id,
     110                    batchID)
    95111
    96112        batch.run()
     113
     114        ippToPspsDb.lockBatchTable()
     115
     116        logger.infoSeparator()
    97117
    98118        # if in TEST mode, then quit after one batch
    99119        if TEST: break
    100120
     121    ippToPspsDb.unlockTables()
    101122
    102123'''
     
    122143logger = logging.getLogger("ippToPspsLog")
    123144
     145# get hostnamee and PID for unique log naming
     146HOST = socket.gethostname()
     147PID = os.getpid()
     148
    124149# if in test mode, print log to screen, otherwise, only to file
    125 logger.setup(configDoc, "ippToPsps", TEST, not TEST)
     150logger.setup(configDoc, "ippToPsps", TEST, not TEST, HOST, PID)
    126151
    127152# create database objects
    128153gpc1Db = Gpc1Db(logger, configDoc)
    129154ippToPspsDb = IppToPspsDb(logger, configDoc)
    130 datastore = Datastore(logger, configDoc)
     155datastore = Datastore(logger, configDoc, ippToPspsDb)
    131156
    132157# check we connected ok
     
    143168QUEUE_P2 = int(configDoc.find("options/queueP2").text)
    144169QUEUE_ST = int(configDoc.find("options/queueST").text)
     170SURVEY = configDoc.find("options/survey").text
    145171
    146172# prompt user: FORCE and PUBLISH is a dangerous combination
     
    180206    # queue all items for all batch types, sequentially
    181207    if QUEUE_IN:
    182        batch = InitBatch(logger, CONFIG, configDoc, gpc1Db, ippToPspsDb)
    183        batch.run()
     208       batchID = ippToPspsDb.createNewBatch(
     209                 "IN",
     210                 0,
     211                 SURVEY,
     212                 EPOCH,
     213                 DVOGPC1LABEL,
     214                 datastore.product,
     215                 1)
     216       if batchID > 0:
     217           batch = InitBatch(logger, CONFIG, configDoc, gpc1Db, ippToPspsDb, batchID)
     218           batch.run()
    184219       break;
    185220
Note: See TracChangeset for help on using the changeset viewer.