Esempio n. 1
0
 def __init__(self, server=None):
     State.__init__(self, server)
     self.matchIndex = defaultdict(int)
     self.nextIndex = defaultdict(int)
     for node in self.server.connectedNode:
         # For each server, index of the next log entry to send to that server
         self.nextIndex[node] = self.server.lastLogIndex() + 1
         # For each server, index of highest log entry known to be replicated on server
         self.matchIndex[node] = -1
     if self.server.timer:
         self.server.timer.cancel()
     # heartbeat
     self.hThread = threading.Thread(target=self.heartbeat)
     self.hThread.start()
 def __init__(self, server=None):
     State.__init__(self, server)
     self.voteReceived = {self.server.id: 1}
     self.votedFor = self.server.id
     self.server.setElectionTimer()
     self.requestElection()
 def __init__(self, server=None):
     # Initialize the server first
     State.__init__(self, server)
     if self.server:
         self.server.setElectionTimer()