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)
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)
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)
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()
def epfdRestore(self, p: ProcessId): key = getKeyForProcess(p) if key in self.suspected.keys(): del self.suspected[key] self.check()
def epfdSuspect(self, p: ProcessId): key = getKeyForProcess(p) self.suspected[key] = p self.check()
def plDeliverState(self, q: ProcessId, ts, v): key = getKeyForProcess(q) self.states[key] = EpState(ts, v) self.checkStates()
def plDeliverHeartbeatReply(self, p: ProcessId): key = getKeyForProcess(p) self.alive[key] = p