Exemple #1
0
    def plDeliver(self, p: ProcessId):
        if getKeyForProcess(self.trusted) == getKeyForProcess(self.system.me):
            self.ts += len(self.system.processes)
            message = Message()
            bebBroadcast = BebBroadcast()

            bebBroadcast.message.abstractionId = 'ec'
            bebBroadcast.message.ecNewEpoch_.timestamp = self.ts
            bebBroadcast.message.type = Message.Type.EC_NEW_EPOCH_

            message.abstractionId = 'beb'
            message.bebBroadcast.CopyFrom(bebBroadcast)
            message.type = Message.Type.BEB_BROADCAST

            self.system.events.append(message)
Exemple #2
0
    def bebDeliver(self, p: ProcessId, newTs: int):
        if getKeyForProcess(p) == getKeyForProcess(
                self.trusted) and newTs > self.lastts:
            message = Message()

            message.abstractionId = 'uc'
            message.ecStartEpoch.newLeader.CopyFrom(p)
            message.ecStartEpoch.newTimestamp = newTs
            message.type = Message.Type.EC_START_EPOCH
            self.system.events.append(message)
        else:
            self.lastts = newTs
            message = Message()

            message.plSend.destination.CopyFrom(p)
            message.type = Message.Type.PL_SEND
            message.plSend.message.abstractionId = 'ec'
            message.plSend.message.type = Message.Type.EC_NACK_

            self.system.events.append(message)
Exemple #3
0
    def appPropose(self, v: Value, processes: []):
        for p in processes:
            key = getKeyForProcess(p)
            self.system.processes[key] = p
            if key == getKeyForProcess(self.system.me):
                self.system.me.rank = p.rank

        if len(processes):
            self.system.abstractions.append(Pl(self.system))
            self.system.abstractions.append(Ec(self.system))
            self.system.abstractions.append(Uc(self.system))
            self.system.abstractions.append(Eld(self.system))
            self.system.abstractions.append(Beb(self.system))
            self.system.abstractions.append(Epfd(self.system))
        
        m = Message()
        m.abstractionId = 'uc'
        m.ucPropose.value.CopyFrom(v)
        m.type = Message.Type.UC_PROPOSE
        self.system.events.append(m)
Exemple #4
0
    def epdfTimeout(self):
        if len(self.alive.keys() & self.suspected.keys()):
            self.delay += delta
        for p in self.system.processes.values():
            key = getKeyForProcess(p)
            if (not key in self.alive.keys()) and (not key
                                                   in self.suspected.keys()):
                self.suspected[key] = p

                message = Message()
                message.abstractionId = 'eld'
                message.epfdSuspect.process.CopyFrom(p)
                message.type = Message.Type.EPFD_SUSPECT

                self.system.events.append(message)

            elif (key in self.alive.keys()) and (key in self.suspected.keys()):
                del self.suspected[key]

                message = Message()
                message.abstractionId = 'eld'
                message.epfdRestore.process.CopyFrom(p)
                message.type = Message.Type.EPFD_RESTORE

                self.system.events.append(message)

            message = Message()

            message.type = Message.Type.PL_SEND
            message.plSend.destination.CopyFrom(p)
            message.plSend.message.abstractionId = 'epfd'
            message.plSend.message.type = Message.Type.EPFD_HEARTBEAT_REQUEST

            self.system.events.append(message)

        self.alive.clear()
        self.startTimer()
Exemple #5
0
 def epfdRestore(self, p: ProcessId):
     key = getKeyForProcess(p)
     if key in self.suspected.keys():
         del self.suspected[key]
         self.check()
Exemple #6
0
 def epfdSuspect(self, p: ProcessId):
     key = getKeyForProcess(p)
     self.suspected[key] = p
     self.check()
Exemple #7
0
    def plDeliverState(self, q: ProcessId, ts, v):
        key = getKeyForProcess(q)
        self.states[key] = EpState(ts, v)

        self.checkStates()
Exemple #8
0
 def plDeliverHeartbeatReply(self, p: ProcessId):
     key = getKeyForProcess(p)
     self.alive[key] = p