IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35175 for trunk/ippToPsps


Ignore:
Timestamp:
Feb 16, 2013, 3:36:57 PM (13 years ago)
Author:
eugene
Message:

swap inner and outer loops: do boxes then batches (so a single dvopsps load can be used for both P2 and ST)

Location:
trunk/ippToPsps/jython
Files:
3 edited

Legend:

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

    r35174 r35175  
    640640        p.wait()
    641641
     642        ## dvopsps can take a very long time. try 2 or 3 times to re-establish communication with the db before proceeding?
     643
    642644        self.ippToPspsDb.setIngestedBox(boxId)
    643645
  • trunk/ippToPsps/jython/ipptopspsdb.py

    r35097 r35175  
    11681168            rs.close()
    11691169        except:
    1170             self.logger.errorPair("No free stripes", "trying to share with other client...")
     1170            self.logger.errorPair("No free stripes", "trying to steal boxes from other client...")
    11711171            sql = "SELECT ra_center, COUNT(*) AS numPending\
    11721172                   FROM box \
     
    11841184                rs.close()
    11851185            except:
    1186                 self.logger.errorPair("No available stripes to share", "no stripe obtained")
     1186                self.logger.errorPair("No outstanding boxes to steal", "no stripe obtained")
    11871187
    11881188        self.logger.infoPair("Using RA stripe", "%f" % raCenter)
     
    12031203
    12041204        self.registerStripe(host, pid, raCenter)
     1205
     1206        self.unlockTables()
     1207
     1208        return ids
     1209
     1210    '''
     1211    Returns ids for all boxes with pending items in a stripe of RA not already being processed
     1212    by another client. If none are available, then it uses the stripe already used by another
     1213    client that has the most pending items
     1214    '''
     1215    def getStripeBoxIdsAnyBatch(self, host, pid):
     1216
     1217        self.execute("LOCK TABLES box READ, pending READ, stripe WRITE, clients WRITE")
     1218
     1219        ids = []
     1220        raCenter = -1.0
     1221        sql = "SELECT ra_center \
     1222               FROM box \
     1223               JOIN pending ON (id = box_id) \
     1224               WHERE skychunk = '" + self.skychunk.name + "' \
     1225               AND ra_center NOT IN \
     1226               (SELECT ra_center \
     1227                FROM stripe \
     1228                WHERE skychunk = '" + self.skychunk.name + "') \
     1229               GROUP BY ra_center LIMIT 1"
     1230
     1231        try:
     1232            rs = self.executeQuery(sql)
     1233            rs.first()
     1234            raCenter = rs.getFloat(1)
     1235            rs.close()
     1236        except:
     1237            self.logger.errorPair("No free stripes", "trying to steal boxes from other client...")
     1238            sql = "SELECT ra_center, COUNT(*) AS numPending\
     1239                   FROM box \
     1240                   JOIN pending ON (id = box_id) \
     1241                   WHERE skychunk = '" + self.skychunk.name + "' \
     1242                   GROUP BY ra_center \
     1243                   ORDER BY numPending \
     1244                   DESC LIMIT 1"
     1245
     1246            try:
     1247                rs = self.executeQuery(sql)
     1248                rs.first()
     1249                raCenter = rs.getFloat(1)
     1250                rs.close()
     1251            except:
     1252                self.logger.errorPair("No outstanding boxes to steal", "no stripe obtained")
     1253
     1254        self.logger.infoPair("Using RA stripe", "%f" % raCenter)
     1255        sql = "SELECT DISTINCT id \
     1256               FROM box \
     1257               JOIN pending ON (id = box_id) \
     1258               WHERE ra_center = " + str(raCenter) + " \
     1259               AND skychunk = '" + self.skychunk.name + "' \
     1260               ORDER BY dec_center DESC"
     1261
     1262        try:
     1263            rs = self.executeQuery(sql)
     1264            while (rs.next()): ids.append(rs.getInt(1))
     1265            rs.close()
     1266        except:
     1267            self.logger.errorPair("Can't get stripe boxes", sql)
    12051268
    12061269        self.unlockTables()
  • trunk/ippToPsps/jython/loader.py

    r35174 r35175  
    125125        while True:
    126126
    127             abort = False
    128             for batchType in self.skychunk.batchTypes:
    129 
    130                 # get a stripe's worth of box IDs
    131                 boxIds = self.ippToPspsDb.getStripeBoxIds(self.HOST, self.PID, batchType)
    132 
    133                 numAttempts += 1
    134 
    135                 self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds))
    136                 self.logger.infoPair("numAttempts", str(numAttempts))
    137                 if len(boxIds) > 0: numAttempts = 0
    138 
    139                 for boxId in boxIds:
     127            # get a stripe's worth of box IDs
     128            boxIds = self.ippToPspsDb.getStripeBoxIdsAnyBatch(self.HOST, self.PID)
     129            self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds))
     130            self.logger.infoPair("numAttempts", str(numAttempts))
     131
     132            if len(boxIds) > 0: numAttempts = 0
     133            numAttempts += 1
     134
     135            for boxId in boxIds:
     136
     137                # get box info. if boxes have changed, break and start again
     138                try:
     139                    boxDim = self.ippToPspsDb.getBoxDimensions(boxId)
     140                except:
     141                    self.logger.infoPair("Can't get details for this box", "%d" % boxId)
     142                    break
     143                self.logger.infoPair("client status", "ok")
     144
     145                abort = False
     146                for batchType in self.skychunk.batchTypes:
     147
    140148                    self.logger.infoPair("Check","client status")
    141149                    if not self.checkClientStatus():
     
    143151                        break
    144152                    self.logger.infoPair("client status", "ok")
    145                     # get box info. if boxes have changed, break and start again
    146                     try:
    147                         boxDim = self.ippToPspsDb.getBoxDimensions(boxId)
    148                     except:
    149                         self.logger.infoPair("Can't get details for this box", "%d" % boxId)
    150                         break
    151                     self.logger.infoPair("client status", "ok")
     153
    152154                    ids = self.ippToPspsDb.getPendingIdsForThisBox(boxId, batchType)
    153155               
Note: See TracChangeset for help on using the changeset viewer.