Пример #1
0
    def _initiateBroadcast(cls, message, toMyself):
        cls.logger.debug("Initiating broadcast message %s",
                         message.__class__.__name__)
        # propagation phase
        prop = ProbeStorage.getIdAllOtherProbes()
        if toMyself:
            # make sure we are the first on our list
            prop.insert(0, Identification.PROBE_ID)

        # Only do something if there is something to do
        if len(prop) > 0:
            if len(prop) <= Consts.PROPAGATION_RATE:
                for p in prop:
                    mes = copy.deepcopy(message)
                    mes.targetId = p
                    mes.recipientId = p
                    cls.send(mes)
            else:
                pRate = Consts.PROPAGATION_RATE
                # take targets for first hop out of the list
                sendTo = prop[0:pRate]
                pt = prop[pRate:]
                propTargets = [pt[i::pRate] for i in range(pRate)]
                for i, firstHop in enumerate(sendTo):
                    cls.send(
                        BroadCast(firstHop, Identification.PROBE_ID, message,
                                  propTargets[i]))
Пример #2
0
    def _initiateBroadcast(cls, message, toMyself):
        cls.logger.debug("Initiating broadcast message %s", message.__class__.__name__)
        # propagation phase
        prop = ProbeStorage.getIdAllOtherProbes()
        if toMyself:
            # make sure we are the first on our list
            prop.insert(0, Identification.PROBE_ID)

        # Only do something if there is something to do
        if len(prop) > 0:
            if len(prop) <= Consts.PROPAGATION_RATE:
                for p in prop:
                    mes = copy.deepcopy(message)
                    mes.targetId = p
                    mes.recipientId = p
                    cls.send(mes)
            else:
                pRate = Consts.PROPAGATION_RATE
                # take targets for first hop out of the list
                sendTo = prop[0:pRate]
                pt = prop[pRate:]
                propTargets = [pt[i::pRate] for i in range(pRate)]
                for i, firstHop in enumerate(sendTo):
                    cls.send(BroadCast(firstHop, Identification.PROBE_ID, message, propTargets[i]))
Пример #3
0
 def getIdAllOtherProbes(cls):
     return ProbeStorage.getIdAllOtherProbes()
Пример #4
0
 def getIdAllOtherProbes():
     """Returns the Ids of all the other known probes"""
     return ProbeStorage.getIdAllOtherProbes()
Пример #5
0
 def getIdAllOtherProbes():
     """Returns the Ids of all the other known probes"""
     return ProbeStorage.getIdAllOtherProbes()