Commit Graph
12 Commits
Author SHA1 Message Date
cozis fb28e94a83 Continued work on the WAL 2025-11-17 21:52:44 +01:00
cozis 7b01ac6384 Fix compilation errors 2025-11-13 20:21:26 +01:00
cozis cdce267768 Update DESIGN.txt and code accordingly 2025-11-13 17:27:00 +01:00
cozis 6a608051d6 Clean up timeout code in metadata server 2025-11-10 15:07:38 +01:00
Claude 02b58a26a7 Implement periodic health checks for chunk servers
This implements the periodic STATE_UPDATE mechanism described in DESIGN.txt
lines 80-99, where the metadata server periodically sends synchronization
messages to chunk servers.

Changes:

1. Added timing fields to ChunkServerPeer:
   - last_sync_time: tracks when STATE_UPDATE was last sent
   - last_response_time: tracks when chunk server last responded

2. Added health check configuration constants (config.h):
   - HEALTH_CHECK_INTERVAL: 30 seconds between STATE_UPDATE messages
   - HEALTH_CHECK_TIMEOUT: 90 seconds before marking server as unhealthy

3. Implemented send_state_update() function:
   - Serializes and sends add_list and rem_list to chunk servers
   - Updates last_sync_time when messages are sent

4. Added message handlers for chunk server responses:
   - process_chunk_server_state_update_success(): merges add_list into old_list,
     clears pending lists, updates last_response_time
   - process_chunk_server_state_update_error(): handles missing chunks,
     updates last_response_time, logs errors

5. Implemented periodic timer logic in metadata_server_step():
   - Calculates when next STATE_UPDATE should be sent to each chunk server
   - Sends updates when HEALTH_CHECK_INTERVAL has elapsed
   - Logs warnings when chunk servers haven't responded within HEALTH_CHECK_TIMEOUT
   - Sets appropriate poll() timeout to wake up for next health check

The implementation ensures that:
- Chunk servers receive regular synchronization messages with add_list/rem_list
- The metadata server tracks chunk server health based on response times
- STATE_UPDATE messages are sent periodically (every 30 seconds by default)
- Failed/missing chunks are detected and logged for recovery

This completes the health check mechanism described in the architecture design,
enabling the metadata server to maintain accurate state with chunk servers and
detect unhealthy servers.
2025-11-10 12:50:15 +00:00
cozis d13ad3ae6c Progress 2025-11-09 19:43:24 +01:00
cozis 739d6a7aee Progress 2025-11-09 12:08:22 +01:00
Claude 88a3a6e4f0 Add timeout parameter to metadata_server and chunk_server init/step functions
Unified the function signatures across all process types (metadata server,
chunk server, and simulation client) to accept an int *timeout parameter.
This provides consistency in the simulation framework and allows all
process types to control their wakeup times.

**Changes:**

**Headers (metadata_server.h, chunk_server.h):**
- Updated metadata_server_init() to accept int *timeout parameter
- Updated metadata_server_step() to accept int *timeout parameter
- Updated chunk_server_init() to accept int *timeout parameter
- Updated chunk_server_step() to accept int *timeout parameter

**Implementations (metadata_server.c, chunk_server.c):**
- Modified init functions to set *timeout = -1 (no timeout needed)
- Modified step functions to set *timeout = -1 (no timeout needed)
- Both server types currently don't require periodic wakeups, but the
  parameter allows for future timeout-based behavior

**System Integration (system.c):**
- Updated spawn_simulated_process() to declare timeout variable once
  and pass it to all process init functions uniformly
- Updated update_simulation() to declare timeout variable once and
  pass it to all process step functions uniformly
- Simplified control flow by removing special case for client timeout
  handling - now all process types use the same timeout logic
- Consolidated timeout-to-wakeup_time conversion after switch statements

**Benefits:**
- Consistent API across all process types
- Cleaner code with reduced duplication
- Future-proof for server timeout requirements
- All processes now managed uniformly by simulation framework

The simulation continues to run correctly with all process types
handling timeout parameter appropriately.
2025-11-02 12:33:40 +00:00
cozis 7525a93035 Progress 2025-10-29 23:48:45 +01:00
cozis 174f37c6c0 Continue work on DST framework 2025-10-29 21:46:17 +01:00
cozis fb8ac1d5c9 Fix compiler errors 2025-10-28 17:33:52 +01:00
cozis c5a21608d7 Split project over multiple files 2025-10-28 17:24:25 +01:00