class ExecutionEngineAgent(ResourceAgent): """Agent to manage processes on a worker """ def __init__(self): log.debug("ExecutionEngineAgent init") ResourceAgent.__init__(self) def on_init(self): if not EEAgentCore: msg = "EEAgentCore isn't available. Use production.cfg buildout" log.error(msg) return log.debug("ExecutionEngineAgent Pyon on_init") launch_type_name = self.CFG.eeagent.launch_type.name if not launch_type_name: # TODO: Fail fast here? log.error("No launch_type.name specified") self._factory = get_exe_factory(launch_type_name, self.CFG, pyon_container=self.container, log=log) # TODO: Allow other core class? self.core = EEAgentCore(self.CFG, self._factory, log) interval = self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT) if interval > 0: self.heartbeater = HeartBeater(self.CFG, self._factory, log=log) looping_call(interval, self.heartbeater.poll) def on_quit(self): self._factory.terminate() def rcmd_launch_process(self, u_pid, round, run_type, parameters): self.core.launch_process(u_pid, round, run_type, parameters) def rcmd_terminate_process(self, u_pid, round): self.core.terminate_process(u_pid, round) def rcmd_restart_process(self, u_pid, round): self.core.restart_process(u_pid, round) def rcmd_cleanup(self, u_pid, round): self.core.cleanup(u_pid, round) def rcmd_dump_state(self): return make_beat_msg(self.core._process_managers_map)