replayJournalfunction for both the Follower and the Leader. This function will iterate through the Journal and replay all the actions that have been committed to the journal. At the end, you should be able to continue receiving messages from where you left off in the Journal.
EntryIteratorwhich as the functions
Next. The journal itself can be modified with the functions
Empty. You must implement journaling in the follower's
globalfunctions. In the leader, you must implement journaling in
replayJournalfunction. For the follower, this function should update the internal state based on what entries were logged. For the leader, this function should either make a global COMMIT or ABORT based on what was last logged.
replayJournalfor the leader, you may at one point need to pass a context to some helper functions. The context is a concept in Golang that adds timeouts and deadlines to requests and you don't really need to understand how its used. (Although if you are curious this video is great.) The context normally comes from the gRPC
Putcall, but when replaying the journal we no longer have a context to work with. Thus we need to make a new context, which you can do with
hw6.txtin the hw6 directory. In it, answer the following questions:
api/kv.proto. Take a look a that file and describe what the keywords
pkg/tpc/rpcserver.goas well as the compiled frameworks in
pkg/rpc/tpc.protodefines a service that implements an RPC which takes a stream and returns a stream. This RPC is called a bi-directional stream. How is the bi-directional stream different from a normal request-response RPC?
pkg/tpc/messagemanager.go. Where is the bi-directional stream between the leader and each follower created? What does the function
SendMessagechange based on the value of the
retryargument? To help answer this question, take a look at the helper function
sendSingleMessage. In what situtaion would the retry argument be used?
retryvalues for sending a vote request and sending a global command. Take a look at the
pkg/tpc/tpcleader.go. Why does one have it set to true and the other have it set to false?