Example #1
0
    def handle(self, msg):
        """
        Set the :attr:`alive <powerapi.actor.state.State.alive>`
        attribute of the actor state to False

        :param Object msg: the message received by the actor
        """
        if not isinstance(msg, PoisonPillMessage):
            raise UnknowMessageTypeException(type(msg))

        self.state.alive = False
Example #2
0
    def handle(self, msg):
        """
        Process a report and send the result(s) to a pusher actor.
        :param msg: Received message
        :return: New actor state
        :raise: UnknowMessageTypeException when the given message is not an HWPCReport
        """
        if not isinstance(msg, HWPCReport):
            raise UnknowMessageTypeException(type(msg))

        self._process_report(msg)
Example #3
0
    def get_corresponding_handler(self, msg):
        """
        Return the handler corresponding to the given message type

        :param Object msg: the received message
        :return: the handler corresponding to the given message type
        :rtype: powerapi.handler.AbstractHandler

        :raises UnknowMessageTypeException: if no handler could be find
        """
        for (msg_type, handler) in self.handlers:
            if isinstance(msg, msg_type):
                return handler

        raise UnknowMessageTypeException()
Example #4
0
    def get_dispatch_rule(self, msg):
        """
        Return the corresponding group by rule mapped to the received message
        type

        :param type msg: the received message
        :return: the dispatch_rule rule mapped to the received message type
        :rtype: powerapi.dispatch_rule.DispatchRule
        :raise: UnknowMessageTypeException if no group by rule is mapped to the
                received message type
        """
        for (report_class, dispatch_rule) in self.route_table:
            if isinstance(msg, report_class):
                return dispatch_rule

        raise UnknowMessageTypeException(type(msg))
    def handle(self, msg, state):
        """
        Set the :attr:`alive <powerapi.actor.state.State.alive>`
        attribute of the actor state to False

        :param Object msg: the message received by the actor
        :param state: The current actor's state
        :type state: powerapi.actor.state.State

        :return: The new actor's state
        :rtype: powerapi.actor.state.State
        """
        if not isinstance(msg, PoisonPillMessage):
            raise UnknowMessageTypeException(type(msg))

        state.alive = False
        return state
Example #6
0
    def handle(self, msg, state):
        """
        Process a report and send the result(s) to a pusher actor.

        :param msg: Received message
        :param state: Current actor state
        :return: New actor state
        :raises UnknowMessageTypeException: if the given message is not an HWPCReport
        """
        if not isinstance(msg, HWPCReport):
            raise UnknowMessageTypeException(type(msg))

        result = self._process_report(msg, state)
        for report in result:
            self.actor_pusher.send_data(report)

        return state
Example #7
0
    def handle(self, msg, state):
        """
        Process a report and send the result to the pusher actor

        :param powerapi.Report msg:       Received message
        :param powerapi.State state: Actor state

        :return: New Actor state
        :rtype:  powerapi.State

        :raises UnknowMessageTypeException: If the msg is not a Report
        """
        if not isinstance(msg, Report):
            raise UnknowMessageTypeException(type(msg))

        result = self._process_report(msg)
        self.actor_pusher.send_data(result)
        return state