This project implements a Distributed Network File System (DNFS) with three main components: a Naming Server, multiple Storage Servers, and Clients. DNFS supports distributed file storage, access control, replication for fault tolerance, and advanced file operations such as streaming and sentence-level editing.
- Naming Server (NM): Central directory and controller. Manages file indexing (hash maps), client authentication, ACLs, storage server heartbeats, and replication logic.
- Storage Server (SS): Handles file storage and data operations. Manages local file parsing, lazy-loading, and synchronization with the NM.
- Client: User interface for interacting with the file system. Communicates with the NM for file locations and connects to SS for file operations.
- Distributed File Operations: Create, read, delete, and list files across servers.
- Sentence-Level Editing: Update specific sentences in a file with
WRITEand revert withUNDO. - Streaming: Stream file content with controlled delays.
- Access Control:
- Ownership and ACL-based permissions (Read/Write).
- Request-approval workflow for access to non-owned files.
- Fault Tolerance & Replication:
- Automatic file replication to backup servers.
- Primary-backup failover with automatic client redirection.
- Heartbeat monitoring for server failure detection.
- Recycle Bin: Soft-delete with garbage collection after a configurable timeout (default 60 seconds).
- Checkpoints: Create and revert to file snapshots.
- Remote Execution: Execute shell scripts on storage servers.
- GCC (C99 or later)
- POSIX Threads (pthreads)
- Linux/Unix environment (uses system calls like
mkdir,remove,popen)
Compile the project using the provided Makefile:
make allThis generates three executables: nameserver_exe, storageserver_exe, and client_exe.
The Naming Server listens for clients on port 8080 and Storage Servers on port 8081.
./nameserver_exeEach Storage Server requires specific arguments:
./storageserver_exe <nm_ip> <nm_port> <advertise_ip> <client_port> <storage_dir> <is_primary>nm_port: Use 8081.is_primary: 1 for primary, 0 for backup.
./client_exeFollow prompts to enter the Naming Server IP and your username.
| Command | Description |
|---|---|
VIEW [-a] [-l] |
View all files (optionally list all/detailed info) |
CREATE <filename> |
Create a new file |
READ <filename> |
Read file content |
WRITE <filename> <sentence_no> |
Edit or append a sentence |
UNDO <filename> |
Revert the last write |
STREAM <filename> |
Stream file content |
DELETE [-F] <filename> |
Soft delete (use -F for hard delete) |
RESTORE <filename> |
Restore from Recycle Bin |
VIEWTRASH |
List files in Recycle Bin |
CHECKPOINT <file> <tag> |
Create a named snapshot |
REVERT <file> <tag> |
Revert to a checkpoint |
REQACCESS <file> <R/W> |
Request file access |
APPROVE <file> <user> |
Approve access request (Owner only) |
EXEC <filename> |
Execute a shell script on server |
exit |
Disconnect from the system |
System limits and constants are defined in networking.h:
PAYLOAD_SIZE: 4096 bytesMAX_CLIENTS: 100MAX_SS: 10MAX_REPLICAS: 1
This project is licensed under the MIT License.