execute tasks nly of right type

This commit is contained in:
Johannes Findeisen 2013-11-09 04:29:49 +01:00
commit e7d1c97a48
2 changed files with 8 additions and 5 deletions

View file

@ -42,7 +42,7 @@
} }
}, },
"periods": { "periods": {
"fast": { "seconds": 15 }, "fast": { "seconds": 3 },
"medium": { "seconds": 120 }, "medium": { "seconds": 120 },
"slow": { "seconds": 480 } "slow": { "seconds": 480 }
}, },
@ -54,14 +54,14 @@
{ {
"class": "etc/dummy", "class": "etc/dummy",
"periods": ["fast"], "periods": ["fast"],
"threshold": 1, "threshold": 10,
"args": { "sleep": 1, "fail": true } "args": { "sleep": 1, "fail": true }
}, },
{ {
"class": "etc/dummy", "class": "etc/dummy",
"periods": ["fast"], "periods": ["fast"],
"threshold": 1, "threshold": 1,
"args": { "sleep": 10, "fail": false } "args": { "sleep": 1, "fail": false }
} }
] ]
}, },

View file

@ -108,12 +108,15 @@ class Job:
if self.job_threshold >= service_threshold: if self.job_threshold >= service_threshold:
logger.info("Job " + self.hex_string() + ", Threshold reached!") logger.info("Job " + self.hex_string() + ", Threshold reached!")
self.status = "ERROR" self.status = "ERROR"
self.handle_alarm()
self.handle_alarm()
def handle_alarm(self): def handle_alarm(self):
for member in self.members: for member in self.members:
for task in member.get_tasks(): for task in member.get_tasks():
TaskExecutor.Instance().schedule_task(self.get_message(), task) if self.status.lower() == task.get_task_type_name():
logger.debug("Executing Task of type: " + self.status)
TaskExecutor.Instance().schedule_task(self.status + " " + self.get_message(), task)
def handle_call(self): def handle_call(self):
logger.debug("handle call") logger.debug("handle call")