Skip to content

About

Python-based distributed file system using Chord DHT, simplified Paxos consensus, fault-tolerant replication, and distributed sorting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Distributed File System on Chord (with Simplified Paxos)

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)

Quick Start

python3 main.py demo

For a live, stateful demonstration session (single process, persistent in-memory state during the session):

python3 main.py shell

The 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

Implemented DFS API

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)

Data Model

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_no
  • guid (deterministic key)
  • replicas (3 successor nodes)

Simplified Paxos Behavior

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

Sorting Workflow

sort_file(input, output) performs:

  1. read all input pages
  2. parse records key,value
  3. route records to successor peer of hash(key)
  4. sort records locally on each peer partition
  5. merge for global sorted output
  6. store result as new distributed DFS file

Validation Utility

python3 tools/validate_sorted.py output.csv

Evidence Bundle Generation

Generate submission-friendly artifacts (Paxos logs, topology, sorted output, checks):

python3 tools/generate_evidence.py

Generated files in evidence/:

  • paxos_messages.log
  • chord_topology.json
  • dfs_stats.json
  • sorted_records.csv
  • sorted_check.txt

Suggested Demo Script

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.

About

Python-based distributed file system using Chord DHT, simplified Paxos consensus, fault-tolerant replication, and distributed sorting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages