def _processDBRow(self, row): """ Completely process a single DB row. Take the row, convert it to a UsageRecord, and send it up to Gratia. Process any recoverable errors which occurred during the process. Note we skip a row if it is an Intra-site transfer and we are instructed not to send them. Otherwise, we process the row in Gratia or exit the probe. @return: The number of jobs in this row, regardless of whether we sent them successfully or not. """ # Skip intra-site transfers if required if self._skipIntraSiteXfer(row): return row['njobs'] if (TestContainer.isTest()): if (self._summarize): TestContainer.sendInterrupt(15) return TestContainer.processRow(row, self._log) usageRecord = self._convertBillingInfoToGratiaUsageRecord(\ row) # Send to gratia, and see what it says. response = Gratia.Send(usageRecord) baseMsg = "Record: %s, %s, njobs %i" % (str( row['datestamp']), row['transaction'], row['njobs']) if response == "Fatal Error: too many pending files": # The server is currently not accepting record and # Gratia.py was not able to store the record, we will # need to resend it. # For now take a long nap and then by 'break' we # force a retry for this record. self._log.error("Error sending : too many pending files") longsleep = 15 * 60 self._log.warn("sleeping for = %i seconds." % longsleep) sleep_check(longsleep, self._stopFileName) elif response.startswith('Fatal Error') or \ response.startswith('Internal Error'): self._log.critical('error sending ' + baseMsg + \ '\ngot response ' + response) sys.exit(2) self._log.debug('sent ' + baseMsg) # If we got a non-fatal error, slow down since the server # might be overloaded. if response[:2] != 'OK': self._log.error('error sending ' + baseMsg + \ '\ngot response ' + response) return row['njobs']
def send(self, record): Gratia.Send(record)
# print 'endtime: ' + endtime # print 'starttime: ' + starttime # print 'walltime: ' + walltime # Gratia likes ints, not strings, for times. r.LocalJobId(localjobid) r.EndTime(int(endtime)) r.StartTime(int(starttime)) r.Njobs(1) r.WallDuration(int(walltime)) r.LocalUserId('labuser') r.MachineName('clemson-boinc') r.Host(host, True) r.CpuDuration(int(walltime), 'user') r.CpuDuration(0, 'system') r.VOName('LIGO') print Gratia.Send(r) shutil.move('/home/gprobe/Data/' + var, '/home/gprobe/Data/parsed/' + var) else: # Get rid of the file, since it is # not a boinc job. os.remove(BASEDIR + var) # print "Not a boinc job.. returning."
localjobid = var.partition('.')[2].partition('#')[2].partition('#')[0] # print 'endtime: ' + endtime # print 'starttime: ' + starttime # print 'walltime: ' + walltime # Gratia likes ints, not strings, for times. r.LocalJobId(localjobid) r.EndTime(int(endtime)) r.StartTime(int(starttime)) r.Njobs(1) r.WallDuration(int(walltime)) r.LocalUserId('labuser') r.MachineName('clemson-boinc') r.Host(host, True) r.CpuDuration(int(walltime), 'user') r.CpuDuration(0, 'system') r.VOName('LIGO') print(Gratia.Send(r)) shutil.move('/home/gprobe/Data/' + var, '/home/gprobe/Data/parsed/' + var) else: # Get rid of the file, since it is # not a boinc job. os.remove(BASEDIR + var) # print "Not a boinc job.. returning."