This repository contains:
- Chord ring routing with deterministic keys
- DFS file metadata + paged file contents stored on the ring
- Distributed sorting workflow over file records (
key,value) - Simplified Paxos-style replication flow (
ACCEPT,LEARN, majority commit)
python3 main.py demoFor a live, stateful demonstration session (single process, persistent in-memory state during the session):
python3 main.py shellThe demo builds:
- 5 Chord peers
- 3 Paxos replicas
- one input distributed file from
samples/input_records.csv - one sorted output distributed file
sorted_records.csv
In dfs_chord/dfs.py:
touch(filename)append(filename, local_path)read(filename)head(filename, n)tail(filename, n)delete_file(filename)ls()stat(filename)sort_file(filename, output_filename)
Metadata key:
hash("metadata:" + filename)
Page key:
hash(filename + ":" + page_no)
Metadata structure includes:
- logical filename
- total bytes
- number of pages
- ordered page descriptors
- metadata version
Each page descriptor includes:
page_noguid(deterministic key)replicas(3 successor nodes)
In dfs_chord/paxos.py:
- leader increments ballot/slot for each operation
- sends
ACCEPT(slot, ballot)to replicas - if majority accepts, sends
LEARN(slot, ballot) - operation commits when majority learns
- committed operations are recorded in order in
commit_log
Fault model simulation:
- optional message drops via
drop_rate - supports delayed/lost semantics at a simplified level
sort_file(input, output) performs:
- read all input pages
- parse records
key,value - route records to successor peer of
hash(key) - sort records locally on each peer partition
- merge for global sorted output
- store result as new distributed DFS file
python3 tools/validate_sorted.py output.csvGenerate submission-friendly artifacts (Paxos logs, topology, sorted output, checks):
python3 tools/generate_evidence.pyGenerated files in evidence/:
paxos_messages.logchord_topology.jsondfs_stats.jsonsorted_records.csvsorted_check.txt
1. python3 main.py shell
2. touch records.csv
3. append records.csv samples/input_records.csv
4. stat records.csv
5. sort records.csv sorted_records.csv
6. head sorted_records.csv 10
7. paxos
This flow demonstrates the DFS API, distributed sorting, and Paxos message sequence in one run.