surfstore

package
v0.0.0-...-3cb4c05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const CONFIG_DELIMITER string = ","
View Source
const DEFAULT_META_FILENAME string = "index.db"
View Source
const EMPTYFILE_HASHVALUE string = "-1"
View Source
const FILENAME_INDEX int = 0
View Source
const HASH_DELIMITER string = " "
View Source
const HASH_LIST_INDEX int = 2
View Source
const TOMBSTONE_HASHVALUE string = "0"
View Source
const VERSION_INDEX int = 1

Variables

View Source
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)

View Source
var ERR_NOT_LEADER = fmt.Errorf("Server is not the leader")
View Source
var ERR_SERVER_CRASHED = fmt.Errorf("Server is crashed.")
View Source
var File_pkg_surfstore_SurfStore_proto protoreflect.FileDescriptor
View Source
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)

View Source
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 ConcatPath

func ConcatPath(baseDir, fileDir string) string

File Path Related

func GetBlockHashBytes

func GetBlockHashBytes(blockData []byte) []byte

Hash Related

func GetBlockHashString

func GetBlockHashString(blockData []byte) string

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) Descriptor() ([]byte, []int)

Deprecated: Use Block.ProtoReflect.Descriptor instead.

func (*Block) GetBlockData

func (x *Block) GetBlockData() []byte

func (*Block) GetBlockSize

func (x *Block) GetBlockSize() int32

func (*Block) ProtoMessage

func (*Block) ProtoMessage()

func (*Block) ProtoReflect

func (x *Block) ProtoReflect() protoreflect.Message

func (*Block) Reset

func (x *Block) Reset()

func (*Block) String

func (x *Block) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use BlockHash.ProtoReflect.Descriptor instead.

func (*BlockHash) GetHash

func (x *BlockHash) GetHash() string

func (*BlockHash) ProtoMessage

func (*BlockHash) ProtoMessage()

func (*BlockHash) ProtoReflect

func (x *BlockHash) ProtoReflect() protoreflect.Message

func (*BlockHash) Reset

func (x *BlockHash) Reset()

func (*BlockHash) String

func (x *BlockHash) String() string

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) GetBlock

func (bs *BlockStore) GetBlock(ctx context.Context, blockHash *BlockHash) (*Block, error)

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

func (*BlockStore) PutBlock

func (bs *BlockStore) PutBlock(ctx context.Context, block *Block) (*Success, error)

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

type ConsistentHashRing struct {
	ServerMap map[string]string
}

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 NewMetaStore(blockStoreAddrs []string) *MetaStore

func (*MetaStore) GetBlockStoreAddrs

func (m *MetaStore) GetBlockStoreAddrs(ctx context.Context, _ *emptypb.Empty) (*BlockStoreAddrs, error)

func (*MetaStore) GetBlockStoreMap

func (m *MetaStore) GetBlockStoreMap(ctx context.Context, blockHashesIn *BlockHashes) (*BlockStoreMap, error)

func (*MetaStore) GetFileInfoMap

func (m *MetaStore) GetFileInfoMap(ctx context.Context, _ *emptypb.Empty) (*FileInfoMap, error)

func (*MetaStore) UpdateFile

func (m *MetaStore) UpdateFile(ctx context.Context, fileMetaData *FileMetaData) (*Version, error)

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

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

func NewSurfstoreRPCClient

func NewSurfstoreRPCClient(addrs []string, baseDir string, blockSize int) RPCClient

Create an Surfstore RPC client

func (*RPCClient) GetBlock

func (surfClient *RPCClient) GetBlock(blockHash string, blockStoreAddr string, block *Block) error

func (*RPCClient) GetBlockHashes

func (surfClient *RPCClient) GetBlockHashes(blockStoreAddr string, blockHashes *[]string) error

func (*RPCClient) GetBlockStoreAddrs

func (surfClient *RPCClient) GetBlockStoreAddrs(blockStoreAddrs *[]string) error

func (*RPCClient) GetBlockStoreMap

func (surfClient *RPCClient) GetBlockStoreMap(blockHashesIn []string, blockStoreMap *map[string][]string) error

func (*RPCClient) GetFileInfoMap

func (surfClient *RPCClient) GetFileInfoMap(serverFileInfoMap *map[string]*FileMetaData) error

func (*RPCClient) HasBlocks

func (surfClient *RPCClient) HasBlocks(blockHashesIn []string, blockStoreAddr string, blockHashesOut *[]string) error

func (*RPCClient) PutBlock

func (surfClient *RPCClient) PutBlock(block *Block, blockStoreAddr string, succ *bool) error

func (*RPCClient) UpdateFile

func (surfClient *RPCClient) UpdateFile(fileMetaData *FileMetaData, latestVersion *int32) error

type RaftConfig

type RaftConfig struct {
	RaftAddrs  []string
	BlockAddrs []string
}

func LoadRaftConfigFile

func LoadRaftConfigFile(filename string) (cfg RaftConfig)

type RaftInterface

type RaftInterface interface {
	AppendEntries(ctx context.Context, input *AppendEntryInput) (*AppendEntryOutput, error)
	SetLeader(ctx context.Context, _ *emptypb.Empty) (*Success, error)
	SendHeartbeat(ctx context.Context, _ *emptypb.Empty) (*Success, error)
}

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) Crash

func (s *RaftSurfstore) Crash(ctx context.Context, _ *emptypb.Empty) (*Success, error)

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) Restore

func (s *RaftSurfstore) Restore(ctx context.Context, _ *emptypb.Empty) (*Success, error)

func (*RaftSurfstore) SendHeartbeat

func (s *RaftSurfstore) SendHeartbeat(ctx context.Context, _ *emptypb.Empty) (*Success, error)

func (*RaftSurfstore) SetLeader

func (s *RaftSurfstore) SetLeader(ctx context.Context, _ *emptypb.Empty) (*Success, error)

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.

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 RaftTestingInterface interface {
	GetInternalState(ctx context.Context, _ *emptypb.Empty) (*RaftInternalState, error)
	Crash(ctx context.Context, _ *emptypb.Empty) (*Success, error)
	Restore(ctx context.Context, _ *emptypb.Empty) (*Success, error)
}

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) Descriptor() ([]byte, []int)

Deprecated: Use Success.ProtoReflect.Descriptor instead.

func (*Success) GetFlag

func (x *Success) GetFlag() bool

func (*Success) ProtoMessage

func (*Success) ProtoMessage()

func (*Success) ProtoReflect

func (x *Success) ProtoReflect() protoreflect.Message

func (*Success) Reset

func (x *Success) Reset()

func (*Success) String

func (x *Success) String() string

type UnimplementedBlockStoreServer

type UnimplementedBlockStoreServer struct {
}

UnimplementedBlockStoreServer must be embedded to have forward compatible implementations.

func (UnimplementedBlockStoreServer) GetBlock

func (UnimplementedBlockStoreServer) GetBlockHashes

func (UnimplementedBlockStoreServer) HasBlocks

func (UnimplementedBlockStoreServer) PutBlock

type UnimplementedMetaStoreServer

type UnimplementedMetaStoreServer struct {
}

UnimplementedMetaStoreServer must be embedded to have forward compatible implementations.

func (UnimplementedMetaStoreServer) GetBlockStoreAddrs

func (UnimplementedMetaStoreServer) GetBlockStoreMap

func (UnimplementedMetaStoreServer) GetFileInfoMap

func (UnimplementedMetaStoreServer) UpdateFile

type UnimplementedRaftSurfstoreServer

type UnimplementedRaftSurfstoreServer struct {
}

UnimplementedRaftSurfstoreServer must be embedded to have forward compatible implementations.

func (UnimplementedRaftSurfstoreServer) AppendEntries

func (UnimplementedRaftSurfstoreServer) Crash

func (UnimplementedRaftSurfstoreServer) GetBlockStoreAddrs

func (UnimplementedRaftSurfstoreServer) GetBlockStoreMap

func (UnimplementedRaftSurfstoreServer) GetFileInfoMap

func (UnimplementedRaftSurfstoreServer) GetInternalState

func (UnimplementedRaftSurfstoreServer) Restore

func (UnimplementedRaftSurfstoreServer) SendHeartbeat

func (UnimplementedRaftSurfstoreServer) SetLeader

func (UnimplementedRaftSurfstoreServer) UpdateFile

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) Descriptor() ([]byte, []int)

Deprecated: Use Version.ProtoReflect.Descriptor instead.

func (*Version) GetVersion

func (x *Version) GetVersion() int32

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) ProtoReflect

func (x *Version) ProtoReflect() protoreflect.Message

func (*Version) Reset

func (x *Version) Reset()

func (*Version) String

func (x *Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL