当前位置: 首页>>代码示例>>Python>>正文


Python JobDB.getJobParameter方法代码示例

本文整理汇总了Python中DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB.getJobParameter方法的典型用法代码示例。如果您正苦于以下问题:Python JobDB.getJobParameter方法的具体用法?Python JobDB.getJobParameter怎么用?Python JobDB.getJobParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB的用法示例。


在下文中一共展示了JobDB.getJobParameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: JobCleaningAgent

# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobParameter [as 别名]

#.........这里部分代码省略.........
          errorFlag = True
        if not resultTQ['OK']:
          gLogger.warn( 'Failed to remove job %d from TaskQueueDB' % jobID, result['Message'] )
          errorFlag = True
        if not resultLogDB['OK']:
          gLogger.warn( 'Failed to remove job %d from JobLoggingDB' % jobID, result['Message'] )
          errorFlag = True
        if errorFlag:  
          error_count += 1  
        else:
          count += 1
        if self.throttlingPeriod:
          time.sleep(self.throttlingPeriod)  
    else:    
      result = self.jobDB.removeJobFromDB( jobList )
      if not result['OK']:
        gLogger.error('Failed to delete %d jobs from JobDB' % len(jobList) )
      else:
        gLogger.info('Deleted %d jobs from JobDB' % len(jobList) )
  
      for jobID in jobList:
        resultTQ = self.taskQueueDB.deleteJob( jobID )
        if not resultTQ['OK']:
          gLogger.warn( 'Failed to remove job %d from TaskQueueDB' % jobID, resultTQ['Message'] )
          error_count += 1
        else:
          count += 1    

      result = self.jobLoggingDB.deleteJob( jobList )
      if not result['OK']:
        gLogger.error('Failed to delete %d jobs from JobLoggingDB' % len(jobList) )
      else:
        gLogger.info('Deleted %d jobs from JobLoggingDB' % len(jobList) )

    if count > 0 or error_count > 0 :
      gLogger.info( 'Deleted %d jobs from JobDB, %d errors' % ( count, error_count ) )
    return S_OK()

  def deleteJobOversizedSandbox( self, jobIDList ):
    """ Delete the job oversized sandbox files from storage elements
    """ 

    failed = {}
    successful = {}

    lfnDict = {}
    for jobID in jobIDList:
      result = self.jobDB.getJobParameter( jobID, 'OutputSandboxLFN' )
      if result['OK']:
        lfn = result['Value']
        if lfn:
          lfnDict[lfn] = jobID
        else:
          successful[jobID] = 'No oversized sandbox found'
      else:
        gLogger.warn( 'Error interrogting JobDB: %s' % result['Message'] )
    if not lfnDict:
      return S_OK( {'Successful':successful, 'Failed':failed} )   

    # Schedule removal of the LFNs now

    for lfn,jobID in lfnDict.items():
      result = self.jobDB.getJobAttributes( jobID, ['OwnerDN', 'OwnerGroup'] )
      if not result['OK']:
        failed[jobID] = lfn
        continue
      if not result['Value']:
        failed[jobID] = lfn
        continue

      ownerDN = result['Value']['OwnerDN']
      ownerGroup = result['Value']['OwnerGroup']
      result = self.__setRemovalRequest( lfn, ownerDN, ownerGroup )
      if not result['OK']:
        failed[jobID] = lfn
      else:
        successful[jobID] = lfn
           
    result = {'Successful':successful, 'Failed':failed}
    return S_OK( result )   
    
  def __setRemovalRequest( self, lfn, ownerDN, ownerGroup ):
    """ Set removal request with the given credentials
    """
    oRequest = Request()
    oRequest.OwnerDN = ownerDN
    oRequest.OwnerGroup = ownerGroup
    oRequest.RequestName = os.path.basename( lfn ).strip() + '_removal_request.xml'
    oRequest.SourceComponent = 'JobCleaningAgent'

    removeFile = Operation()
    removeFile.Type = 'RemoveFile'

    removedFile = File()
    removedFile.LFN = lfn

    removeFile.addFile( removedFile )
    oRequest.addOperation( removeFile )

    return ReqClient().putRequest( oRequest )
开发者ID:afalabel,项目名称:DIRAC,代码行数:104,代码来源:JobCleaningAgent.py

示例2: StalledJobAgent

# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobParameter [as 别名]

#.........这里部分代码省略.........
                    result = self.__sendAccounting(job)
                    if not result["OK"]:
                        self.log.error("Failed to send accounting", result["Message"])

        recoverCounter = 0

        for minor in minorStalledStatuses:
            result = self.jobDB.selectJobs({"Status": "Failed", "MinorStatus": minor, "AccountedFlag": "False"})
            if not result["OK"]:
                return result
            if result["Value"]:
                jobs = result["Value"]
                self.log.info("%s Stalled jobs will be Accounted" % (len(jobs)))
                for job in jobs:
                    result = self.__sendAccounting(job)
                    if not result["OK"]:
                        self.log.error("Failed to send accounting", result["Message"])
                        continue

                    recoverCounter += 1
            if not result["OK"]:
                break

        if failedCounter:
            self.log.info("%d jobs set to Failed" % failedCounter)
        if recoverCounter:
            self.log.info("%d jobs properly Accounted" % recoverCounter)
        return S_OK(failedCounter)

    #############################################################################
    def __getJobPilotStatus(self, jobID):
        """ Get the job pilot status
"""
        result = self.jobDB.getJobParameter(jobID, "Pilot_Reference")
        if not result["OK"]:
            return result
        if not result["Value"]:
            return S_ERROR("Failed to get the pilot reference")

        pilotReference = result["Value"]
        wmsAdminClient = RPCClient("WorkloadManagement/WMSAdministrator")
        result = wmsAdminClient.getPilotInfo(pilotReference)
        if not result["OK"]:
            if "No pilots found" in result["Message"]:
                self.log.warn(result["Message"])
                return S_OK("NoPilot")
            self.log.error("Failed to get pilot information", result["Message"])
            return S_ERROR("Failed to get the pilot status")
        pilotStatus = result["Value"][pilotReference]["Status"]

        return S_OK(pilotStatus)

    #############################################################################
    def __getStalledJob(self, job, stalledTime):
        """ Compares the most recent of LastUpdateTime and HeartBeatTime against
the stalledTime limit.
"""
        result = self.__getLatestUpdateTime(job)
        if not result["OK"]:
            return result

        currentTime = toEpoch()
        lastUpdate = result["Value"]

        elapsedTime = currentTime - lastUpdate
        self.log.verbose("(CurrentTime-LastUpdate) = %s secs" % (elapsedTime))
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:70,代码来源:StalledJobAgent.py

示例3: StalledJobAgent

# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobParameter [as 别名]

#.........这里部分代码省略.........
          if not result['OK']:
            self.log.error( 'Failed to send accounting', result['Message'] )
            break

    recoverCounter = 0

    for minor in ["Job stalled: pilot not running", 'Stalling for more than %d sec' % failedTime]:
      result = self.jobDB.selectJobs( {'Status':'Failed', 'MinorStatus': minor, 'AccountedFlag': 'False' } )
      if not result['OK']:
        return result
      if result['Value']:
        jobs = result['Value']
        self.log.info( '%s Stalled jobs will be Accounted' % ( len( jobs ) ) )
        for job in jobs:
          result = self.__sendAccounting( job )
          if not result['OK']:
            self.log.error( 'Failed to send accounting', result['Message'] )
            continue

          recoverCounter += 1
      if not result['OK']:
        break

    if failedCounter:
      self.log.info( '%d jobs set to Failed' % failedCounter )
    if recoverCounter:
      self.log.info( '%d jobs properly Accounted' % recoverCounter )
    return S_OK( failedCounter )

  #############################################################################
  def __getJobPilotStatus( self, jobID ):
    """ Get the job pilot status
"""
    result = self.jobDB.getJobParameter( jobID, 'Pilot_Reference' )
    if not result['OK']:
      return result
    if not result['Value']:
      return S_ERROR( 'Failed to get the pilot reference' )

    pilotReference = result['Value']
    wmsAdminClient = RPCClient( 'WorkloadManagement/WMSAdministrator' )
    result = wmsAdminClient.getPilotInfo( pilotReference )
    if not result['OK']:
      if "No pilots found" in result['Message']:
        self.log.warn( result['Message'] )
        return S_OK( 'NoPilot' )
      self.log.error( 'Failed to get pilot information', result['Message'] )
      return S_ERROR( 'Failed to get the pilot status' )
    pilotStatus = result['Value'][pilotReference]['Status']

    return S_OK( pilotStatus )


  #############################################################################
  def __getStalledJob( self, job, stalledTime ):
    """ Compares the most recent of LastUpdateTime and HeartBeatTime against
the stalledTime limit.
"""
    result = self.__getLatestUpdateTime( job )
    if not result['OK']:
      return result

    currentTime = toEpoch()
    lastUpdate = result['Value']

    elapsedTime = currentTime - lastUpdate
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:70,代码来源:StalledJobAgent.py

示例4: JobCleaningAgent

# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobParameter [as 别名]

#.........这里部分代码省略.........
          errorFlag = True
        if not resultTQ['OK']:
          gLogger.warn( 'Failed to remove job %d from TaskQueueDB' % jobID, result['Message'] )
          errorFlag = True
        if not resultLogDB['OK']:
          gLogger.warn( 'Failed to remove job %d from JobLoggingDB' % jobID, result['Message'] )
          errorFlag = True
        if errorFlag:
          error_count += 1
        else:
          count += 1
        if self.throttlingPeriod:
          time.sleep(self.throttlingPeriod)
    else:
      result = self.jobDB.removeJobFromDB( jobList )
      if not result['OK']:
        gLogger.error('Failed to delete %d jobs from JobDB' % len(jobList) )
      else:
        gLogger.info('Deleted %d jobs from JobDB' % len(jobList) )

      for jobID in jobList:
        resultTQ = self.taskQueueDB.deleteJob( jobID )
        if not resultTQ['OK']:
          gLogger.warn( 'Failed to remove job %d from TaskQueueDB' % jobID, resultTQ['Message'] )
          error_count += 1
        else:
          count += 1

      result = self.jobLoggingDB.deleteJob( jobList )
      if not result['OK']:
        gLogger.error('Failed to delete %d jobs from JobLoggingDB' % len(jobList) )
      else:
        gLogger.info('Deleted %d jobs from JobLoggingDB' % len(jobList) )

    if count > 0 or error_count > 0 :
      gLogger.info( 'Deleted %d jobs from JobDB, %d errors' % ( count, error_count ) )
    return S_OK()

  def deleteJobOversizedSandbox( self, jobIDList ):
    """ Delete the job oversized sandbox files from storage elements
    """

    failed = {}
    successful = {}

    lfnDict = {}
    for jobID in jobIDList:
      result = self.jobDB.getJobParameter( jobID, 'OutputSandboxLFN' )
      if result['OK']:
        lfn = result['Value']
        if lfn:
          lfnDict[lfn] = jobID
        else:
          successful[jobID] = 'No oversized sandbox found'
      else:
        gLogger.warn( 'Error interrogating JobDB: %s' % result['Message'] )
    if not lfnDict:
      return S_OK({'Successful': successful, 'Failed': failed})

    # Schedule removal of the LFNs now

    for lfn,jobID in lfnDict.items():
      result = self.jobDB.getJobAttributes( jobID, ['OwnerDN', 'OwnerGroup'] )
      if not result['OK']:
        failed[jobID] = lfn
        continue
      if not result['Value']:
        failed[jobID] = lfn
        continue

      ownerDN = result['Value']['OwnerDN']
      ownerGroup = result['Value']['OwnerGroup']
      result = self.__setRemovalRequest( lfn, ownerDN, ownerGroup )
      if not result['OK']:
        failed[jobID] = lfn
      else:
        successful[jobID] = lfn

    result = {'Successful':successful, 'Failed':failed}
    return S_OK(result)

  def __setRemovalRequest( self, lfn, ownerDN, ownerGroup ):
    """ Set removal request with the given credentials
    """
    oRequest = Request()
    oRequest.OwnerDN = ownerDN
    oRequest.OwnerGroup = ownerGroup
    oRequest.RequestName = os.path.basename( lfn ).strip() + '_removal_request.xml'
    oRequest.SourceComponent = 'JobCleaningAgent'

    removeFile = Operation()
    removeFile.Type = 'RemoveFile'

    removedFile = File()
    removedFile.LFN = lfn

    removeFile.addFile( removedFile )
    oRequest.addOperation( removeFile )

    return ReqClient().putRequest( oRequest )
开发者ID:marianne013,项目名称:DIRAC,代码行数:104,代码来源:JobCleaningAgent.py


注:本文中的DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB.getJobParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。