本文整理汇总了Python中WMCore.Services.WMStats.WMStatsReader.WMStatsReader.agentsByTeam方法的典型用法代码示例。如果您正苦于以下问题:Python WMStatsReader.agentsByTeam方法的具体用法?Python WMStatsReader.agentsByTeam怎么用?Python WMStatsReader.agentsByTeam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.WMStats.WMStatsReader.WMStatsReader
的用法示例。
在下文中一共展示了WMStatsReader.agentsByTeam方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TeamInfo
# 需要导入模块: from WMCore.Services.WMStats.WMStatsReader import WMStatsReader [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsReader.WMStatsReader import agentsByTeam [as 别名]
class TeamInfo(RESTEntity):
"""
This class need to move under WMStats server when wmstats server created
"""
def __init__(self, app, api, config, mount):
# main CouchDB database where requests/workloads are stored
RESTEntity.__init__(self, app, api, config, mount)
wmstats_url = "%s/%s" % (self.config.couch_host, self.config.couch_wmstats_db)
self.wmstats = WMStatsReader(wmstats_url)
def validate(self, apiobj, method, api, param, safe):
args_length = len(param.args)
if args_length == 1:
safe.args.append(param.args[0])
param.args.pop()
return
@restcall(formats = [('application/json', JSONFormat())])
@tools.expires(secs=-1)
def get(self):
result = self.wmstats.agentsByTeam(filterDrain=False)
return rows(result.keys())
示例2: ResourceControlUpdater
# 需要导入模块: from WMCore.Services.WMStats.WMStatsReader import WMStatsReader [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsReader.WMStatsReader import agentsByTeam [as 别名]
#.........这里部分代码省略.........
if not self.enabled:
logging.info("This component is not enabled in the configuration. Doing nothing.")
return
try:
sitesRC = self.resourceControl.listSitesSlots()
logging.debug("Info from resource control: %s" % sitesRC)
sitesSSB = self.getInfoFromSSB()
if not sitesSSB:
return
logging.debug("Info from SSB: %s" % sitesSSB)
# Check which site states need to be updated in the database
sitesRC = self.checkStatusChanges(sitesRC, sitesSSB)
# get number of agents working in the same team (not in DrainMode)
self.getAgentsByTeam()
# Check which site slots need to be updated in the database
self.checkSlotsChanges(sitesRC, sitesSSB, self.agentsNumByTeam)
except Exception as ex:
logging.error("Error occurred, will retry later:")
logging.error(str(ex))
logging.error("Trace back: \n%s" % traceback.format_exc())
logging.info("Resource control cycle finished updating site state and thresholds.")
def getAgentsByTeam(self):
"""
_getAgentsByTeam_
Get the WMStats view about agents and teams
"""
agentsByTeam = {}
try:
agentsByTeam = self.centralCouchDBReader.agentsByTeam()
except Exception as ex:
logging.error("WMStats is not available or is unresponsive.")
if not agentsByTeam:
logging.debug("agentInfo couch view is not available, use default value %s" % self.agentsNumByTeam)
else:
self.agentsByTeam = agentsByTeam
agentsCount = []
for team in self.teamNames.split(','):
if team not in self.agentsByTeam:
agentsCount.append(1)
else:
agentsCount.append(self.agentsByTeam[team])
# If agent is in several teams, we choose the team with less agents
self.agentsNumByTeam = min(agentsCount, self.agentsNumByTeam)
logging.debug("Agents connected to the same team (not in DrainMode): %d" % self.agentsNumByTeam)
return
def getInfoFromSSB(self):
"""
_getInfoFromSSB_
Get site status, CPU bound and IO bound from dashboard (SSB).
Returns a dict of dicts where the first key is the site name.
"""
# urls from site status board
url_site_state = self.dashboard + '/request.py/getplotdata?columnid=%s&batch=1&lastdata=1' % str(self.siteStatusMetric)
url_cpu_bound = self.dashboard + '/request.py/getplotdata?columnid=%s&batch=1&lastdata=1' % str(self.cpuBoundMetric)
url_io_bound = self.dashboard + '/request.py/getplotdata?columnid=%s&batch=1&lastdata=1' % str(self.ioBoundMetric)
示例3: ResourceControlUpdater
# 需要导入模块: from WMCore.Services.WMStats.WMStatsReader import WMStatsReader [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsReader.WMStatsReader import agentsByTeam [as 别名]
class ResourceControlUpdater(BaseWorkerThread):
"""
Update site status and thresholds from SSB
"""
def __init__(self, config):
"""
Initialize
"""
BaseWorkerThread.__init__(self)
# set the workqueue service for REST call
self.config = config
self.setVariables(self.config)
def setVariables(self, config):
"""
load all the variables from the config file
"""
# get dashboard url, set metric columns from config
self.dashboard = config.AgentStatusWatcher.dashboard
self.siteStatusMetric = config.AgentStatusWatcher.siteStatusMetric
self.cpuBoundMetric = config.AgentStatusWatcher.cpuBoundMetric
self.ioBoundMetric = config.AgentStatusWatcher.ioBoundMetric
# set pending percentages from config
self.pendingSlotsSitePercent = config.AgentStatusWatcher.pendingSlotsSitePercent
self.pendingSlotsTaskPercent = config.AgentStatusWatcher.pendingSlotsTaskPercent
self.runningExpressPercentCPUBound = config.AgentStatusWatcher.runningExpressPercentCPUBound
self.runningRepackPercentIOBound = config.AgentStatusWatcher.runningRepackPercentIOBound
# forced site list
self.forcedSiteList = config.AgentStatusWatcher.forcedSiteList
# agent teams (for dynamic threshold) and queueParams (drain mode)
self.teamNames = config.Agent.teamName
self.queueParams = config.WorkQueueManager.queueParams
# only SSB sites
self.onlySSB = config.AgentStatusWatcher.onlySSB
# tier mode
self.tier0Mode = hasattr(config, "Tier0Feeder")
def setup(self, parameters):
"""
Set db connection and prepare resource control
"""
# Interface to WMBS/BossAir db
myThread = threading.currentThread()
# set resource control
self.resourceControl = ResourceControl(config = self.config)
# wmstats connection
self.centralCouchDBReader = WMStatsReader(self.config.AgentStatusWatcher.centralWMStatsURL)
# init variables
self.agentsByTeam = {}
def algorithm(self, parameters):
"""
_algorithm_
Update site info about state and thresholds
1. Get information from SSB
2. Get information about teams and agents from WMStats
3. Set site status and set therholds for each valid site
Sites from SSB are validated with PhEDEx node names
"""
try:
# set variables every polling cycle
self.setVariables(self.config)
# Get sites in Resource Control
currentSites = self.resourceControl.listCurrentSites()
logging.debug("Starting algorithm, getting site info from SSB")
stateBySite, slotsCPU, slotsIO = self.getInfoFromSSB()
if not stateBySite or not slotsCPU or not slotsIO:
logging.error("One or more of the SSB metrics is down. Please contact the Dashboard team.")
return
logging.debug("Setting status and thresholds for all sites, site pending: %s%%, task pending: %s%%" %
(str(self.pendingSlotsSitePercent), str(self.pendingSlotsTaskPercent)))
if self.queueParams.get('DrainMode', False):
agentsNum = 1
logging.debug("This agent is in DrainMode, don't divide pending thresholds")
else:
# get number of agents working in the same team (not in DrainMode)
agentsByTeam = self.centralCouchDBReader.agentsByTeam()
if not agentsByTeam:
agentsNum = 1
logging.debug("agentInfo couch view is not available, don't divide pending thresholds")
else:
self.agentsByTeam = agentsByTeam
teams = self.teamNames.split(',')
agentsCount = []
for team in teams:
if self.agentsByTeam[team] == 0:
#.........这里部分代码省略.........
示例4: ResourceControlUpdater
# 需要导入模块: from WMCore.Services.WMStats.WMStatsReader import WMStatsReader [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsReader.WMStatsReader import agentsByTeam [as 别名]
class ResourceControlUpdater(BaseWorkerThread):
"""
Update site status and thresholds from SSB
"""
def __init__(self, config):
"""
Initialize
"""
BaseWorkerThread.__init__(self)
self.config = config
# get dashboard url, set metric columns from config
self.dashboard = config.AgentStatusWatcher.dashboard
self.siteStatusMetric = config.AgentStatusWatcher.siteStatusMetric
self.cpuBoundMetric = config.AgentStatusWatcher.cpuBoundMetric
self.ioBoundMetric = config.AgentStatusWatcher.ioBoundMetric
# set pending percentages from config
self.pendingSlotsSitePercent = config.AgentStatusWatcher.pendingSlotsSitePercent
self.pendingSlotsTaskPercent = config.AgentStatusWatcher.pendingSlotsTaskPercent
self.runningExpressPercent = config.AgentStatusWatcher.runningExpressPercent
self.runningRepackPercent = config.AgentStatusWatcher.runningRepackPercent
# sites forced to down
self.forceSiteDown = getattr(config.AgentStatusWatcher, 'forceSiteDown', [])
# agent team (for dynamic threshold) and queueParams (drain mode)
self.teamName = config.Agent.teamName
self.agentsNumByTeam = getattr(config.AgentStatusWatcher, 'defaultAgentsNumByTeam', 5)
# only SSB sites
self.onlySSB = config.AgentStatusWatcher.onlySSB
# tier mode
self.tier0Mode = hasattr(config, "Tier0Feeder")
self.t1SitesCores = config.AgentStatusWatcher.t1SitesCores
# switch this component on/off
self.enabled = getattr(config.AgentStatusWatcher, 'enabled', True)
# set resource control
self.resourceControl = ResourceControl(config=self.config)
# wmstats connection
self.centralCouchDBReader = WMStatsReader(self.config.AgentStatusWatcher.centralWMStatsURL)
def algorithm(self, parameters):
"""
_algorithm_
Update site state and thresholds, based on differences between resource
control database and info available in SSB.
1. Get info from Resource Control database
2. Get info from SSB
3. Get information about teams and number of agents from WMStats
4. Change site state when needed (this triggers a condor clasAd fetch)
5. Change site thresholds when needed (and task thresholds)
Sites from SSB are validated with PhEDEx node names
"""
if not self.enabled:
logging.info("This component is not enabled in the configuration. Doing nothing.")
return
try:
sitesRC = self.resourceControl.listSitesSlots()
logging.debug("Info from resource control: %s", sitesRC)
sitesSSB = self.getInfoFromSSB()
if not sitesSSB:
return
logging.debug("Info from SSB: %s", sitesSSB)
# Check which site states need to be updated in the database
sitesRC = self.checkStatusChanges(sitesRC, sitesSSB)
# get number of agents working in the same team (not in DrainMode)
self.getAgentsByTeam()
# Check which site slots need to be updated in the database
self.checkSlotsChanges(sitesRC, sitesSSB, self.agentsNumByTeam)
except Exception as ex:
logging.error("Error occurred, will retry later:")
logging.error(str(ex))
logging.error("Trace back: \n%s", traceback.format_exc())
logging.info("Resource control cycle finished updating site state and thresholds.")
def getAgentsByTeam(self):
"""
_getAgentsByTeam_
Get the WMStats view about agents and teams
"""
if isDrainMode(self.config):
# maximize pending thresholds to get this agent drained ASAP
self.agentsNumByTeam = 1
return
agentsByTeam = {}
try:
agentsByTeam = self.centralCouchDBReader.agentsByTeam(filterDrain=True)
#.........这里部分代码省略.........
示例5: ResourceControlUpdater
# 需要导入模块: from WMCore.Services.WMStats.WMStatsReader import WMStatsReader [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsReader.WMStatsReader import agentsByTeam [as 别名]
#.........这里部分代码省略.........
ssbSiteStatus = self.getSiteStatus()
self.checkStatusChanges(sitesRC, ssbSiteStatus)
# now fetch site slots thresholds
sitesSSB = self.getInfoFromSSB()
if not sitesSSB:
logging.error("One or more of the SSB metrics is down. Please contact the Dashboard team.")
return
logging.debug("Info from SSB: %s", sitesSSB)
# get number of agents working in the same team (not in DrainMode)
self.getAgentsByTeam()
# Check which site slots need to be updated in the database
self.checkSlotsChanges(sitesRC, sitesSSB)
except Exception as ex:
logging.error("Error occurred, will retry later:")
logging.error(str(ex))
logging.error("Trace back: \n%s", traceback.format_exc())
logging.info("Resource control cycle finished updating site state and thresholds.")
def getAgentsByTeam(self):
"""
_getAgentsByTeam_
Get the WMStats view for agents and teams
"""
if isDrainMode(self.config):
# maximize pending thresholds to get this agent drained ASAP
self.agentsNumByTeam = 1
return
agentsByTeam = {}
try:
agentsByTeam = self.centralCouchDBReader.agentsByTeam(filterDrain=True)
except Exception:
logging.error("WMStats is not available or is unresponsive.")
if not agentsByTeam:
logging.warning("agentInfo couch view is not available, use default value %s", self.agentsNumByTeam)
else:
self.agentsNumByTeam = agentsByTeam.get(self.teamName, self.agentsNumByTeam)
logging.debug("Agents connected to the same team (not in DrainMode): %d", self.agentsNumByTeam)
return
def getInfoFromSSB(self):
"""
_getInfoFromSSB_
Get site status, CPU bound and IO bound from dashboard (SSB).
Returns a dict of dicts where the first key is the site name.
"""
ssbCpuSlots = self.ssb.getMetric(self.cpuBoundMetric)
ssbIoSlots = self.ssb.getMetric(self.ioBoundMetric)
ssbSiteSlots = self.thresholdsByVOName(ssbCpuSlots, ssbIoSlots)
return ssbSiteSlots
def checkStatusChanges(self, infoRC, infoSSB):
"""
_checkStatusChanges_
Checks which sites need to have their site state updated in