def getNewJob(self, tofile=True): try: _maxinputsize = pUtil.getMaxInputSize(MB=True) _disk = self.__node.disk pUtil.tolog("Available WN disk space: %d MB" % (_disk)) _diskSpace = min(_disk, _maxinputsize) pUtil.tolog("Sending disk space %d MB to dispatcher" % (_diskSpace)) # construct a dictionary for passing to jobDispatcher and get the prodSourceLabel jNode, prodSourceLabel, pilotErrorDiag = self.getDispatcherDictionary(_diskSpace, tofile) if jNode == {}: errorText = "!!FAILED!!1200!! %s" % (pilotErrorDiag) pUtil.tolog(errorText, tofile=tofile) # send to stderr print >> sys.stderr, errorText return None, None, pilotErrorDiag # get a random server url = '%s:%s/server/panda' % (self.__env['pshttpurl'], str(self.__env['psport'])) pUtil.tolog("Looking for a primary job (contacting server at %s)" % (url), tofile=tofile) # make http connection to jobdispatcher # format: status, parsed response (data), response ret = pUtil.httpConnect(jNode, url, mode = "GETJOB", path = self.__pilotWorkingDir, experiment = self.__thisExperiment) # connection mode is GETJOB # get and write the dispatcher status code to file StatusCode = str(ret[0]) # the original response will be put in a file in this function data = ret[1] # dictionary response = ret[2] # text # write the dispatcher exit code to file self.writeDispatcherEC(StatusCode) if ret[0]: # non-zero return return None, None, pUtil.getDispatcherErrorDiag(ret[0]) if StatusCode != '0': pilotErrorDiag = "No job received from jobDispatcher, StatusCode: %s" % (StatusCode) pUtil.tolog("%s" % (pilotErrorDiag), tofile=tofile) return None, None, pilotErrorDiag # test if he attempt number was sent try: attemptNr = int(data['attemptNr']) except Exception,e: pUtil.tolog("!!WARNING!!1200!! Failed to get attempt number from server: %s" % str(e), tofile=tofile) else:
def getMaxInputSize(self): # Get a proper maxinputsize from schedconfig/default # quick stab: old implementation, fix me later from pUtil import getMaxInputSize return getMaxInputSize()
def getNewJob(self, tofile=True, nJobs=1): try: _maxinputsize = pUtil.getMaxInputSize(MB=True) _disk = self.__node.disk pUtil.tolog("Available WN disk space: %d MB" % (_disk)) _diskSpace = min(_disk, _maxinputsize) pUtil.tolog("Sending disk space %d MB to dispatcher" % (_diskSpace)) # construct a dictionary for passing to jobDispatcher and get the prodSourceLabel jNode, prodSourceLabel, pilotErrorDiag = self.getDispatcherDictionary(_diskSpace, tofile, nJobs) if jNode == {}: errorText = "!!FAILED!!1200!! %s" % (pilotErrorDiag) pUtil.tolog(errorText, tofile=tofile) # send to stderr print >> sys.stderr, errorText return None, None, pilotErrorDiag # get a random server url = '%s:%s/server/panda' % (self.__env['pshttpurl'], str(self.__env['psport'])) pUtil.tolog("Looking for a primary job (contacting server at %s)" % (url), tofile=tofile) # make http connection to jobdispatcher # format: status, parsed response (data), response ret = pUtil.httpConnect(jNode, url, mode = "GETJOB", path = self.__pilotWorkingDir, experiment = self.__thisExperiment) # connection mode is GETJOB # get and write the dispatcher status code to file StatusCode = str(ret[0]) # the original response will be put in a file in this function data = ret[1] # dictionary response = ret[2] # text # write the dispatcher exit code to file self.writeDispatcherEC(StatusCode) if ret[0]: # non-zero return return None, None, pUtil.getDispatcherErrorDiag(ret[0]) if StatusCode != '0': pilotErrorDiag = "No job received from jobDispatcher, StatusCode: %s" % (StatusCode) pUtil.tolog("%s" % (pilotErrorDiag), tofile=tofile) return None, None, pilotErrorDiag # backup response (will be copied to workdir later) self.backupDispatcherResponse(response, tofile) if not data.has_key("jobs"): jobs = [data] else: jobs = data['jobs'] newJobs = [] newJobsData = {} for job in jobs: # test if he attempt number was sent try: attemptNr = int(job['attemptNr']) except Exception,e: pUtil.tolog("!!WARNING!!1200!! Failed to get attempt number from server: %s" % str(e), tofile=tofile) else: pUtil.tolog("Attempt number from server: %d" % attemptNr) # should there be a delay before setting running state? try: nSent = int(job['nSent']) except Exception,e: nSent = 0 else: