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


Python ResourceStatusClient.getStuffToCheck方法代码示例

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


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

示例1: RSInspectorAgent

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getStuffToCheck [as 别名]
class RSInspectorAgent( AgentModule ):
  """
    The RSInspector agent ( ResourceInspectorAgent ) is one of the four
    InspectorAgents of the RSS.

    This Agent takes care of the Resources. In order to do so, it gathers
    the eligible ones and then evaluates their statuses with the PEP.

    If you want to know more about the RSInspectorAgent, scroll down to the
    end of the file.
  """

  # Too many public methods
  # pylint: disable-msg=R0904

  def initialize( self ):

    # Attribute defined outside __init__ 
    # pylint: disable-msg=W0201

    try:
      self.rsClient             = ResourceStatusClient()
      self.resourcesFreqs       = CS.getTypedDictRootedAtOperations( 'CheckingFreqs/ResourcesFreqs' )
      self.resourcesToBeChecked = Queue.Queue()
      self.resourceNamesInCheck = []

      self.maxNumberOfThreads = self.am_getOption( 'maxThreadsInPool', 1 )
      self.threadPool         = ThreadPool( self.maxNumberOfThreads,
                                            self.maxNumberOfThreads )
      if not self.threadPool:
        self.log.error( 'Can not create Thread Pool' )
        return S_ERROR( 'Can not create Thread Pool' )

      for _i in xrange( self.maxNumberOfThreads ):
        self.threadPool.generateJobAndQueueIt( self._executeCheck, args = ( None, ) )

      return S_OK()

    except Exception:
      errorStr = "RSInspectorAgent initialization"
      self.log.exception( errorStr )
      return S_ERROR( errorStr )

  def execute( self ):

    try:

      kwargs = { 'meta' : {} }
      kwargs['meta']['columns'] = [ 'ResourceName', 'StatusType', 'Status',
                                    'FormerStatus', 'SiteType', 'ResourceType', \
                                    'TokenOwner' ]
      kwargs[ 'tokenOwner' ]    = 'RS_SVC'

      resQuery = self.rsClient.getStuffToCheck( 'Resource', self.resourcesFreqs, **kwargs )
      if not resQuery[ 'OK' ]:
        self.log.error( resQuery[ 'Message' ] )
        return resQuery

      resQuery = resQuery[ 'Value' ]  
      self.log.info( 'Found %d candidates to be checked.' % len( resQuery ) )

      for resourceTuple in resQuery:

        if ( resourceTuple[ 0 ], resourceTuple[ 1 ] ) in self.resourceNamesInCheck:
          self.log.info( '%s(%s) discarded, already on the queue' % ( resourceTuple[ 0 ], resourceTuple[ 1 ] ) )
          continue

        resourceL = [ 'Resource' ] + resourceTuple

        self.resourceNamesInCheck.insert( 0, ( resourceTuple[ 0 ], resourceTuple[ 1 ] ) )
        self.resourcesToBeChecked.put( resourceL )

      return S_OK()

    except Exception, x:
      errorStr = where( self, self.execute )
      self.log.exception( errorStr, lException = x )
      return S_ERROR( errorStr )
开发者ID:bmb,项目名称:DIRAC,代码行数:80,代码来源:RSInspectorAgent.py

示例2: SeSInspectorAgent

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getStuffToCheck [as 别名]
class SeSInspectorAgent( AgentModule ):
  '''
    The SeSInspector agent ( ServiceInspectorAgent ) is one of the four
    InspectorAgents of the RSS.

    This Agent takes care of the Service. In order to do so, it gathers
    the eligible ones and then evaluates their statuses with the PEP.

    If you want to know more about the SeSInspectorAgent, scroll down to the
    end of the file.
  '''

  # Too many public methods
  # pylint: disable-msg=R0904

  def initialize( self ):

    # Attribute defined outside __init__ 
    # pylint: disable-msg=W0201

    try:
      self.rsClient      = ResourceStatusClient()
      self.servicesFreqs = CS.getTypedDictRootedAtOperations( 'CheckingFreqs/ServicesFreqs' )
      self.queue         = Queue.Queue()

      self.maxNumberOfThreads = self.am_getOption( 'maxThreadsInPool', 1 )
      self.threadPool         = ThreadPool( self.maxNumberOfThreads,
                                            self.maxNumberOfThreads )
      if not self.threadPool:
        self.log.error( 'Can not create Thread Pool' )
        return S_ERROR( 'Can not create Thread Pool' )

      for _i in xrange( self.maxNumberOfThreads ):
        self.threadPool.generateJobAndQueueIt( self._executeCheck )

      return S_OK()

    except Exception:
      errorStr = "SeSInspectorAgent initialization"
      self.log.exception( errorStr )
      return S_ERROR( errorStr )

  def execute( self ):

    try:
      
      kwargs = { 'meta' : {} }
      kwargs['meta']['columns'] = [ 'ServiceName', 'StatusType', 'Status',
                                    'FormerStatus', 'SiteType',
                                    'ServiceType', 'TokenOwner' ]
      kwargs[ 'tokenOwner' ]    = 'RS_SVC'

      resQuery = self.rsClient.getStuffToCheck( 'Service', self.servicesFreqs, **kwargs )
      if not resQuery[ 'OK' ]:
        self.log.error( resQuery[ 'Message' ] )
        return resQuery

      resQuery = resQuery[ 'Value' ]
      self.log.info( 'Found %d candidates to be checked.' % len( resQuery ) )

      for service in resQuery:
        resourceL = [ 'Service' ] + service
        # Here we peek INSIDE the Queue to know if the item is already
        # here. It's ok _here_ since (i.e. I know what I'm doing):
        # - It is a read only operation.
        # - We do not need exact accuracy, it's ok to have 2 times the same item in the queue sometimes.
        if resourceL not in self.queue.queue:
          self.queue.put( resourceL )

      return S_OK()

    except Exception, x:
      errorStr = where( self, self.execute )
      self.log.exception( errorStr, lException = x )
      return S_ERROR( errorStr )
开发者ID:bmb,项目名称:DIRAC,代码行数:77,代码来源:SeSInspectorAgent.py


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