本文整理汇总了Python中WMCore.Services.WMStats.WMStatsWriter.WMStatsWriter.getArchivedRequests方法的典型用法代码示例。如果您正苦于以下问题:Python WMStatsWriter.getArchivedRequests方法的具体用法?Python WMStatsWriter.getArchivedRequests怎么用?Python WMStatsWriter.getArchivedRequests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.WMStats.WMStatsWriter.WMStatsWriter
的用法示例。
在下文中一共展示了WMStatsWriter.getArchivedRequests方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CleanUpTask
# 需要导入模块: from WMCore.Services.WMStats.WMStatsWriter import WMStatsWriter [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsWriter.WMStatsWriter import getArchivedRequests [as 别名]
class CleanUpTask(CherryPyPeriodicTask):
"""
This class is used for both T0WMStats and WMStats
controlled by config.reqdb_couch_app value
"""
def __init__(self, rest, config):
super(CleanUpTask, self).__init__(config)
self.wmstatsDB = WMStatsWriter(config.wmstats_url, reqdbURL=config.reqmgrdb_url,
reqdbCouchApp=config.reqdb_couch_app)
def setConcurrentTasks(self, config):
"""
sets the list of functions which runs concurrently
"""
self.concurrentTasks = [{'func': self.cleanUpOldRequests, 'duration': (config.DataKeepDays * 24 * 60 * 60)},
{'func': self.cleanUpArchivedRequests, 'duration': config.archivedCleanUpDuration}]
def cleanUpOldRequests(self, config):
"""
clean up wmstats data older then given days
"""
self.logger.info("deleting %s hours old docs", (config.DataKeepDays * 24))
result = self.wmstatsDB.deleteOldDocs(config.DataKeepDays)
self.logger.info("%s old doc deleted", result)
return
def cleanUpArchivedRequests(self, config):
"""
loop through the workflows in couchdb, if archived delete all the data in couchdb
"""
self.logger.info("getting archived data")
requestNames = self.wmstatsDB.getArchivedRequests()
self.logger.info("archived list %s", requestNames)
for req in requestNames:
self.logger.info("Deleting data for: %s", req)
try:
result = self.wmstatsDB.deleteDocsByWorkflow(req)
except Exception as ex:
self.logger.error("deleting %s failed: %s", req, str(ex))
for line in traceback.format_exc().rstrip().split("\n"):
self.logger.error(" " + line)
else:
if result is None:
self.logger.info("there were no documents to delete.")
else:
self.logger.info("%s docs deleted", len(result))
return
示例2: CleanUpTask
# 需要导入模块: from WMCore.Services.WMStats.WMStatsWriter import WMStatsWriter [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsWriter.WMStatsWriter import getArchivedRequests [as 别名]
class CleanUpTask(CherryPyPeriodicTask):
"""
This class is used for both T0WMStats and WMStats
controlled by config.reqdb_couch_app value
"""
def __init__(self, rest, config):
CherryPyPeriodicTask.__init__(self, config)
self.wmstatsDB = WMStatsWriter(
config.wmstats_url, reqdbURL=config.reqmgrdb_url, reqdbCouchApp=config.reqdb_couch_app
)
def setConcurrentTasks(self, config):
"""
sets the list of functions which
"""
self.concurrentTasks = [
{"func": self.cleanUpOldRequests, "duration": (config.DataKeepDays * 24 * 60 * 60)},
{"func": self.cleanUpArchivedRequests, "duration": config.archivedCleanUpDuration},
]
def cleanUpOldRequests(self, config):
"""
clean up wmstats data older then given days
"""
self.logger.info("deleting %s hours old docs" % (config.DataKeepDays * 24))
result = self.wmstatsDB.deleteOldDocs(config.DataKeepDays)
self.logger.info("%s old doc deleted" % result)
return
def cleanUpArchivedRequests(self, config):
"""
loop through the workflows in couchdb, if archived delete all the data in couchdb
"""
requestNames = self.wmstatsDB.getArchivedRequests()
for req in requestNames:
self.logger.info("deleting %s data" % req)
result = self.wmstatsDB.deleteDocsByWorkflow(req)
self.logger.info("%s deleted" % result)
return