IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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()
Note: See TracChangeset for help on using the changeset viewer.