This is a consistent, replicated file storage that uses the RAFT consensus protocol for log sharing between servers.
- Read a particular file
- Write to it and get the current version
- Compare and Swap contents(CAS) by giving the correct(current) version number of the file
- Delete a particular file.
The files can also be made to expire after a given amount of time specified during writes.
$ go install github.com/akhilsurya/akhilsurya/cs733/assignment4
$ go $GOBIN/assignment4
Command | Success Response | Error Response |
---|---|---|
read filename \r\n | CONTENTS version numbytes exptime remaining\r\n content bytes\r\n |
ERR_FILE_NOT_FOUND |
write filename numbytes [exptime]\r\n content bytes\r\n |
OK version\r\n | |
cas filename version numbytes [exptime]\r\n content bytes\r\n |
OK version\r\n | ERR_VERSION newversion |
delete filename \r\n | OK\r\n | ERR_FILE_NOT_FOUND |
- ERR_REDIRECT : Suggests that the node connected to is not the leader and gives the URL of the leader. If it does not know the leader an
_
is returned in place of the url field - ERR_INTERNAL : Suggests an Internal error has occured and you need to retry later
- If the exptime given is 0, the file does not expire
- An update to expiry time resets the time left to expire
- 8095, 8096... 8099 are the ports of 5 nodes running
1.0.0
$ go get github.com/akhilsurya/akhilsurya
$ go test -v github.com/akhilsurya/akhilsurya/cs733/assignment4 -run "^TestRPC_BasicSequential|TestRPC_Binary|TestRPC_Chunks|TestRPC_Batch|TestRPC_BasicTimer|TestRPC_ConcurrentWrites|TestRPC_ConcurrentCas|TestRPC_KillLeader$"
$ go test -v github.com/akhilsurya/akhilsurya/cs733/assignment4 -run "^TestRaft1|TestRaft3$"
$ go test -v github.com/akhilsurya/akhilsurya/cs733/assignment4 -run "^TestRaft1|TestRaft3$"
- Write Tests(There are never enough tests)
- Add Code Comments
- Make startup of the servers better i.e. Make each node start individually
- Right now, one can only shutdown all the nodes together through the CLI