Documentation ¶
Index ¶
- Constants
- func DeleteChunkHandle(primary string, chunkHandle string) error
- func ErrorCodeToString(e int32) string
- func GenerateToken(length int) (string, error)
- func NewAppendFileResp(errorCode int32, primaryIP []string, chunckHandle []string) *pb.AppendFileResp
- func NewAppendResultResp() *pb.AppendResultResp
- func NewCSRegisterResp(errorCode int32) *pb.CSRegisterResp
- func NewCreateResp(errorCode int32) *pb.CreateResp
- func NewDeleteStatus(errorCode int32) *pb.DeleteStatus
- func NewGetLocationResp(errorCode int32, chunkInfo []*pb.ChunkServerInfo, start uint32, end uint32) *pb.GetLocationResp
- func NewGetTokenResp(uniqueToken string) *pb.GetTokenResp
- func NewHeartBeatResp(errorCode int32) *pb.HeartBeatResp
- type ChunkServerChan
- type ChunkServerInfo
- type ClientInfo
- type HandleMetaData
- type MasterServer
- func (s *MasterServer) AppendFile(ctx context.Context, appendFileReq *pb.AppendFileReq) (*pb.AppendFileResp, error)
- func (s *MasterServer) AppendResult(ctx context.Context, appendResultReq *pb.AppendResultReq) (*pb.AppendResultResp, error)
- func (s *MasterServer) AppendWorker(fileName string, fileSize uint32, primary string, peers []string, ...)
- func (s *MasterServer) CSRegister(ctx context.Context, csRegisterReq *pb.CSRegisterReq) (*pb.CSRegisterResp, error)
- func (s *MasterServer) Create(ctx context.Context, createReq *pb.CreateReq) (*pb.CreateResp, error)
- func (s *MasterServer) Delete(ctx context.Context, deleteReq *pb.DeleteReq) (*pb.DeleteStatus, error)
- func (s *MasterServer) GenerateHandleToMetaMap() error
- func (s *MasterServer) GetLocation(ctx context.Context, getLocationReq *pb.GetLocationReq) (*pb.GetLocationResp, error)
- func (s *MasterServer) GetToken(ctx context.Context, getTokenReq *pb.GetTokenReq) (*pb.GetTokenResp, error)
- func (s *MasterServer) HeartBeat(ctx context.Context, heartBeatReq *pb.HeartBeatPayload) (*pb.HeartBeatResp, error)
- func (s *MasterServer) PersistMetaData(chunkMetaData *HandleMetaData)
- func (s *MasterServer) PersistState(filename string, operation int)
- type Pair
- type SnapshotTimer
Constants ¶
const ( OK int32 = iota ERROR_FILE_NOT_EXISTS ERROR_PRIMARY_NOT_EXISTS ERROR_FILE_ALREADY_EXISTS ERROR_NO_SERVER_AVAILABLE ERROR_CHUNKSERVER_ALREADY_EXISTS ERROR_FAIL_TO_GENERATE_UNIQUE_TOKEN ERROR_FAIL_TO_DELETE ERROR_FAIL_TO_CONNECT_TO_CHUNKSERVER ERROR_FAIL_TO_CREATE_CHUNK_WHEN_CREATEFILE ERROR_FAIL_TO_CREATE_CHUNK_WHEN_APPEND ERROR_DEAD_BECOME_ALIVE ERROR_READ_WRONG_OFFSET ERROR_READ_WRONG_SIZE )
const ( DB_SET = iota DB_DELETE )
const (
ChunkSize = uint32(64 * 1024 * 1024)
)
Variables ¶
This section is empty.
Functions ¶
func DeleteChunkHandle ¶
helper function: given primary and chunkHandle, call DeleteChunk grpc to delete the chunk
func ErrorCodeToString ¶
func GenerateToken ¶
Given the length and generate unique token. For e.g. given 16 would generate a string token of length 24.
func NewAppendFileResp ¶
func NewAppendFileResp(errorCode int32, primaryIP []string, chunckHandle []string) *pb.AppendFileResp
func NewAppendResultResp ¶
func NewAppendResultResp() *pb.AppendResultResp
func NewCSRegisterResp ¶
func NewCSRegisterResp(errorCode int32) *pb.CSRegisterResp
func NewCreateResp ¶
func NewCreateResp(errorCode int32) *pb.CreateResp
func NewDeleteStatus ¶
func NewDeleteStatus(errorCode int32) *pb.DeleteStatus
func NewGetLocationResp ¶
func NewGetLocationResp(errorCode int32, chunkInfo []*pb.ChunkServerInfo, start uint32, end uint32) *pb.GetLocationResp
func NewGetTokenResp ¶
func NewGetTokenResp(uniqueToken string) *pb.GetTokenResp
func NewHeartBeatResp ¶
func NewHeartBeatResp(errorCode int32) *pb.HeartBeatResp
Types ¶
type ChunkServerChan ¶
type ChunkServerChan struct {
// contains filtered or unexported fields
}
type ChunkServerInfo ¶
type ClientInfo ¶
type ClientInfo struct { Token string UUID string // TODO: Save previous response GetTokenResp *pb.GetTokenResp }
type HandleMetaData ¶
type MasterServer ¶
type MasterServer struct { pb.UnimplementedMasterServer FileMutex sync.Mutex CSToHandleMutex sync.Mutex ChunkServerLoadMutex sync.Mutex // a mapping from File name to A slice of HandleMetaData Files map[string][]*HandleMetaData // a mapping from chunk handle to HandleMetaData HandleToMeta map[string]*HandleMetaData // a map from the unique Token(Host:Port) of ChunkServer to its Used (sort on value Used) ChunkServerLoad map[string]uint // a mapping from ChunkServer to all HandleMetaData it has CSToHandle map[string][]*HandleMetaData // a map record hearbeat channel HeartBeatMap map[string]*ChunkServerChan // globally unique server name ServerName string // base directory to store chunk files BasePath string HBMutex sync.Mutex CSRegisterMutex sync.Mutex DB *redis.Client AppendFileMutex sync.Mutex }
func (*MasterServer) AppendFile ¶
func (s *MasterServer) AppendFile(ctx context.Context, appendFileReq *pb.AppendFileReq) (*pb.AppendFileResp, error)
Client <-> Master : AppendFile request, given fileName and append size
func (*MasterServer) AppendResult ¶
func (s *MasterServer) AppendResult(ctx context.Context, appendResultReq *pb.AppendResultReq) (*pb.AppendResultResp, error)
chunk server <-> Master : modify used and load based on append outcome
func (*MasterServer) AppendWorker ¶
func (*MasterServer) CSRegister ¶
func (s *MasterServer) CSRegister(ctx context.Context, csRegisterReq *pb.CSRegisterReq) (*pb.CSRegisterResp, error)
chunk server <-> Master : ChunkServer Register, save the chunk server host and port
func (*MasterServer) Create ¶
func (s *MasterServer) Create(ctx context.Context, createReq *pb.CreateReq) (*pb.CreateResp, error)
client -> Master Create file given the FileName
func (*MasterServer) Delete ¶
func (s *MasterServer) Delete(ctx context.Context, deleteReq *pb.DeleteReq) (*pb.DeleteStatus, error)
Client <-> Master : Delete a file given the filename
func (*MasterServer) GenerateHandleToMetaMap ¶
func (s *MasterServer) GenerateHandleToMetaMap() error
GenerateHandleToMetaMap: when master server re-boot from crash, generate the HandleToMeta map from Files map.
func (*MasterServer) GetLocation ¶
func (s *MasterServer) GetLocation(ctx context.Context, getLocationReq *pb.GetLocationReq) (*pb.GetLocationResp, error)
GetLocation return the IP of the Primary chunkserver and chunkID back to client
func (*MasterServer) GetToken ¶
func (s *MasterServer) GetToken(ctx context.Context, getTokenReq *pb.GetTokenReq) (*pb.GetTokenResp, error)
Client <-> Master : Master return a unique token for each client First message client send to master
func (*MasterServer) HeartBeat ¶
func (s *MasterServer) HeartBeat(ctx context.Context, heartBeatReq *pb.HeartBeatPayload) (*pb.HeartBeatResp, error)
func (*MasterServer) PersistMetaData ¶
func (s *MasterServer) PersistMetaData(chunkMetaData *HandleMetaData)
func (*MasterServer) PersistState ¶
func (s *MasterServer) PersistState(filename string, operation int)
type Pair ¶
type Pair struct {
// contains filtered or unexported fields
}
Pair represents a key-value pair. For sorting the map
type SnapshotTimer ¶
type SnapshotTimer struct { DB *redis.Client Interval int Srv *MasterServer }
func (*SnapshotTimer) Snapshot ¶
func (t *SnapshotTimer) Snapshot()