Skip to content

akhilsurya/FileDRaft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FileDRaft

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.

Sample Usage

$ go install github.com/akhilsurya/akhilsurya/cs733/assignment4
$ go $GOBIN/assignment4

The API

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

Other errors

  • 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

Some Conventions

  • 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

Version

1.0.0

Installation

$ 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$"

TODO

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages