def testLatestJobDataExpired(self): self.assertFalse(DataCache.islatestJobDataExpired()) DataCache.setDuration(-1) self.assertTrue(DataCache.islatestJobDataExpired()) DataCache.setDuration(300) self.assertFalse(DataCache.islatestJobDataExpired()) DataCache._lastedActiveDataFromAgent = {} self.assertTrue(DataCache.islatestJobDataExpired()) self.assertEqual({}, DataCache.getlatestJobData())
def testLatestJobDataExpired(self): self.assertFalse(DataCache.islatestJobDataExpired()) DataCache.setDuration(-1) self.assertTrue(DataCache.islatestJobDataExpired()) DataCache.setDuration(300) self.assertFalse(DataCache.islatestJobDataExpired()) DataCache._lastedActiveDataFromAgent = {} self.assertTrue(DataCache.islatestJobDataExpired()) self.assertEqual({}, DataCache.getlatestJobData())
def gatherT0ActiveDataStats(self, config): """ gather active data statistics """ try: if DataCache.islatestJobDataExpired(): wmstatsDB = WMStatsReader(config.wmstats_url, reqdbURL=config.reqmgrdb_url, reqdbCouchApp = "T0Request") jobData = wmstatsDB.getT0ActiveData(jobInfoFlag = True) DataCache.setlatestJobData(jobData) self.logger.info("DataCache is updated: %s", len(jobData)) except Exception as ex: self.logger.error(str(ex)) return
def gatherActiveDataStats(self, config): """ gather active data statistics """ try: if DataCache.islatestJobDataExpired(): wmstatsDB = WMStatsReader(config.wmstats_url, config.reqmgrdb_url, reqdbCouchApp = "ReqMgr") jobData = wmstatsDB.getActiveData(jobInfoFlag = True) DataCache.setlatestJobData(jobData) except Exception as ex: cherrypy.log.error(str(ex)) return
def gatherT0ActiveDataStats(self, config): """ gather active data statistics """ try: if DataCache.islatestJobDataExpired(): wmstatsDB = WMStatsReader(config.wmstats_url, config.reqmgrdb_url, reqdbCouchApp = "T0Request") jobData = wmstatsDB.getT0ActiveData(jobInfoFlag = True) DataCache.setlatestJobData(jobData) self.logger.info("DataCache is updated: %s" % len(jobData)) except Exception as ex: self.logger.error(str(ex)) return
def gatherActiveDataStats(self, config): """ gather active data statistics """ try: if DataCache.islatestJobDataExpired(): wmstatsDB = WMStatsReader(config.wmstats_url, config.reqmgrdb_url, reqdbCouchApp="ReqMgr") jobData = wmstatsDB.getActiveData(jobInfoFlag=True) DataCache.setlatestJobData(jobData) except Exception as ex: cherrypy.log.error(str(ex)) return
def gatherActiveDataStats(): wmstats_url = "https://cmsweb.cern.ch/couchdb/wmstats" reqmgrdb_url = "https://cmsweb.cern.ch/couchdb/reqmgr_workload_cache" jobInfoFlag = False tStart = time.time() try: if DataCache.islatestJobDataExpired(): wmstatsDB = WMStatsReader(wmstats_url, reqdbURL=reqmgrdb_url, reqdbCouchApp="ReqMgr") jobData = wmstatsDB.getActiveData(jobInfoFlag=jobInfoFlag) DataCache.setlatestJobData(jobData) print("DataCache is updated: {}".format(len(jobData))) else: print("DataCache is up-to-date") except Exception as ex: print("Exception updating cache. Details: {}\nTraceback: {}".format( str(ex), str(traceback.format_exc()))) print("Total time executing this cycle: {}".format(time.time() - tStart))
def gatherActiveDataStats(self, config): """ gather active data statistics """ self.logger.info("Starting gatherActiveDataStats with jobInfo set to: %s", self.getJobInfo) try: tStart = time.time() if DataCache.islatestJobDataExpired(): wmstatsDB = WMStatsReader(config.wmstats_url, reqdbURL=config.reqmgrdb_url, reqdbCouchApp="ReqMgr", logger=self.logger) self.logger.info("Getting active data with job info for statuses: %s", WMSTATS_JOB_INFO) jobData = wmstatsDB.getActiveData(WMSTATS_JOB_INFO, jobInfoFlag=self.getJobInfo) self.logger.info("Getting active data with NO job info for statuses: %s", WMSTATS_NO_JOB_INFO) tempData = wmstatsDB.getActiveData(WMSTATS_NO_JOB_INFO, jobInfoFlag=False) jobData.update(tempData) self.logger.info("Running setlatestJobData...") DataCache.setlatestJobData(jobData) self.logger.info("DataCache is up-to-date with %d requests data", len(jobData)) except Exception as ex: self.logger.exception("Exception updating DataCache. Error: %s", str(ex)) self.logger.info("Total time loading data from ReqMgr2 and WMStats: %s", time.time() - tStart) return
def get(self): results = DataCache.getlatestJobData() if results == None or DataCache.islatestJobDataExpired(): results = self.wmstats.getActiveData(jobInfoFlag = True) return rows([results])
def get(self): results = DataCache.getlatestJobData() if results == None or DataCache.islatestJobDataExpired(): results = self.wmstats.getActiveData(jobInfoFlag=True) return rows([results])