File Sharing System
For this project you will implement a highly available distributed service for synchronizing access to small files. The project design is based on ZooKeeper, a distributed coordination service that is part of the Apache Hadoop project.
The service consists of N servers (where N is on the order of 5) and an arbitrary number of clients. The servers should be identified 1, 2, …, N. Each server stores a replica of the of files.
When a client is started, it specifies which server ID to connect to. Once connected, the client can issue the following commands:
create <filename>: creates an empty file named <filename>
delete <filename>: deletes file named <filename>
read <filename: displays the contents of <filename>
append <filename> <line>: appends a <line> to <filename>
A client can issue multiple commands in a single session, connected to the same server. When a client issues a read command, the contents of the file should be displayed. When a client issues a create, delete, or append command, the client should receive a notification once this operation has been completed at the server the client is connected to.
If a client requests to read, append to, or delete a file that does not exist, an appropriate error message should be displayed, and the session should be allowed to continue. A client terminates a session by entering ‘exit’.
You can assume that file names are unique.
Each server must have a replica of the file system. You will implement the ZooKeeper Atomic Broadcast algorithm to propagate updates to the replicas of the file system.
Your code should use TCP sockets. You may use an existing library/package for serialization. You must write your own client/server code for socket and thread-handling.