Skip to content
Snippets Groups Projects
Commit 9b22d3f8 authored by Dixon Tirtayadi's avatar Dixon Tirtayadi
Browse files

Small bug in heartbeat

parent a5c3a160
No related branches found
No related tags found
No related merge requests found
{
"servers": [
"127.0.0.1", "9000",
"127.0.0.1", "9001",
"127.0.0.1", "9002"
]
}
\ No newline at end of file
......@@ -172,7 +172,8 @@ class Paxos(socketserver.UDPServer):
# Skip messages are learned imediately
if p2a.value is not None and self.highest_ballot_seen[self.slotToLeaderIndex(p2a.slot_num)] != p2a.ballot_num:
# Drop if value is not Skip and is proposed by non-coordinator for that slot
print(f"Dropped because {p2a.ballot_num} is not from {self.highest_ballot_seen[self.slotToLeaderIndex(p2a.slot_num)]}")
print(f"{self.address} Dropped because {p2a.ballot_num} is not from {self.highest_ballot_seen[self.slotToLeaderIndex(p2a.slot_num)]}")
print(f"{self.address} highest ballot seen is {[str(i) for i in self.highest_ballot_seen]}")
return
# If it is a skip and from the coordinator, immediately learns it (put it in their log)
......@@ -233,7 +234,7 @@ class Paxos(socketserver.UDPServer):
def handleLeaderHeartbeat(self, heartbeat, address):
for i in range(len(heartbeat.leader_slot)):
if not self.is_leader[i]:
if not self.is_leader[i] and heartbeat.leader_slot[i]:
if self.highest_ballot_seen[i] > heartbeat.ballot_num:
# It's not "leader" heartbeat
return
......@@ -426,11 +427,11 @@ class PaxosHandler(socketserver.BaseRequestHandler):
self.server.handleP1B(message, self.client_address)
elif isinstance(message, P2A):
print(f"got p2a {message}", file=sys.stdout) # debug
print(f"{self.server.server_address} got p2a {message}", file=sys.stdout) # debug
self.server.handleP2A(message, message.addr)
elif isinstance(message, P2B):
print(f"got p2b {message}", file=sys.stdout) # debug
print(f"{self.server.server_address} got p2b {message}", file=sys.stdout) # debug
self.server.handleP2B(message, self.client_address)
elif isinstance(message, LeaderHeartbeat):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment