示例#1
0
文件: main.py 项目: netixx/NetProbes
    def shutdown(signum = None, frame = None):
        with stopLock:
            global stopped
            if stopped:
                return
            else:
                stopped = True
        logging.getLogger().info("Shutting down probe")
        Scheduler.quit()
        if Params.COMMANDER and commander is not None:
            commander.quit()
        from calls.actions import Quit

        if Params.WATCHERS:
            WatcherManager.stopWatchers()
        from managers.probetests import TestManager, TestResponder

        TestManager.stopTests()
        TestResponder.stopTests()
        if actionMan is not None:
            ActionMan.addTask(Quit())
        if server is not None:
            server.quit()
        if actionMan is not None:
            actionMan.quit()
        #everybody might need the client so stop it last
        if client is not None:
            client.quit()
示例#2
0
文件: main.py 项目: netixx/NetProbes
    def shutdown(signum=None, frame=None):
        with stopLock:
            global stopped
            if stopped:
                return
            else:
                stopped = True
        logging.getLogger().info("Shutting down probe")
        Scheduler.quit()
        if Params.COMMANDER and commander is not None:
            commander.quit()
        from calls.actions import Quit

        if Params.WATCHERS:
            WatcherManager.stopWatchers()
        from managers.probetests import TestManager, TestResponder

        TestManager.stopTests()
        TestResponder.stopTests()
        if actionMan is not None:
            ActionMan.addTask(Quit())
        if server is not None:
            server.quit()
        if actionMan is not None:
            actionMan.quit()
        #everybody might need the client so stop it last
        if client is not None:
            client.quit()
示例#3
0
    def treatMessage(cls, message):
        """Handles the receptions of a Message (called by the listener)
        For regular Actions, addTask is called after translation of the message
        For TesterMessages and TesteeMessages, treatTestMessage is called
        :param message: The Message instance to treat

        """
        cls.logger.debug("Treating message %s", message.__class__.__name__)
        assert isinstance(message, Message)
        # forwarding mechanism
        if message.targetId != Identification.PROBE_ID:
            if ProbeStorage.isKnownId(message.targetId):
                message.recipientId = message.targetId
            else:
                #if we already forwarded it before , stop here
                if message.hash in cls.forwardedMessages:
                    cls.logger.warning(
                        "Throwing message %s in forward because message was previously forwarded.",
                        message.__class__.__name__)
                    return
                Scheduler.forward()
                message.recipientId = ProbeStorage.getOtherRandomId()
            cls.logger.info("Forwarding message %s for %s to id %s",
                            message.__class__.__name__, message.targetId,
                            message.recipientId)
            cls.forwardedMessages.append(message.hash)
            Client.send(message)
            return
        # handle special class of messages separately
        if isinstance(message, TestMessage):
            cls.treatTestMessage(message)
        elif isinstance(message, WatcherMessage):
            cls.treatWatcherMessage(message)
        elif isinstance(message, BroadCast):
            # broadcast = do required action first and continue broadcast
            cls.logger.ddebug("Handling Broadcast")
            try:
                ActionMan.addTask(MTA.toAction(message.getMessage()))
            except ActionError:
                pass
            # be sure to propagate broadcast if a reasonable error occurs
            ActionMan.addTask(MTA.toAction(message))
            # Client.broadcast(message)
        else:
            # handles everything else, including Do messages
            ActionMan.addTask(MTA.toAction(message))
示例#4
0
    def treatMessage(cls, message):
        """Handles the receptions of a Message (called by the listener)
        For regular Actions, addTask is called after translation of the message
        For TesterMessages and TesteeMessages, treatTestMessage is called
        :param message: The Message instance to treat

        """
        cls.logger.debug("Treating message %s", message.__class__.__name__)
        assert isinstance(message, Message)
        # forwarding mechanism
        if message.targetId != Identification.PROBE_ID:
            if ProbeStorage.isKnownId(message.targetId):
                message.recipientId = message.targetId
            else:
                #if we already forwarded it before , stop here
                if message.hash in cls.forwardedMessages:
                    cls.logger.warning("Throwing message %s in forward because message was previously forwarded.", message.__class__.__name__)
                    return
                Scheduler.forward()
                message.recipientId = ProbeStorage.getOtherRandomId()
            cls.logger.info("Forwarding message %s for %s to id %s", message.__class__.__name__, message.targetId, message.recipientId)
            cls.forwardedMessages.append(message.hash)
            Client.send(message)
            return
        # handle special class of messages separately
        if isinstance(message, TestMessage):
            cls.treatTestMessage(message)
        elif isinstance(message, WatcherMessage):
            cls.treatWatcherMessage(message)
        elif isinstance(message, BroadCast):
            # broadcast = do required action first and continue broadcast
            cls.logger.ddebug("Handling Broadcast")
            try:
                ActionMan.addTask(MTA.toAction(message.getMessage()))
            except ActionError:
                pass
            # be sure to propagate broadcast if a reasonable error occurs
            ActionMan.addTask(MTA.toAction(message))
            # Client.broadcast(message)
        else:
            # handles everything else, including Do messages
            ActionMan.addTask(MTA.toAction(message))