Distributed File System Prototype:
In this project I have used asynchronous sockets to enable multiple clients to connect to a server. I have developed the following functionalities of DFS assignment.
1. CreateFile(char*filename): Server returns 1 if a new file is created in its local directory on the behalf of user’s request. Filename can be up to 30 characters. Server returns -1 if a local copy of same filename already exists or there is some other problem.
2. OpenFile (char *filename, int mode): Opening a file means creating a local copy of the file at client’s end and client performs read and write operations on it. Mode can be “read” i.e. 0 or “write” i.e. 1. The system only allows 1 client to open a file in write mode at a given time. If call is successful, the call returns a positive value i.e. file descriptor. This file descriptor is subsequently used to perform read/write operations. Server returns -1 if file doesn’t exist or -2 if file has already been opened in write mode by any other client.
3. ReadFile (int fd, char *buffer): This call reads the contents of file described by its file descriptor and fills the buffer with it. The contents should be printed on client’s screen.
4. WriteFile(int fd, char *buffer, int length, int mode): This call writes the contents of buffer in a file described by its file descriptor “fd” up to the given length. Writes can happen in 3 different modes. i. Blocking: In this mode, file will be written to server and the write update is sent to all the clients who have opened this file in read mode. We call such clients as active replicas. Once the server and all replicas have been updated, call to this function returns with 1. ii. Non-Blocking: In this mode, file will be written to the server and it returns with a value = 1. That means, only the server has been updated and all the subsequent replicas are yet to be updated who have opened the file in read mode. iii. Disconnected: In this mode, the file is written on the local directory of the client. This is suitable for a mobile client who may not be connected to the server all the time. The server and replicas are only updated when the client closes the file. Technology Used: I have used mono and Xamarin as IDE for this assignment and language used is C#.
Here are the links for assignment description and projects files.