Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DBE-DS-Group1-WS24
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Leber
DBE-DS-Group1-WS24
Commits
aa616013
Commit
aa616013
authored
Feb 4, 2024
by
Quoc Nguyen Dao
Browse files
Options
Downloads
Patches
Plain Diff
heartbeat fix
parent
2512fa2e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+4
-2
4 additions, 2 deletions
server.py
with
4 additions
and
2 deletions
server.py
+
4
−
2
View file @
aa616013
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment