Implement chunk server state update handling
Fix how chunk servers handle state updates from the metadata server based on the design in DESIGN.txt. The implementation now: 1. Checks if chunks in the add_list exist in the chunk store and collects any missing chunks 2. Unmarks chunks in the add_list that were previously marked for removal 3. Marks chunks in the rem_list for removal with timestamps 4. Responds with SUCCESS if all chunks are present, or ERROR with the list of missing chunks Added: - RemovalList data structure to track chunks marked for deletion with timestamps - chunk_store_exists() to check if a chunk file exists - Helper functions for removal list management (init, free, add, remove, find) This implements the garbage collection mechanism described in DESIGN.txt where chunks are marked for removal and can be unmarked if they appear in the add_list again.
This commit is contained in:
@@ -25,6 +25,17 @@ typedef struct {
|
||||
PendingDownload *items;
|
||||
} PendingDownloadList;
|
||||
|
||||
typedef struct {
|
||||
SHA256 hash;
|
||||
Time marked_time;
|
||||
} PendingRemoval;
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
int capacity;
|
||||
PendingRemoval *items;
|
||||
} RemovalList;
|
||||
|
||||
typedef struct {
|
||||
bool trace;
|
||||
Address local_addr;
|
||||
@@ -34,6 +45,7 @@ typedef struct {
|
||||
ChunkStore store;
|
||||
bool downloading;
|
||||
PendingDownloadList pending_download_list;
|
||||
RemovalList removal_list;
|
||||
} ChunkServer;
|
||||
|
||||
int chunk_server_init(ChunkServer *state, int argc, char **argv, void **contexts, struct pollfd *polled, int *timeout);
|
||||
|
||||
Reference in New Issue
Block a user