本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.RequestClient.RequestClient.serveRequest方法的典型用法代码示例。如果您正苦于以下问题:Python RequestClient.serveRequest方法的具体用法?Python RequestClient.serveRequest怎么用?Python RequestClient.serveRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.RequestManagementSystem.Client.RequestClient.RequestClient
的用法示例。
在下文中一共展示了RequestClient.serveRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ZuziaAgent
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestClient import RequestClient [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestClient.RequestClient import serveRequest [as 别名]
class ZuziaAgent(AgentModule):
def initialize(self):
self.RequestDBClient = RequestClient()
gMonitor.registerActivity("Iteration", "Agent Loops", "ZuziaAgent", "Loops/min", gMonitor.OP_SUM)
gMonitor.registerActivity("Attempted", "Request Processed", "ZuziaRAgent", "Requests/min", gMonitor.OP_SUM)
gMonitor.registerActivity("Successful", "Request Forward Successful", "ZuziaAgent", "Requests/min", gMonitor.OP_SUM)
gMonitor.registerActivity("Failed", "Request Forward Failed", "ZuziaAgent", "Requests/min", gMonitor.OP_SUM)
self.local = PathFinder.getServiceURL("RequestManagement/localURL")
if not self.local:
self.local = AgentModule.am_getOption(self,'localURL','')
if not self.local:
errStr = 'The RequestManagement/localURL option must be defined.'
gLogger.fatal(errStr)
return S_ERROR(errStr)
self.central = PathFinder.getServiceURL("RequestManagement/centralURL")
if not self.central:
errStr = 'The RequestManagement/centralURL option must be defined.'
gLogger.fatal(errStr)
return S_ERROR(errStr)
return S_OK()
def execute(self):
""" This agent is the smallest and (cutest) of all the DIRAC agents in existence.
"""
gMonitor.addMark("Iteration",1)
central = PathFinder.getServiceURL("RequestManagement/centralURL")
if central:
self.central = central
local = PathFinder.getServiceURL("RequestManagement/localURL")
if local:
self.local = local
res = self.RequestDBClient.serveRequest(url=self.local)
if not res['OK']:
gLogger.error("ZuziaAgent.execute: Failed to get request from database.",self.local)
return S_OK()
elif not res['Value']:
gLogger.info("ZuziaAgent.execute: No requests to be executed found.")
return S_OK()
gMonitor.addMark("Attempted",1)
requestString = res['Value']['RequestString']
requestName = res['Value']['RequestName']
gLogger.info("ZuziaAgent.execute: Obtained request %s" % requestName)
gLogger.info("ZuziaAgent.execute: Attempting to set request to %s." % self.central)
res = self.RequestDBClient.setRequest(requestName,requestString,self.central)
if res['OK']:
gMonitor.addMark("Successful",1)
gLogger.info("ZuziaAgent.execute: Successfully put request.")
else:
gMonitor.addMark("Failed",1)
gLogger.error("ZuziaAgent.execute: Failed to set request to", self.central)
gLogger.info("ZuziaAgent.execute: Attempting to set request to %s." % self.local)
res = self.RequestDBClient.setRequest(requestName,requestString,self.local)
if res['OK']:
gLogger.info("ZuziaAgent.execute: Successfully put request.")
else:
gLogger.error("ZuziaAgent.execute: Failed to set request to", self.local)
while not res['OK']:
gLogger.info("ZuziaAgent.execute: Attempting to set request to anywhere.")
res = self.RequestDBClient.setRequest(requestName,requestString)
gLogger.info("ZuziaAgent.execute: Successfully put request to %s." % res["Server"])
return S_OK()