dist-fs is a Unix-style distributed filesystem written in Java, which uses Gradle for build automation. It also includes a Python client program for interacting with the filesystem. The system supports the following commands: cd, pwd, mkdir, write, read, rm, and tree.
To get started with dist-fs, you need to have the following installed on your system:
- Java Development Kit (JDK) 21
- Python 3.11
- Gradle
git clone git@github.com:kpp16/dist-fs.git
cd dist-fsThis project uses RAFT consensus algorithm to ensure a consistent state across multiple servers. To set up the RAFT servers, run RaftWorkerServer in your respective servers (Docker coming soon!).
javac worker/RaftWorkerServer.java
java worker.RaftWorkerServer <current-address> <peer-addresses> <storage-dir>And note down the peers in FileBlock.java (setting peers up in .env also coming soon!)
Navigate back to the project root and build the project using Gradle:
./gradlew buildThe client program is located in pyclient/client.py. The client acts as an interactive shell for the distributed filesystem.
Navigate to the pyclient Directory cd pyclient and run the Client python3 client.py
Once the client is running, you can use the following commands in the interactive shell:
pwd: Print the current directory.mkdir: <directory_name>: Create a new directory.write: <file_name> : Write data to a file.read: <file_name>: Read data from a file.rm: <file_name>: Delete file.tree: Display the directory tree.exit: Exit the shell.cd <dir>Change current directory.
I was too lazy to fix the absolute paths, so for every command that you execute, make sure that you are in the correct folder. For example,
write folder1/folder2/hello.txt hello worldWILL NOT WORK! It will create the structure folder1/folder2 but hello.txt will be stored in your current directory instead. Feel free to fix it!
$ python3 client.py
Connected to server at localhost:8080
/@localhost:8080 > mkdir folder1
Directory folder1 created.
/@localhost:8080 > cd folder1
Changed directory to folder1
/folder1@localhost:8080 > pwd
/folder1
/folder1@localhost:8080 > write hello.txt hello world
File hello.txt created.
/folder1@localhost:8080 > read hello.txt
hello world
/folder1@localhost:8080 > delete hello.txt
Unknown command: delete
/folder1@localhost:8080 > rm hello.txt
Deleted file hello.txt.
/folder1@localhost:8080 > read hello.txt
Error: File does not exist
/folder1@localhost:8080 > pwd
/folder1
/folder1@localhost:8080 > cd ..
Changed directory to ..
/@localhost:8080 > write tst.txt this is a test file
File tst.txt created.
/@localhost:8080 > read tst.txt
this is a test file
/@localhost:8080 > exit
Exiting...- Fix absolute paths as mentioned above.
- Right now, only the data blocks (
FileBlock.java) is being stored in different servers. Find a way to also store the Inode table and path mappings in different servers instead of storing them in RAM. - Make the FileSystemServer take the PORT as an argument.
- Make the client.py also take the PORT as an argument.
- Implement
rmdircommand. - Make the tree command look pretty.
Contributions are welcome! Please fork the repository and open a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details. Contact
For any questions or issues, please open an issue on the GitHub repository or contact the maintainer. Feel free to modify the instructions as needed based on your specific setup and requirements.