From 86f2060544139a74690e3b6f4386c1847c9e2548 Mon Sep 17 00:00:00 2001 From: Casper-NS Date: Tue, 26 Nov 2024 12:21:45 +0100 Subject: [PATCH] Added a new exercise for lecture 8 --- README.md | 8 ++++++++ exercises/exercise8.py | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index c55c649..aa5821a 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,14 @@ For all exercises today, you can use the `sync` network type - but most algorith when they should be sent, etc 3. Implement your solution, starting from the handler of RecordAppendReqMessage of the GfsChunkserver class 4. Try out your solution with a larger number of clients, to have more concurrent changes to the "file" +3. Implement fault tolerance mechanisms(Heartbeat Detection and Failover Mechanism) in the system: + 1. Heartbeat Detection: The GFS master should periodically receive heartbeats from each chunkserver to monitor their health. + 1. Modify the GfsChunkserver class to send periodic heartbeat messages to the GfsMaster. + 2. Update the GfsMaster class to maintain a list of active chunkservers based on received heartbeats. + 2. Failover Mechanism: When a chunkserver fails (i.e., stops sending heartbeats), the requests should be redirected to available replicas. + 1. Introduce a simple mechanism to simulate a chunkserver failing. + 2. Update the GfsMaster to detect a missing heartbeat and mark the corresponding chunkserver as failed. + 3. Ensure the client (GfsClient) can reroute operations to other replicas if a chunkserver has failed. 3. BONUS Exercise: Add shadow masters to the system. Clients and chunk servers will still interact with the first master to change the file system, but the shadow master can take over if the master shuts down. diff --git a/exercises/exercise8.py b/exercises/exercise8.py index d96e21d..4e85ad2 100644 --- a/exercises/exercise8.py +++ b/exercises/exercise8.py @@ -273,3 +273,10 @@ def __init__(self, sender: int, destination: int, result: str): def __str__(self): return f"RECORD APPEND RESPONSE {self.source} -> {self.destination}: ({self.result})" + +class HeartbeatMessage(MessageStub): + def __init__(self, sender: int, destination: int): + super().__init__(sender, destination) + + def __str__(self): + return f"HEARTBEAT {self.source} -> {self.destination}" \ No newline at end of file