Exemplo n.º 1
0
class EEAgentMessageHandler(object):

    def __init__(self, CFG, process_managers_map, log, core_class=None):

        if core_class:
            self.core = core_class(CFG, process_managers_map, log)
        else:
            self.core = EEAgentCore(CFG, process_managers_map, log)

        self.CFG = CFG
        self._process_managers_map = process_managers_map
        self.ee_name = CFG.eeagent.name
        self.exchange = CFG.server.amqp.exchange
        self._log = log
        self.dashi = dashi_connect(self.ee_name, CFG)

        self.dashi.handle(self.launch_process, "launch_process")
        self.dashi.handle(self.terminate_process, "terminate_process")
        self.dashi.handle(self.restart_process, "restart_process")
        self.dashi.handle(self.dump_state, "dump_state")
        self.dashi.handle(self.cleanup, "cleanup")

    def dump_state(self, rpc=False):
        if rpc:
            return make_beat_msg(self._process_managers_map, self.CFG)
        else:
            beat_it(self.dashi, self.CFG, self._process_managers_map, log=self._log)

    def launch_process(self, u_pid, round, run_type, parameters):
        try:
            self.core.launch_process(u_pid, round, run_type, parameters)
        except Exception, ex:
            self._log.exception("Error on launch %s" % (str(ex)))
Exemplo n.º 2
0
    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            self.heartbeat_thread = None
            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)
            self.heartbeater.poll()
            self.heartbeat_thread = looping_call(0.1, self.heartbeater.poll)
        else:
            self.heartbeat_thread = None
class ExecutionEngineAgent(SimpleResourceAgent):
    """Agent to manage processes on a worker

    """
    def __init__(self):
        log.debug("ExecutionEngineAgent init")
        SimpleResourceAgent.__init__(self)

    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            self.heartbeat_thread = None
            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 = float(self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT))
        if interval > 0:
            self.heartbeater = HeartBeater(self.CFG,
                                           self._factory,
                                           self.resource_id,
                                           self,
                                           log=log)
            self.heartbeater.poll()
            self.heartbeat_thread, self._heartbeat_thread_event = looping_call(
                0.1, self.heartbeater.poll)
        else:
            self.heartbeat_thread = None
            self._heartbeat_thread_event = None

    def on_quit(self):
        if self._heartbeat_thread_event is not None:
            self._heartbeat_thread_event.set()
            self.heartbeat_thread.join()
            self.heartbeat_thread.kill()  # just in case

        self._factory.terminate()

    def rcmd_launch_process(self, u_pid, round, run_type, parameters):
        try:
            self.core.launch_process(u_pid, round, run_type, parameters)
        except EEAgentUnauthorizedException, e:
            raise Unauthorized(e.message)
        except PIDanticExecutionException, e:
            raise NotFound(e.message)
class ExecutionEngineAgent(SimpleResourceAgent):
    """Agent to manage processes on a worker

    """

    def __init__(self):
        log.debug("ExecutionEngineAgent init")
        SimpleResourceAgent.__init__(self)

    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            self.heartbeat_thread = None
            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 = float(self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT))
        if interval > 0:
            self.heartbeater = HeartBeater(
                self.CFG, self._factory, self.resource_id, self, log=log)
            self.heartbeater.poll()
            self.heartbeat_thread, self._heartbeat_thread_event = looping_call(0.1, self.heartbeater.poll)
        else:
            self.heartbeat_thread = None
            self._heartbeat_thread_event = None

    def on_quit(self):
        if self._heartbeat_thread_event is not None:
            self._heartbeat_thread_event.set()
            self.heartbeat_thread.join()
            self.heartbeat_thread.kill()        # just in case

        self._factory.terminate()

    def rcmd_launch_process(self, u_pid, round, run_type, parameters):
        try:
            self.core.launch_process(u_pid, round, run_type, parameters)
        except EEAgentUnauthorizedException, e:
            raise Unauthorized(e.message)
        except PIDanticExecutionException, e:
            raise NotFound(e.message)
    def on_init(self):
        if not EEAgentCore:
            msg = "EEAgentCore isn't available. Use autolaunch.cfg buildout"
            log.error(msg)
            self.heartbeat_thread = None
            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 = float(self.CFG.eeagent.get('heartbeat', DEFAULT_HEARTBEAT))
        if interval > 0:
            self.heartbeater = HeartBeater(
                self.CFG, self._factory, self.resource_id, self, log=log)
            self.heartbeater.poll()
            self.heartbeat_thread, self._heartbeat_thread_event = looping_call(0.1, self.heartbeater.poll)
        else:
            self.heartbeat_thread = None
            self._heartbeat_thread_event = None
Exemplo n.º 6
0
    def __init__(self, CFG, process_managers_map, log, core_class=None):

        if core_class:
            self.core = core_class(CFG, process_managers_map, log)
        else:
            self.core = EEAgentCore(CFG, process_managers_map, log)

        self.CFG = CFG
        self._process_managers_map = process_managers_map
        self.ee_name = CFG.eeagent.name
        self.exchange = CFG.server.amqp.exchange
        self._log = log
        self.dashi = dashi_connect(self.ee_name, CFG)

        self.dashi.handle(self.launch_process, "launch_process")
        self.dashi.handle(self.terminate_process, "terminate_process")
        self.dashi.handle(self.restart_process, "restart_process")
        self.dashi.handle(self.dump_state, "dump_state")
        self.dashi.handle(self.cleanup, "cleanup")
Exemplo n.º 7
0
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)
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)
    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)