Documentation ¶
Index ¶
- Constants
- Variables
- func ClientSync(client RPCClient)
- func ConcatPath(baseDir, fileDir string) string
- func GetBlockHashBytes(blockData []byte) []byte
- func GetBlockHashString(blockData []byte) string
- func LoadMetaFromMetaFile(baseDir string) (fileMetaMap map[string]*FileMetaData, e error)
- func PrintMetaMap(metaMap map[string]*FileMetaData)
- func RegisterBlockStoreServer(s grpc.ServiceRegistrar, srv BlockStoreServer)
- func RegisterMetaStoreServer(s grpc.ServiceRegistrar, srv MetaStoreServer)
- func RegisterRaftSurfstoreServer(s grpc.ServiceRegistrar, srv RaftSurfstoreServer)
- func ServeRaftServer(server *RaftSurfstore) error
- func WriteMetaFile(fileMetas map[string]*FileMetaData, baseDir string) error
- type AppendEntryInput
- func (*AppendEntryInput) Descriptor() ([]byte, []int)deprecated
- func (x *AppendEntryInput) GetEntries() []*UpdateOperation
- func (x *AppendEntryInput) GetLeaderCommit() int64
- func (x *AppendEntryInput) GetPrevLogIndex() int64
- func (x *AppendEntryInput) GetPrevLogTerm() int64
- func (x *AppendEntryInput) GetTerm() int64
- func (*AppendEntryInput) ProtoMessage()
- func (x *AppendEntryInput) ProtoReflect() protoreflect.Message
- func (x *AppendEntryInput) Reset()
- func (x *AppendEntryInput) String() string
- type AppendEntryOutput
- func (*AppendEntryOutput) Descriptor() ([]byte, []int)deprecated
- func (x *AppendEntryOutput) GetMatchedIndex() int64
- func (x *AppendEntryOutput) GetServerId() int64
- func (x *AppendEntryOutput) GetSuccess() bool
- func (x *AppendEntryOutput) GetTerm() int64
- func (*AppendEntryOutput) ProtoMessage()
- func (x *AppendEntryOutput) ProtoReflect() protoreflect.Message
- func (x *AppendEntryOutput) Reset()
- func (x *AppendEntryOutput) String() string
- type Block
- type BlockHash
- type BlockHashes
- type BlockStore
- func (bs *BlockStore) GetBlock(ctx context.Context, blockHash *BlockHash) (*Block, error)
- func (bs *BlockStore) GetBlockHashes(ctx context.Context, _ *emptypb.Empty) (*BlockHashes, error)
- func (bs *BlockStore) HasBlocks(ctx context.Context, blockHashesIn *BlockHashes) (*BlockHashes, error)
- func (bs *BlockStore) PutBlock(ctx context.Context, block *Block) (*Success, error)
- type BlockStoreAddrs
- type BlockStoreClient
- type BlockStoreInterface
- type BlockStoreMap
- type BlockStoreServer
- type ClientInterface
- type ConsistentHashRing
- type CrashedState
- type FileInfoMap
- type FileMetaData
- func (*FileMetaData) Descriptor() ([]byte, []int)deprecated
- func (x *FileMetaData) GetBlockHashList() []string
- func (x *FileMetaData) GetFilename() string
- func (x *FileMetaData) GetVersion() int32
- func (*FileMetaData) ProtoMessage()
- func (x *FileMetaData) ProtoReflect() protoreflect.Message
- func (x *FileMetaData) Reset()
- func (x *FileMetaData) String() string
- type MetaStore
- func (m *MetaStore) GetBlockStoreAddrs(ctx context.Context, _ *emptypb.Empty) (*BlockStoreAddrs, error)
- func (m *MetaStore) GetBlockStoreMap(ctx context.Context, blockHashesIn *BlockHashes) (*BlockStoreMap, error)
- func (m *MetaStore) GetFileInfoMap(ctx context.Context, _ *emptypb.Empty) (*FileInfoMap, error)
- func (m *MetaStore) UpdateFile(ctx context.Context, fileMetaData *FileMetaData) (*Version, error)
- type MetaStoreClient
- type MetaStoreInterface
- type MetaStoreServer
- type RPCClient
- func (surfClient *RPCClient) GetBlock(blockHash string, blockStoreAddr string, block *Block) error
- func (surfClient *RPCClient) GetBlockHashes(blockStoreAddr string, blockHashes *[]string) error
- func (surfClient *RPCClient) GetBlockStoreAddrs(blockStoreAddrs *[]string) error
- func (surfClient *RPCClient) GetBlockStoreMap(blockHashesIn []string, blockStoreMap *map[string][]string) error
- func (surfClient *RPCClient) GetFileInfoMap(serverFileInfoMap *map[string]*FileMetaData) error
- func (surfClient *RPCClient) HasBlocks(blockHashesIn []string, blockStoreAddr string, blockHashesOut *[]string) error
- func (surfClient *RPCClient) PutBlock(block *Block, blockStoreAddr string, succ *bool) error
- func (surfClient *RPCClient) UpdateFile(fileMetaData *FileMetaData, latestVersion *int32) error
- type RaftConfig
- type RaftInterface
- type RaftInternalState
- func (*RaftInternalState) Descriptor() ([]byte, []int)deprecated
- func (x *RaftInternalState) GetIsLeader() bool
- func (x *RaftInternalState) GetLog() []*UpdateOperation
- func (x *RaftInternalState) GetMetaMap() *FileInfoMap
- func (x *RaftInternalState) GetTerm() int64
- func (*RaftInternalState) ProtoMessage()
- func (x *RaftInternalState) ProtoReflect() protoreflect.Message
- func (x *RaftInternalState) Reset()
- func (x *RaftInternalState) String() string
- type RaftSurfstore
- func (s *RaftSurfstore) AppendEntries(ctx context.Context, input *AppendEntryInput) (*AppendEntryOutput, error)
- func (s *RaftSurfstore) Crash(ctx context.Context, _ *emptypb.Empty) (*Success, error)
- func (s *RaftSurfstore) GetBlockStoreAddrs(ctx context.Context, empty *emptypb.Empty) (*BlockStoreAddrs, error)
- func (s *RaftSurfstore) GetBlockStoreMap(ctx context.Context, hashes *BlockHashes) (*BlockStoreMap, error)
- func (s *RaftSurfstore) GetFileInfoMap(ctx context.Context, empty *emptypb.Empty) (*FileInfoMap, error)
- func (s *RaftSurfstore) GetInternalState(ctx context.Context, empty *emptypb.Empty) (*RaftInternalState, error)
- func (s *RaftSurfstore) Restore(ctx context.Context, _ *emptypb.Empty) (*Success, error)
- func (s *RaftSurfstore) SendHeartbeat(ctx context.Context, _ *emptypb.Empty) (*Success, error)
- func (s *RaftSurfstore) SetLeader(ctx context.Context, _ *emptypb.Empty) (*Success, error)
- func (s *RaftSurfstore) UpdateFile(ctx context.Context, filemeta *FileMetaData) (*Version, error)
- type RaftSurfstoreClient
- type RaftSurfstoreInterface
- type RaftSurfstoreServer
- type RaftTestingInterface
- type Success
- type UnimplementedBlockStoreServer
- func (UnimplementedBlockStoreServer) GetBlock(context.Context, *BlockHash) (*Block, error)
- func (UnimplementedBlockStoreServer) GetBlockHashes(context.Context, *emptypb.Empty) (*BlockHashes, error)
- func (UnimplementedBlockStoreServer) HasBlocks(context.Context, *BlockHashes) (*BlockHashes, error)
- func (UnimplementedBlockStoreServer) PutBlock(context.Context, *Block) (*Success, error)
- type UnimplementedMetaStoreServer
- func (UnimplementedMetaStoreServer) GetBlockStoreAddrs(context.Context, *emptypb.Empty) (*BlockStoreAddrs, error)
- func (UnimplementedMetaStoreServer) GetBlockStoreMap(context.Context, *BlockHashes) (*BlockStoreMap, error)
- func (UnimplementedMetaStoreServer) GetFileInfoMap(context.Context, *emptypb.Empty) (*FileInfoMap, error)
- func (UnimplementedMetaStoreServer) UpdateFile(context.Context, *FileMetaData) (*Version, error)
- type UnimplementedRaftSurfstoreServer
- func (UnimplementedRaftSurfstoreServer) AppendEntries(context.Context, *AppendEntryInput) (*AppendEntryOutput, error)
- func (UnimplementedRaftSurfstoreServer) Crash(context.Context, *emptypb.Empty) (*Success, error)
- func (UnimplementedRaftSurfstoreServer) GetBlockStoreAddrs(context.Context, *emptypb.Empty) (*BlockStoreAddrs, error)
- func (UnimplementedRaftSurfstoreServer) GetBlockStoreMap(context.Context, *BlockHashes) (*BlockStoreMap, error)
- func (UnimplementedRaftSurfstoreServer) GetFileInfoMap(context.Context, *emptypb.Empty) (*FileInfoMap, error)
- func (UnimplementedRaftSurfstoreServer) GetInternalState(context.Context, *emptypb.Empty) (*RaftInternalState, error)
- func (UnimplementedRaftSurfstoreServer) Restore(context.Context, *emptypb.Empty) (*Success, error)
- func (UnimplementedRaftSurfstoreServer) SendHeartbeat(context.Context, *emptypb.Empty) (*Success, error)
- func (UnimplementedRaftSurfstoreServer) SetLeader(context.Context, *emptypb.Empty) (*Success, error)
- func (UnimplementedRaftSurfstoreServer) UpdateFile(context.Context, *FileMetaData) (*Version, error)
- type UnsafeBlockStoreServer
- type UnsafeMetaStoreServer
- type UnsafeRaftSurfstoreServer
- type UpdateOperation
- func (*UpdateOperation) Descriptor() ([]byte, []int)deprecated
- func (x *UpdateOperation) GetFileMetaData() *FileMetaData
- func (x *UpdateOperation) GetTerm() int64
- func (*UpdateOperation) ProtoMessage()
- func (x *UpdateOperation) ProtoReflect() protoreflect.Message
- func (x *UpdateOperation) Reset()
- func (x *UpdateOperation) String() string
- type Version
Constants ¶
const CONFIG_DELIMITER string = ","
const DEFAULT_META_FILENAME string = "index.db"
const EMPTYFILE_HASHVALUE string = "-1"
const FILENAME_INDEX int = 0
const HASH_DELIMITER string = " "
const HASH_LIST_INDEX int = 2
const TOMBSTONE_HASHVALUE string = "0"
const VERSION_INDEX int = 1
Variables ¶
var BlockStore_ServiceDesc = grpc.ServiceDesc{ ServiceName: "surfstore.BlockStore", HandlerType: (*BlockStoreServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetBlock", Handler: _BlockStore_GetBlock_Handler, }, { MethodName: "PutBlock", Handler: _BlockStore_PutBlock_Handler, }, { MethodName: "HasBlocks", Handler: _BlockStore_HasBlocks_Handler, }, { MethodName: "GetBlockHashes", Handler: _BlockStore_GetBlockHashes_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "pkg/surfstore/SurfStore.proto", }
BlockStore_ServiceDesc is the grpc.ServiceDesc for BlockStore service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var ERR_NOT_LEADER = fmt.Errorf("Server is not the leader")
var ERR_SERVER_CRASHED = fmt.Errorf("Server is crashed.")
var File_pkg_surfstore_SurfStore_proto protoreflect.FileDescriptor
var MetaStore_ServiceDesc = grpc.ServiceDesc{ ServiceName: "surfstore.MetaStore", HandlerType: (*MetaStoreServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetFileInfoMap", Handler: _MetaStore_GetFileInfoMap_Handler, }, { MethodName: "UpdateFile", Handler: _MetaStore_UpdateFile_Handler, }, { MethodName: "GetBlockStoreMap", Handler: _MetaStore_GetBlockStoreMap_Handler, }, { MethodName: "GetBlockStoreAddrs", Handler: _MetaStore_GetBlockStoreAddrs_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "pkg/surfstore/SurfStore.proto", }
MetaStore_ServiceDesc is the grpc.ServiceDesc for MetaStore service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var RaftSurfstore_ServiceDesc = grpc.ServiceDesc{ ServiceName: "surfstore.RaftSurfstore", HandlerType: (*RaftSurfstoreServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "AppendEntries", Handler: _RaftSurfstore_AppendEntries_Handler, }, { MethodName: "SetLeader", Handler: _RaftSurfstore_SetLeader_Handler, }, { MethodName: "SendHeartbeat", Handler: _RaftSurfstore_SendHeartbeat_Handler, }, { MethodName: "GetFileInfoMap", Handler: _RaftSurfstore_GetFileInfoMap_Handler, }, { MethodName: "UpdateFile", Handler: _RaftSurfstore_UpdateFile_Handler, }, { MethodName: "GetBlockStoreMap", Handler: _RaftSurfstore_GetBlockStoreMap_Handler, }, { MethodName: "GetBlockStoreAddrs", Handler: _RaftSurfstore_GetBlockStoreAddrs_Handler, }, { MethodName: "GetInternalState", Handler: _RaftSurfstore_GetInternalState_Handler, }, { MethodName: "Restore", Handler: _RaftSurfstore_Restore_Handler, }, { MethodName: "Crash", Handler: _RaftSurfstore_Crash_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "pkg/surfstore/SurfStore.proto", }
RaftSurfstore_ServiceDesc is the grpc.ServiceDesc for RaftSurfstore service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func ClientSync ¶
func ClientSync(client RPCClient)
Implement the logic for a client syncing with the server here.
func GetBlockHashString ¶
func LoadMetaFromMetaFile ¶
func LoadMetaFromMetaFile(baseDir string) (fileMetaMap map[string]*FileMetaData, e error)
order by hashIndex; LoadMetaFromMetaFile loads the local metadata file into a file meta map. The key is the file's name and the value is the file's metadata. You can use this function to load the index.db file in this project.
func PrintMetaMap ¶
func PrintMetaMap(metaMap map[string]*FileMetaData)
PrintMetaMap prints the contents of the metadata map. You might find this function useful for debugging.
func RegisterBlockStoreServer ¶
func RegisterBlockStoreServer(s grpc.ServiceRegistrar, srv BlockStoreServer)
func RegisterMetaStoreServer ¶
func RegisterMetaStoreServer(s grpc.ServiceRegistrar, srv MetaStoreServer)
func RegisterRaftSurfstoreServer ¶
func RegisterRaftSurfstoreServer(s grpc.ServiceRegistrar, srv RaftSurfstoreServer)
func ServeRaftServer ¶
func ServeRaftServer(server *RaftSurfstore) error
TODO Start up the Raft server and any services here
func WriteMetaFile ¶
func WriteMetaFile(fileMetas map[string]*FileMetaData, baseDir string) error
WriteMetaFile writes the file meta map back to local metadata file index.db
Types ¶
type AppendEntryInput ¶
type AppendEntryInput struct { Term int64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"` PrevLogIndex int64 `protobuf:"varint,2,opt,name=prevLogIndex,proto3" json:"prevLogIndex,omitempty"` PrevLogTerm int64 `protobuf:"varint,3,opt,name=prevLogTerm,proto3" json:"prevLogTerm,omitempty"` Entries []*UpdateOperation `protobuf:"bytes,4,rep,name=entries,proto3" json:"entries,omitempty"` LeaderCommit int64 `protobuf:"varint,5,opt,name=leaderCommit,proto3" json:"leaderCommit,omitempty"` // contains filtered or unexported fields }
func (*AppendEntryInput) Descriptor
deprecated
func (*AppendEntryInput) Descriptor() ([]byte, []int)
Deprecated: Use AppendEntryInput.ProtoReflect.Descriptor instead.
func (*AppendEntryInput) GetEntries ¶
func (x *AppendEntryInput) GetEntries() []*UpdateOperation
func (*AppendEntryInput) GetLeaderCommit ¶
func (x *AppendEntryInput) GetLeaderCommit() int64
func (*AppendEntryInput) GetPrevLogIndex ¶
func (x *AppendEntryInput) GetPrevLogIndex() int64
func (*AppendEntryInput) GetPrevLogTerm ¶
func (x *AppendEntryInput) GetPrevLogTerm() int64
func (*AppendEntryInput) GetTerm ¶
func (x *AppendEntryInput) GetTerm() int64
func (*AppendEntryInput) ProtoMessage ¶
func (*AppendEntryInput) ProtoMessage()
func (*AppendEntryInput) ProtoReflect ¶
func (x *AppendEntryInput) ProtoReflect() protoreflect.Message
func (*AppendEntryInput) Reset ¶
func (x *AppendEntryInput) Reset()
func (*AppendEntryInput) String ¶
func (x *AppendEntryInput) String() string
type AppendEntryOutput ¶
type AppendEntryOutput struct { ServerId int64 `protobuf:"varint,1,opt,name=serverId,proto3" json:"serverId,omitempty"` Term int64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"` Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"` MatchedIndex int64 `protobuf:"varint,4,opt,name=matchedIndex,proto3" json:"matchedIndex,omitempty"` // contains filtered or unexported fields }
func (*AppendEntryOutput) Descriptor
deprecated
func (*AppendEntryOutput) Descriptor() ([]byte, []int)
Deprecated: Use AppendEntryOutput.ProtoReflect.Descriptor instead.
func (*AppendEntryOutput) GetMatchedIndex ¶
func (x *AppendEntryOutput) GetMatchedIndex() int64
func (*AppendEntryOutput) GetServerId ¶
func (x *AppendEntryOutput) GetServerId() int64
func (*AppendEntryOutput) GetSuccess ¶
func (x *AppendEntryOutput) GetSuccess() bool
func (*AppendEntryOutput) GetTerm ¶
func (x *AppendEntryOutput) GetTerm() int64
func (*AppendEntryOutput) ProtoMessage ¶
func (*AppendEntryOutput) ProtoMessage()
func (*AppendEntryOutput) ProtoReflect ¶
func (x *AppendEntryOutput) ProtoReflect() protoreflect.Message
func (*AppendEntryOutput) Reset ¶
func (x *AppendEntryOutput) Reset()
func (*AppendEntryOutput) String ¶
func (x *AppendEntryOutput) String() string
type Block ¶
type Block struct { BlockData []byte `protobuf:"bytes,1,opt,name=blockData,proto3" json:"blockData,omitempty"` BlockSize int32 `protobuf:"varint,2,opt,name=blockSize,proto3" json:"blockSize,omitempty"` // contains filtered or unexported fields }
func (*Block) Descriptor
deprecated
func (*Block) GetBlockData ¶
func (*Block) GetBlockSize ¶
func (*Block) ProtoMessage ¶
func (*Block) ProtoMessage()
func (*Block) ProtoReflect ¶
func (x *Block) ProtoReflect() protoreflect.Message
type BlockHash ¶
type BlockHash struct { Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // contains filtered or unexported fields }
func (*BlockHash) Descriptor
deprecated
func (*BlockHash) ProtoMessage ¶
func (*BlockHash) ProtoMessage()
func (*BlockHash) ProtoReflect ¶
func (x *BlockHash) ProtoReflect() protoreflect.Message
type BlockHashes ¶
type BlockHashes struct { Hashes []string `protobuf:"bytes,1,rep,name=hashes,proto3" json:"hashes,omitempty"` // contains filtered or unexported fields }
func (*BlockHashes) Descriptor
deprecated
func (*BlockHashes) Descriptor() ([]byte, []int)
Deprecated: Use BlockHashes.ProtoReflect.Descriptor instead.
func (*BlockHashes) GetHashes ¶
func (x *BlockHashes) GetHashes() []string
func (*BlockHashes) ProtoMessage ¶
func (*BlockHashes) ProtoMessage()
func (*BlockHashes) ProtoReflect ¶
func (x *BlockHashes) ProtoReflect() protoreflect.Message
func (*BlockHashes) Reset ¶
func (x *BlockHashes) Reset()
func (*BlockHashes) String ¶
func (x *BlockHashes) String() string
type BlockStore ¶
type BlockStore struct { BlockMap map[string]*Block UnimplementedBlockStoreServer }
func NewBlockStore ¶
func NewBlockStore() *BlockStore
func (*BlockStore) GetBlockHashes ¶
func (bs *BlockStore) GetBlockHashes(ctx context.Context, _ *emptypb.Empty) (*BlockHashes, error)
Return a list containing all blockHashes on this block server
func (*BlockStore) HasBlocks ¶
func (bs *BlockStore) HasBlocks(ctx context.Context, blockHashesIn *BlockHashes) (*BlockHashes, error)
Given a list of hashes “in”, returns a list containing the subset of in that are stored in the key-value store
type BlockStoreAddrs ¶
type BlockStoreAddrs struct { BlockStoreAddrs []string `protobuf:"bytes,1,rep,name=blockStoreAddrs,proto3" json:"blockStoreAddrs,omitempty"` // contains filtered or unexported fields }
func (*BlockStoreAddrs) Descriptor
deprecated
func (*BlockStoreAddrs) Descriptor() ([]byte, []int)
Deprecated: Use BlockStoreAddrs.ProtoReflect.Descriptor instead.
func (*BlockStoreAddrs) GetBlockStoreAddrs ¶
func (x *BlockStoreAddrs) GetBlockStoreAddrs() []string
func (*BlockStoreAddrs) ProtoMessage ¶
func (*BlockStoreAddrs) ProtoMessage()
func (*BlockStoreAddrs) ProtoReflect ¶
func (x *BlockStoreAddrs) ProtoReflect() protoreflect.Message
func (*BlockStoreAddrs) Reset ¶
func (x *BlockStoreAddrs) Reset()
func (*BlockStoreAddrs) String ¶
func (x *BlockStoreAddrs) String() string
type BlockStoreClient ¶
type BlockStoreClient interface { GetBlock(ctx context.Context, in *BlockHash, opts ...grpc.CallOption) (*Block, error) PutBlock(ctx context.Context, in *Block, opts ...grpc.CallOption) (*Success, error) HasBlocks(ctx context.Context, in *BlockHashes, opts ...grpc.CallOption) (*BlockHashes, error) GetBlockHashes(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*BlockHashes, error) }
BlockStoreClient is the client API for BlockStore service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewBlockStoreClient ¶
func NewBlockStoreClient(cc grpc.ClientConnInterface) BlockStoreClient
type BlockStoreInterface ¶
type BlockStoreInterface interface { // Get a block based on GetBlock(ctx context.Context, blockHash *BlockHash) (*Block, error) // Put a block PutBlock(ctx context.Context, block *Block) (*Success, error) // Given a list of hashes “in”, returns a list containing the // subset of in that are stored in the key-value store HasBlocks(ctx context.Context, blockHashesIn *BlockHashes) (*BlockHashes, error) // Get which blocks are on this BlockStore server GetBlockHashes(ctx context.Context, _ *emptypb.Empty) (*BlockHashes, error) }
type BlockStoreMap ¶
type BlockStoreMap struct { BlockStoreMap map[string]*BlockHashes `` /* 167-byte string literal not displayed */ // contains filtered or unexported fields }
func (*BlockStoreMap) Descriptor
deprecated
func (*BlockStoreMap) Descriptor() ([]byte, []int)
Deprecated: Use BlockStoreMap.ProtoReflect.Descriptor instead.
func (*BlockStoreMap) GetBlockStoreMap ¶
func (x *BlockStoreMap) GetBlockStoreMap() map[string]*BlockHashes
func (*BlockStoreMap) ProtoMessage ¶
func (*BlockStoreMap) ProtoMessage()
func (*BlockStoreMap) ProtoReflect ¶
func (x *BlockStoreMap) ProtoReflect() protoreflect.Message
func (*BlockStoreMap) Reset ¶
func (x *BlockStoreMap) Reset()
func (*BlockStoreMap) String ¶
func (x *BlockStoreMap) String() string
type BlockStoreServer ¶
type BlockStoreServer interface { GetBlock(context.Context, *BlockHash) (*Block, error) PutBlock(context.Context, *Block) (*Success, error) HasBlocks(context.Context, *BlockHashes) (*BlockHashes, error) GetBlockHashes(context.Context, *emptypb.Empty) (*BlockHashes, error) // contains filtered or unexported methods }
BlockStoreServer is the server API for BlockStore service. All implementations must embed UnimplementedBlockStoreServer for forward compatibility
type ClientInterface ¶
type ClientInterface interface { // MetaStore GetFileInfoMap(serverFileInfoMap *map[string]*FileMetaData) error UpdateFile(fileMetaData *FileMetaData, latestVersion *int32) error GetBlockStoreMap(blockHashesIn []string, blockStoreMap *map[string][]string) error GetBlockStoreAddrs(blockStoreAddrs *[]string) error // BlockStore GetBlock(blockHash string, blockStoreAddr string, block *Block) error PutBlock(block *Block, blockStoreAddr string, succ *bool) error HasBlocks(blockHashesIn []string, blockStoreAddr string, blockHashesOut *[]string) error GetBlockHashes(blockStoreAddr string, blockHashes *[]string) error }
type ConsistentHashRing ¶
func NewConsistentHashRing ¶
func NewConsistentHashRing(serverAddrs []string) *ConsistentHashRing
func (ConsistentHashRing) GetResponsibleServer ¶
func (c ConsistentHashRing) GetResponsibleServer(blockId string) string
func (ConsistentHashRing) Hash ¶
func (c ConsistentHashRing) Hash(addr string) string
type CrashedState ¶
type CrashedState struct { IsCrashed bool `protobuf:"varint,1,opt,name=isCrashed,proto3" json:"isCrashed,omitempty"` // contains filtered or unexported fields }
func (*CrashedState) Descriptor
deprecated
func (*CrashedState) Descriptor() ([]byte, []int)
Deprecated: Use CrashedState.ProtoReflect.Descriptor instead.
func (*CrashedState) GetIsCrashed ¶
func (x *CrashedState) GetIsCrashed() bool
func (*CrashedState) ProtoMessage ¶
func (*CrashedState) ProtoMessage()
func (*CrashedState) ProtoReflect ¶
func (x *CrashedState) ProtoReflect() protoreflect.Message
func (*CrashedState) Reset ¶
func (x *CrashedState) Reset()
func (*CrashedState) String ¶
func (x *CrashedState) String() string
type FileInfoMap ¶
type FileInfoMap struct { FileInfoMap map[string]*FileMetaData `` /* 163-byte string literal not displayed */ // contains filtered or unexported fields }
func (*FileInfoMap) Descriptor
deprecated
func (*FileInfoMap) Descriptor() ([]byte, []int)
Deprecated: Use FileInfoMap.ProtoReflect.Descriptor instead.
func (*FileInfoMap) GetFileInfoMap ¶
func (x *FileInfoMap) GetFileInfoMap() map[string]*FileMetaData
func (*FileInfoMap) ProtoMessage ¶
func (*FileInfoMap) ProtoMessage()
func (*FileInfoMap) ProtoReflect ¶
func (x *FileInfoMap) ProtoReflect() protoreflect.Message
func (*FileInfoMap) Reset ¶
func (x *FileInfoMap) Reset()
func (*FileInfoMap) String ¶
func (x *FileInfoMap) String() string
type FileMetaData ¶
type FileMetaData struct { Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` Version int32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` BlockHashList []string `protobuf:"bytes,3,rep,name=blockHashList,proto3" json:"blockHashList,omitempty"` // contains filtered or unexported fields }
func (*FileMetaData) Descriptor
deprecated
func (*FileMetaData) Descriptor() ([]byte, []int)
Deprecated: Use FileMetaData.ProtoReflect.Descriptor instead.
func (*FileMetaData) GetBlockHashList ¶
func (x *FileMetaData) GetBlockHashList() []string
func (*FileMetaData) GetFilename ¶
func (x *FileMetaData) GetFilename() string
func (*FileMetaData) GetVersion ¶
func (x *FileMetaData) GetVersion() int32
func (*FileMetaData) ProtoMessage ¶
func (*FileMetaData) ProtoMessage()
func (*FileMetaData) ProtoReflect ¶
func (x *FileMetaData) ProtoReflect() protoreflect.Message
func (*FileMetaData) Reset ¶
func (x *FileMetaData) Reset()
func (*FileMetaData) String ¶
func (x *FileMetaData) String() string
type MetaStore ¶
type MetaStore struct { FileMetaMap map[string]*FileMetaData BlockStoreAddrs []string ConsistentHashRing *ConsistentHashRing UnimplementedMetaStoreServer }
func NewMetaStore ¶
func (*MetaStore) GetBlockStoreAddrs ¶
func (*MetaStore) GetBlockStoreMap ¶
func (m *MetaStore) GetBlockStoreMap(ctx context.Context, blockHashesIn *BlockHashes) (*BlockStoreMap, error)
func (*MetaStore) GetFileInfoMap ¶
func (*MetaStore) UpdateFile ¶
type MetaStoreClient ¶
type MetaStoreClient interface { GetFileInfoMap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*FileInfoMap, error) UpdateFile(ctx context.Context, in *FileMetaData, opts ...grpc.CallOption) (*Version, error) GetBlockStoreMap(ctx context.Context, in *BlockHashes, opts ...grpc.CallOption) (*BlockStoreMap, error) GetBlockStoreAddrs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*BlockStoreAddrs, error) }
MetaStoreClient is the client API for MetaStore service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewMetaStoreClient ¶
func NewMetaStoreClient(cc grpc.ClientConnInterface) MetaStoreClient
type MetaStoreInterface ¶
type MetaStoreInterface interface { // Retrieves the server's FileInfoMap GetFileInfoMap(ctx context.Context, _ *emptypb.Empty) (*FileInfoMap, error) // Update a file's fileinfo entry UpdateFile(ctx context.Context, fileMetaData *FileMetaData) (*Version, error) // Retrieve the mapping of BlockStore addresses to block hashes GetBlockStoreMap(ctx context.Context, blockHashesIn *BlockHashes) (*BlockStoreMap, error) // Retrieve all BlockStore Addresses GetBlockStoreAddrs(ctx context.Context, _ *emptypb.Empty) (*BlockStoreAddrs, error) }
type MetaStoreServer ¶
type MetaStoreServer interface { GetFileInfoMap(context.Context, *emptypb.Empty) (*FileInfoMap, error) UpdateFile(context.Context, *FileMetaData) (*Version, error) GetBlockStoreMap(context.Context, *BlockHashes) (*BlockStoreMap, error) GetBlockStoreAddrs(context.Context, *emptypb.Empty) (*BlockStoreAddrs, error) // contains filtered or unexported methods }
MetaStoreServer is the server API for MetaStore service. All implementations must embed UnimplementedMetaStoreServer for forward compatibility
type RPCClient ¶
func NewSurfstoreRPCClient ¶
Create an Surfstore RPC client
func (*RPCClient) GetBlockHashes ¶
func (*RPCClient) GetBlockStoreAddrs ¶
func (*RPCClient) GetBlockStoreMap ¶
func (*RPCClient) GetFileInfoMap ¶
func (surfClient *RPCClient) GetFileInfoMap(serverFileInfoMap *map[string]*FileMetaData) error
func (*RPCClient) UpdateFile ¶
func (surfClient *RPCClient) UpdateFile(fileMetaData *FileMetaData, latestVersion *int32) error
type RaftConfig ¶
func LoadRaftConfigFile ¶
func LoadRaftConfigFile(filename string) (cfg RaftConfig)
type RaftInterface ¶
type RaftInternalState ¶
type RaftInternalState struct { IsLeader bool `protobuf:"varint,1,opt,name=isLeader,proto3" json:"isLeader,omitempty"` Term int64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"` Log []*UpdateOperation `protobuf:"bytes,3,rep,name=log,proto3" json:"log,omitempty"` MetaMap *FileInfoMap `protobuf:"bytes,4,opt,name=metaMap,proto3" json:"metaMap,omitempty"` // contains filtered or unexported fields }
func (*RaftInternalState) Descriptor
deprecated
func (*RaftInternalState) Descriptor() ([]byte, []int)
Deprecated: Use RaftInternalState.ProtoReflect.Descriptor instead.
func (*RaftInternalState) GetIsLeader ¶
func (x *RaftInternalState) GetIsLeader() bool
func (*RaftInternalState) GetLog ¶
func (x *RaftInternalState) GetLog() []*UpdateOperation
func (*RaftInternalState) GetMetaMap ¶
func (x *RaftInternalState) GetMetaMap() *FileInfoMap
func (*RaftInternalState) GetTerm ¶
func (x *RaftInternalState) GetTerm() int64
func (*RaftInternalState) ProtoMessage ¶
func (*RaftInternalState) ProtoMessage()
func (*RaftInternalState) ProtoReflect ¶
func (x *RaftInternalState) ProtoReflect() protoreflect.Message
func (*RaftInternalState) Reset ¶
func (x *RaftInternalState) Reset()
func (*RaftInternalState) String ¶
func (x *RaftInternalState) String() string
type RaftSurfstore ¶
type RaftSurfstore struct { //nextIndex int64 //matchIndex int64 Ip_list []string ServerId int64 UnimplementedRaftSurfstoreServer // contains filtered or unexported fields }
TODO Add fields you need here
func NewRaftServer ¶
func NewRaftServer(id int64, config RaftConfig) (*RaftSurfstore, error)
func (*RaftSurfstore) AppendEntries ¶
func (s *RaftSurfstore) AppendEntries(ctx context.Context, input *AppendEntryInput) (*AppendEntryOutput, error)
1. Reply false if term < currentTerm (§5.1) 2. Reply false if log doesn’t contain an entry at prevLogIndex whose term matches prevLogTerm (§5.3) 3. If an existing entry conflicts with a new one (same index but different terms), delete the existing entry and all that follow it (§5.3) 4. Append any new entries not already in the log 5. If leaderCommit > commitIndex, set commitIndex = min(leaderCommit, index of last new entry)
func (*RaftSurfstore) GetBlockStoreAddrs ¶
func (s *RaftSurfstore) GetBlockStoreAddrs(ctx context.Context, empty *emptypb.Empty) (*BlockStoreAddrs, error)
func (*RaftSurfstore) GetBlockStoreMap ¶
func (s *RaftSurfstore) GetBlockStoreMap(ctx context.Context, hashes *BlockHashes) (*BlockStoreMap, error)
func (*RaftSurfstore) GetFileInfoMap ¶
func (s *RaftSurfstore) GetFileInfoMap(ctx context.Context, empty *emptypb.Empty) (*FileInfoMap, error)
func (*RaftSurfstore) GetInternalState ¶
func (s *RaftSurfstore) GetInternalState(ctx context.Context, empty *emptypb.Empty) (*RaftInternalState, error)
func (*RaftSurfstore) SendHeartbeat ¶
func (*RaftSurfstore) UpdateFile ¶
func (s *RaftSurfstore) UpdateFile(ctx context.Context, filemeta *FileMetaData) (*Version, error)
type RaftSurfstoreClient ¶
type RaftSurfstoreClient interface { // raft AppendEntries(ctx context.Context, in *AppendEntryInput, opts ...grpc.CallOption) (*AppendEntryOutput, error) SetLeader(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Success, error) SendHeartbeat(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Success, error) // metastore GetFileInfoMap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*FileInfoMap, error) UpdateFile(ctx context.Context, in *FileMetaData, opts ...grpc.CallOption) (*Version, error) GetBlockStoreMap(ctx context.Context, in *BlockHashes, opts ...grpc.CallOption) (*BlockStoreMap, error) GetBlockStoreAddrs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*BlockStoreAddrs, error) // testing interface GetInternalState(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*RaftInternalState, error) Restore(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Success, error) Crash(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Success, error) }
RaftSurfstoreClient is the client API for RaftSurfstore service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewRaftSurfstoreClient ¶
func NewRaftSurfstoreClient(cc grpc.ClientConnInterface) RaftSurfstoreClient
type RaftSurfstoreInterface ¶
type RaftSurfstoreInterface interface { MetaStoreInterface RaftInterface RaftTestingInterface }
type RaftSurfstoreServer ¶
type RaftSurfstoreServer interface { // raft AppendEntries(context.Context, *AppendEntryInput) (*AppendEntryOutput, error) SetLeader(context.Context, *emptypb.Empty) (*Success, error) SendHeartbeat(context.Context, *emptypb.Empty) (*Success, error) // metastore GetFileInfoMap(context.Context, *emptypb.Empty) (*FileInfoMap, error) UpdateFile(context.Context, *FileMetaData) (*Version, error) GetBlockStoreMap(context.Context, *BlockHashes) (*BlockStoreMap, error) GetBlockStoreAddrs(context.Context, *emptypb.Empty) (*BlockStoreAddrs, error) // testing interface GetInternalState(context.Context, *emptypb.Empty) (*RaftInternalState, error) Restore(context.Context, *emptypb.Empty) (*Success, error) Crash(context.Context, *emptypb.Empty) (*Success, error) // contains filtered or unexported methods }
RaftSurfstoreServer is the server API for RaftSurfstore service. All implementations must embed UnimplementedRaftSurfstoreServer for forward compatibility
type RaftTestingInterface ¶
type Success ¶
type Success struct { Flag bool `protobuf:"varint,1,opt,name=flag,proto3" json:"flag,omitempty"` // contains filtered or unexported fields }
func (*Success) Descriptor
deprecated
func (*Success) ProtoMessage ¶
func (*Success) ProtoMessage()
func (*Success) ProtoReflect ¶
func (x *Success) ProtoReflect() protoreflect.Message
type UnimplementedBlockStoreServer ¶
type UnimplementedBlockStoreServer struct { }
UnimplementedBlockStoreServer must be embedded to have forward compatible implementations.
func (UnimplementedBlockStoreServer) GetBlockHashes ¶
func (UnimplementedBlockStoreServer) GetBlockHashes(context.Context, *emptypb.Empty) (*BlockHashes, error)
func (UnimplementedBlockStoreServer) HasBlocks ¶
func (UnimplementedBlockStoreServer) HasBlocks(context.Context, *BlockHashes) (*BlockHashes, error)
type UnimplementedMetaStoreServer ¶
type UnimplementedMetaStoreServer struct { }
UnimplementedMetaStoreServer must be embedded to have forward compatible implementations.
func (UnimplementedMetaStoreServer) GetBlockStoreAddrs ¶
func (UnimplementedMetaStoreServer) GetBlockStoreAddrs(context.Context, *emptypb.Empty) (*BlockStoreAddrs, error)
func (UnimplementedMetaStoreServer) GetBlockStoreMap ¶
func (UnimplementedMetaStoreServer) GetBlockStoreMap(context.Context, *BlockHashes) (*BlockStoreMap, error)
func (UnimplementedMetaStoreServer) GetFileInfoMap ¶
func (UnimplementedMetaStoreServer) GetFileInfoMap(context.Context, *emptypb.Empty) (*FileInfoMap, error)
func (UnimplementedMetaStoreServer) UpdateFile ¶
func (UnimplementedMetaStoreServer) UpdateFile(context.Context, *FileMetaData) (*Version, error)
type UnimplementedRaftSurfstoreServer ¶
type UnimplementedRaftSurfstoreServer struct { }
UnimplementedRaftSurfstoreServer must be embedded to have forward compatible implementations.
func (UnimplementedRaftSurfstoreServer) AppendEntries ¶
func (UnimplementedRaftSurfstoreServer) AppendEntries(context.Context, *AppendEntryInput) (*AppendEntryOutput, error)
func (UnimplementedRaftSurfstoreServer) GetBlockStoreAddrs ¶
func (UnimplementedRaftSurfstoreServer) GetBlockStoreAddrs(context.Context, *emptypb.Empty) (*BlockStoreAddrs, error)
func (UnimplementedRaftSurfstoreServer) GetBlockStoreMap ¶
func (UnimplementedRaftSurfstoreServer) GetBlockStoreMap(context.Context, *BlockHashes) (*BlockStoreMap, error)
func (UnimplementedRaftSurfstoreServer) GetFileInfoMap ¶
func (UnimplementedRaftSurfstoreServer) GetFileInfoMap(context.Context, *emptypb.Empty) (*FileInfoMap, error)
func (UnimplementedRaftSurfstoreServer) GetInternalState ¶
func (UnimplementedRaftSurfstoreServer) GetInternalState(context.Context, *emptypb.Empty) (*RaftInternalState, error)
func (UnimplementedRaftSurfstoreServer) SendHeartbeat ¶
func (UnimplementedRaftSurfstoreServer) UpdateFile ¶
func (UnimplementedRaftSurfstoreServer) UpdateFile(context.Context, *FileMetaData) (*Version, error)
type UnsafeBlockStoreServer ¶
type UnsafeBlockStoreServer interface {
// contains filtered or unexported methods
}
UnsafeBlockStoreServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to BlockStoreServer will result in compilation errors.
type UnsafeMetaStoreServer ¶
type UnsafeMetaStoreServer interface {
// contains filtered or unexported methods
}
UnsafeMetaStoreServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MetaStoreServer will result in compilation errors.
type UnsafeRaftSurfstoreServer ¶
type UnsafeRaftSurfstoreServer interface {
// contains filtered or unexported methods
}
UnsafeRaftSurfstoreServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RaftSurfstoreServer will result in compilation errors.
type UpdateOperation ¶
type UpdateOperation struct { Term int64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"` FileMetaData *FileMetaData `protobuf:"bytes,3,opt,name=fileMetaData,proto3" json:"fileMetaData,omitempty"` // contains filtered or unexported fields }
func (*UpdateOperation) Descriptor
deprecated
func (*UpdateOperation) Descriptor() ([]byte, []int)
Deprecated: Use UpdateOperation.ProtoReflect.Descriptor instead.
func (*UpdateOperation) GetFileMetaData ¶
func (x *UpdateOperation) GetFileMetaData() *FileMetaData
func (*UpdateOperation) GetTerm ¶
func (x *UpdateOperation) GetTerm() int64
func (*UpdateOperation) ProtoMessage ¶
func (*UpdateOperation) ProtoMessage()
func (*UpdateOperation) ProtoReflect ¶
func (x *UpdateOperation) ProtoReflect() protoreflect.Message
func (*UpdateOperation) Reset ¶
func (x *UpdateOperation) Reset()
func (*UpdateOperation) String ¶
func (x *UpdateOperation) String() string
type Version ¶
type Version struct { Version int32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` // contains filtered or unexported fields }
func (*Version) Descriptor
deprecated
func (*Version) GetVersion ¶
func (*Version) ProtoMessage ¶
func (*Version) ProtoMessage()
func (*Version) ProtoReflect ¶
func (x *Version) ProtoReflect() protoreflect.Message
Source Files ¶
- BlockStore.go
- ConsistentHashRing.go
- MetaStore.go
- RPCClient.go
- RaftConstants.go
- RaftInterfaces.go
- RaftServer.go
- RaftSurfstoreServer.go
- RaftUtils.go
- StoreUtils.go
- SurfStore.pb.go
- SurfStoreConstants.go
- SurfStore_grpc.pb.go
- SurfstoreHelper.go
- SurfstoreInterfaces.go
- SurfstoreRPCClient.go
- SurfstoreUtils.go