Scalable Surfstore Golang Project 4

# Scalable Surfstore

## Extend your surfstore project
1. Make a copy of your solution if you want to:
mkdir proj4
cp -r proj3/* proj4

2. copy over consistent hashing files and new new .proto service defination
mkdir cmd/SurfstorePrintBlockMapping
cp /yourPath/starter-code/cmd/SurfstorePrintBlockMapping/main.go cmd/SurfstorePrintBlockMapping/
cp /yourPath/starter-code/pkg/surfstore/ConsistentHashRing.go pkg/surfstore
cp /yourPath/starter-code/pkg/surfstore/SurfStore.proto pkg/surfstore
cp /yourPath/starter-code/pkg/surfstore/SurfstoreInterfaces.go pkg/surfstore

4. manually change MetaStore.go
type MetaStore struct {
FileMetaMap map[string]*FileMetaData
– BlockStoreAddr string
+ BlockStoreAddrs []string
+ ConsistentHashRing *ConsistentHashRing
UnimplementedMetaStoreServer

-func (m *MetaStore) GetBlockStoreAddr(ctx context.Context, _ *emptypb.Empty) (*BlockStoreAddr, error) {
– panic(“todo”)
+func (m *MetaStore) GetBlockStoreMap(ctx context.Context, blockHashesIn *BlockHashes) (*BlockStoreMap, error) {
+ panic(“todo”)
+func (m *MetaStore) GetBlockStoreAddrs(ctx context.Context, _ *emptypb.Empty) (*BlockStoreAddrs, error) {
+ panic(“todo”)

-func NewMetaStore(blockStoreAddr string) *MetaStore {
+func NewMetaStore(blockStoreAddrs []string) *MetaStore {
return &MetaStore{
FileMetaMap: map[string]*FileMetaData{},
– BlockStoreAddr: blockStoreAddr,
+ BlockStoreAddrs: blockStoreAddrs,
+ ConsistentHashRing: NewConsistentHashRing(blockStoreAddrs),

5. add the following function in BlockStore.go
+// Return a list containing all blockHashes on this block server
+func (bs *BlockStore) GetBlockHashes(ctx context.Context, _ *emptypb.Empty) (*BlockHashes, error) {
+ panic(“todo”)

6. extend SurfstoreRPCClient.go
+func (surfClient *RPCClient) GetBlockHashes(blockStoreAddr string, blockHashes *[]string) error {
+ panic(“todo”)

-func (surfClient *RPCClient) GetBlockStoreAddr(blockStoreAddr *string) error {
– panic(“todo”)
+func (surfClient *RPCClient) GetBlockStoreMap(blockHashesIn []string, blockStoreMap *map[string][]string) error {
+ panic(“todo”)
+func (surfClient *RPCClient) GetBlockStoreAddrs(blockStoreAddrs *[]string) error {
+ panic(“todo”)

7. change your code in `cmd/SurfstoreServerExec/main.go` to handle multiple tail aruguments. In previous project, we only have one tail argument indicating the single block server’s address. Now we want to handle multiple arguments to configure multiple block servers.

## Protocol buffers