def getMsgRaw(fileName, rs): msgID = rs.getLong(1) size = rs.getInt(2) storageLocation = StoredMessage.stripOldStorageDir(rs.getString(3)) custID = rs.getInt(4) ts = rs.getTimestamp(5) receivedDate = None if ts is not None: receivedDate = Date(ts.getTime) msg = StoredMessage(custID, msgID, storageLocation, None, None, receivedDate, 0, 0, 0, 0, None, amPartId, size, size, None, None) if msg: # do some validation if long(msgId) != msg.getMessageId(): printQueue.append("consumer: ERROR: message ID " + str(msgId) + " not the same as " + str(msg.getMessageId())) #print "found message", msgId, "in DB for AM partition" msgStream = msg.getEncryptedCompressedContentStream() if msgStream: out = FileOutputStream(fileName) FileUtils.copyStream(msg.getEncryptedCompressedContentStream(), out) out.flush() out.close() #print "found message", msgId, "on disk in AM partition" return True else: printErrorToRemigrate(msgId, " not found on disk for AM partition.") return False else: printErrorToRemigrate(msgId, " not found in db for AM partition.") return False
for line in infile: # first advance pointer thru CRS while rs.getLong(1) < long(str.strip(line)): if crsi.hasNext(): rs = crsi.next() else: # if we get here, we're looking for something in the file that is greater # than anything in the CRS. This means failure. print message below continue # next, see if they now match. if they do, get to work. if not, throw an error if rs.getLong(1) == long(str.strip(line)): # build up a StoredMessage msgID = rs.getLong(1) size = rs.getInt(2) storageLocation = StoredMessage.stripOldStorageDir(rs.getString(3)) custID = rs.getInt(4) ts = rs.getTimestamp(5) receivedDate = None if ts is not None: receivedDate = Date(ts.getTime()) msg = StoredMessage(custID, msgID, storageLocation, None, None, receivedDate, 0, 0, 0, 0, None, amPartId, size, size, None, None) # build up a batch if it isn't full yet if runningCount < batchSize: printQueue.add("debug(main): adding msg " + str(msg.getMessageId()) + " to a batch") queueToBuild.append(msg) runningCount += 1 # otherwise we're ready to push to a thread and start with a new batch else: