def saveStatus(self, flow, previousStatus, newStatus, difference, ticTime):
     if previousStatus != newStatus:
         self.notificator.statusChanged(flow, previousStatus, newStatus,
                                        ticTime)
     statusDict = {
         "status": newStatus,
         "ticTime": ticTime,
         "difference": difference
     }
     setObj = {"$set": {flow["gName"]: statusDict}}
     mongo.statuses().update_one({"_id": self.DOCUMENT_ID},
                                 setObj,
                                 upsert=True)
 def getAll(self, country):
     lobs = MediationConfig.getLobs(country)
     res = mongo.statuses().find_one({"_id": "lobs"}, {"_id": 0})
     if res is None:
         res = {}
     statuses = {}
     for lobName, lob in lobs.items():
         for flowName, flow in lob["flows"].items():
             gName = flow["gName"]
             if flow["options"]["enabled"] is False:
                 statuses[gName] = {"status": status.DISABLED}
             elif gName in res:
                 statuses[gName] = self._setStatusMetadata(res[gName], flow)
             else:
                 statuses[gName] = {"status": status.NA}
     return statuses
예제 #3
0
  def getStatus():
    from scheduler.ComponentMonitoring import ComponentMonitoring
    from mediation.flow_analyzer import DiscoverFlowsExecutor
    from mediation.flow_analyzer import MediationAnalyzerExecutor
    from zookeeper.analyzer import ZookeeperAnalyzerExecutor
    executors = [ComponentMonitoring, ZookeeperAnalyzerExecutor, MediationAnalyzerExecutor, DiscoverFlowsExecutor]
    kafkaComponents = [MediationStatusProducer.name, MediationDataConsumer.name]
    systemStatus = {"executors": {}, "kafka": {}}
    res = mongo.statuses().find_one({"_id": "system"}, {"_id": 0})
    if res == None:
      res = {}
    for executor in executors:
      executorStatus = res.get("executors", {}).get(executor.name, None)
      if executorStatus is None or _statusIsExpired(executorStatus["time"],
                                                    executor.interval + executor.maxRunningTime):
        systemStatus["executors"][executor.name] = "FAIL"
      else:
        systemStatus["executors"][executor.name] = executorStatus["status"]

    for componentName in kafkaComponents:
      componentStatus = res.get("kafka", {}).get(componentName, None)
      if componentStatus is None or \
        _statusIsExpired(componentStatus["time"], ComponentMonitoring.interval + ComponentMonitoring.maxRunningTime):
        systemStatus["kafka"][componentName] = "FAIL"
      else:
        systemStatus["kafka"][componentName] = componentStatus["status"]
    hasFail = False
    for executorStatus in systemStatus["executors"].values():
      if executorStatus == "FAIL":
        hasFail = True
    for kafkaStatus in systemStatus["kafka"].values():
      if kafkaStatus == "FAIL" or kafkaStatus == "DISCONNECTED":
        hasFail = True
    if hasFail:
      systemStatus["status"] = "FAIL"
    else:
      systemStatus["status"] = "OK"
    return systemStatus
 def getStatusForFlow(self, flow):
     gName = flow["gName"]
     res = mongo.statuses().find_one({"_id": "lobs"}, {gName: 1})
     if gName not in res:
         return {"validity": "expired"}
     return self._setStatusMetadata(res[gName], flow)
 def removeAll(self):
     mongo.statuses().delete_one({"_id": "lobs"})
 def resetStatus(self, flow):
     setObj = {"$unset": {flow["gName"]: ""}}
     mongo.statuses().update_one({"_id": self.DOCUMENT_ID},
                                 setObj,
                                 upsert=True)
     pass
예제 #7
0
 def saveExecutorSuccessfulExecution(executorName, time):
   mongo.statuses().update_one({"_id": "system"},
                         {"$set": {"executors." + executorName: {"time": time, "status": "OK"}}}, upsert=True)
예제 #8
0
 def setKafkaComponentStatus(name, status, time):
   mongo.statuses().update_one({"_id": "system"},
                         {"$set": {"kafka." + name: {"time": time, "status": status}}}, upsert=True)