Instructions to extend project 4

  1. Make a copy of your solution if you want to:

mkdir proj5
cp -r proj4/* proj5
cd proj5
  1. Rename all module paths from “proj4” to “proj5” (you may have more that are not shown here)

$ grep -r proj4 ./
cmd/SurfstoreServerExec/main.go:        "cse224/proj4/pkg/surfstore"
cmd/SurfstoreClientExec/main.go:        "cse224/proj4/pkg/surfstore"
go.mod:module cse224/proj4
  1. Copy over the given test cases

mkdir test
cp -r /path/to/proj5/starter-code/test/* test/
  1. Copy over the Makefile and example config

cp /path/to/proj5/starter-code/Makefile .
cp /path/to/proj5/starter-code/example_config.txt .
  1. Copy over Raft specific files

mkdir cmd/SurfstoreRaftServerExec
cp /path/to/proj5/starter-code/cmd/SurfstoreRaftServerExec/main.go cmd/SurfstoreRaftServerExec/
cp /path/to/proj5/starter-code/pkg/surfstore/Raft* pkg/surfstore/
cp /path/to/proj5/starter-code/pkg/surfstore/SurfStore.proto pkg/surfstore/
  1. Copy over new client exec program and make changes to the client
cp /path/to/proj5/starter-code/cmd/SurfstoreClientExec/main.go cmd/SurfstoreClientExec/

The client will need to take a slice of strings instead of a single address. In pkg/surfstore/SurfstoreRPCClient.go change the client struct to:

type RPCClient struct {
        MetaStoreAddrs []string
        BaseDir       string
        BlockSize     int

And change the NewSurfstoreRPCClient function to:

func NewSurfstoreRPCClient(addrs []string, baseDir string, blockSize int) RPCClient {
        return RPCClient{
                MetaStoreAddrs: addrs,
                BaseDir:       baseDir,
                BlockSize:     blockSize,

MetaStore functionality is now provided by the RaftSurfstoreServer, so change the MetaStore clients to RaftSurfstoreServer clients:

c := NewRaftSurfstoreClient(conn)

And since we no longer have the MetaStoreAddr field, for now you can change surfclient.MetaStoreAddr to surfclient.MetaStoreAddrs[0]. You will eventually need to change this so you can find a leader, deal with server crashes, etc.

conn, err := grpc.Dial(surfClient.MetaStoreAddrs[0], grpc.WithInsecure())
  1. Re-generate the protobuf
protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/surfstore/SurfStore.proto

You should now be able to run make test and it will fail with the panic messages.


Run BlockStore server:

$ make run-blockstore

Run RaftSurfstore server:

$ make IDX=0 run-raft


$ make test

Specific Test:

$ make TEST_REGEX=Test specific-test


$ make clean


View Github