Skip to content
Snippets Groups Projects
Commit aa616013 authored by Quoc Nguyen Dao's avatar Quoc Nguyen Dao
Browse files

heartbeat fix

parent 2512fa2e
Branches
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@ class Server():
self.informServer = False
self.serverList = [] # list if servers and their addresses
self.leader_uuid = '' # fix the leader IP
self.leader_ip = ''
self.is_leader = False # New variable to track if the server is the leader
self.uuid = str(uuid.uuid4())
self.participant = False
......@@ -315,6 +316,7 @@ class Server():
if data:
self.leader_heartbeat_last_received = time.time()
sender_ip = address[0]
self.leader_ip = sender_ip
if sender_ip != MY_IP:
print(f"Received heartbeat from {sender_ip}: {data.decode()}")
......@@ -327,8 +329,8 @@ class Server():
if self.missed_heartbeats >= self.missed_heartbeats_limit:
print("Missed heartbeats limit reached. Initiating leader election.")
thread_election.join()
thread_election.start()
self.serverList.remove(self.leader_ip)
self.basic_lcr()
# Reset missed heartbeats count
self.missed_heartbeats = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment