150 likes | 331 Views
CS244B: Replicated Files Project Session. Anthony Ho. CS244B Administration. Graded midterms will be returned first Mazewar grading completed afterwards Chapter 6 out. Two new papers. ReplFs Overview. Develop a client file API that creates copies of the file on multiple servers.
E N D
CS244B: Replicated Files Project Session Anthony Ho
CS244B Administration • Graded midterms will be returned first • Mazewar grading completed afterwards • Chapter 6 out. Two new papers
ReplFs Overview • Develop a client file API that creates copies of the file on multiple servers. • Appears to the application to be accessing one file, but replicated across servers. • Design protocol. • Everything due Thursday, May 29.
Library Linkage • Use C/C++. • Run a sample application. You won’t get more than 128 writes.
Interfaces • int InitReplFs(int portNum,int packetLoss); • int AddServer(char *id); Use this form • int OpenFile(char *name); • int WriteBlock(int fd, void *buffer, int byteOffset, int blockSize);
Interfaces • int Commit(int fd); • void Abort(int fd); • int CloseFile(int fd);
Writes • Writes using the client interface only permanently written to the file after the Commit function is called successfully. • If you Abort is called, then all writes since the last commit must be discarded
Use transactions • Each transaction has an identifier • Composed of a sequence of changes • Atomic - All changes made or all fail • Commit, Rollback • Example: • Write(‘hello’, 0, 5) • Write(‘ world’, 5, 6)
Two-phase commit • Client sends prepare to commit • Servers respond with ready to commit • Client sends out a commit • Once a server responds that it was ready to commit, then it must always be able to commit. Even if some messages are lost.
Designing Protocol • Client may need to retransmit • Flow control to prevent packet loss. Sending many messages at once can cause congestion. • What if a server is disconnected or crashes. Should work if server is still up. Commit only if all servers read to commit. • Server might need to indicate which writes are missing
Designing Protocol 2 • What do you do when aborts or commits are missed. • When does a new transaction start • Messages sent when • Closing a file • Aborting transaction • Other functions that you may use
Implementation • Make sure packetloss parameter works correctly. Only needs to drop packets at the client. • Should not hang, crash, or produce incorrect files • We may use more than 3 servers.
Implementation 2 • Handle errors. • System call errors. • Parameter checking. • API return values • Etc. • Use a checksum
Other cases • Do not need to resync with crashed server. For example, the server crashes after multiple commits. Should work if server is up though. • All servers specified by AddServer from the user application. • Don’t need to worry about client crashing.
Submission • Client code • Server code • Makefile that compiles code and creates linkable library • Protocol design, evaluation, and future directions