Documentation ¶
Index ¶
- Constants
- Variables
- func Serve() error
- type Block
- type BlockList
- type BlockManager
- type CatDFSDir
- func (self *CatDFSDir) Abs() string
- func (self *CatDFSDir) Delete() error
- func (self *CatDFSDir) Filename() string
- func (self *CatDFSDir) GetFile(filename string) (DFSEntry, error)
- func (self *CatDFSDir) IsDir() bool
- func (self *CatDFSDir) List() DFSEntryList
- func (self *CatDFSDir) MountChild(child DFSEntry) error
- func (self *CatDFSDir) New(filename string, filetype DFSFileType, mode int) (DFSEntry, error)
- func (self *CatDFSDir) Parent() DFSDir
- func (self *CatDFSDir) RenameTo(dir DFSDir, filename string) error
- func (self *CatDFSDir) Status() *proc.CatFileStatus
- func (self *CatDFSDir) UnMountChild(child DFSEntry)
- type CatDFSFile
- func (self *CatDFSFile) Abs() string
- func (self *CatDFSFile) AddBlock() (*Block, error)
- func (self *CatDFSFile) Delete() error
- func (self *CatDFSFile) Filename() string
- func (self *CatDFSFile) GetFile(filename string) (DFSEntry, error)
- func (self *CatDFSFile) IsDir() bool
- func (self *CatDFSFile) Parent() DFSDir
- func (self *CatDFSFile) QueryBlocks(offset int64, length int64) (BlockList, bool)
- func (self *CatDFSFile) RenameTo(dir DFSDir, filename string) error
- func (self *CatDFSFile) Status() *proc.CatFileStatus
- func (self *CatDFSFile) UnMountChild(child DFSEntry) error
- type CatFileSystem
- func (self *CatFileSystem) AddBlock(abspath string) (*Block, error)
- func (self *CatFileSystem) CreateFile(abspath string, mode int) (DFSFile, error)
- func (self *CatFileSystem) DeleteFile(abspath string) error
- func (self *CatFileSystem) GetDir(abspath string) (DFSDir, error)
- func (self *CatFileSystem) GetFile(abspath string) (DFSFile, error)
- func (self *CatFileSystem) GetFileEntry(abspath string) (DFSEntry, error)
- func (self *CatFileSystem) IsExist(abspath string) bool
- func (self *CatFileSystem) ListDir(abspath string) (DFSEntryList, error)
- func (self *CatFileSystem) Mkdirs(abspath string, mode int) (DFSDir, error)
- func (self *CatFileSystem) QueryBlocks(abspath string, offset, length int64) (BlockList, bool, error)
- func (self *CatFileSystem) Rename(src, dst string) error
- type CreateFileLog
- type DFSDir
- type DFSEntry
- type DFSEntryList
- type DFSFile
- type DFSFileType
- type DeleteLog
- type Log
- type LogManager
- type MasterRPC
- func (self *MasterRPC) AbandonBlock(param *proc.AbandonBlockParam, succ *bool) error
- func (self *MasterRPC) AddBlock(param *proc.AddBlockParam, block *proc.CatBlock) error
- func (self *MasterRPC) BlockReport(param *proc.BlockReportParam, rep *proc.BlockReportResponse) error
- func (self *MasterRPC) Close(param *proc.CloseParam, succ *bool) error
- func (self *MasterRPC) Create(param *proc.CreateFileParam, resp *proc.OpenFileResponse) error
- func (self *MasterRPC) Delete(param *proc.DeleteParam, succ *bool) error
- func (self *MasterRPC) GetBlockLocation(query *proc.BlockQueryParam, resp *proc.GetBlocksLocationResponse) error
- func (self *MasterRPC) GetFileInfo(path string, filestatus *proc.CatFileStatus) error
- func (self *MasterRPC) Listdir(param *proc.ListDirParam, resp *proc.ListDirResponse) error
- func (self *MasterRPC) Mkdirs(param *proc.MkdirParam, succ *bool) error
- func (self *MasterRPC) Open(param *proc.OpenFileParam, resp *proc.OpenFileResponse) error
- func (self *MasterRPC) RegisterDataServer(param *proc.RegisterDataParam, succ *bool) error
- func (self *MasterRPC) Rename(param *proc.RenameParam, succ *bool) error
- func (self *MasterRPC) RenewLease(oldLease *proc.CatFileLease, newLease *proc.CatFileLease) error
- func (self *MasterRPC) SendHeartbeat(param *proc.HeartbeatParam, rep *proc.HeartbeatResponse) error
- type MkdirsLog
- type RenameLog
- type Slave
- func (self *Slave) AppendMigration(dst proc.ServerLocation, blockId string)
- func (self *Slave) BlockNum() int
- func (self *Slave) ExamBlock()
- func (self *Slave) GetCommands() []*proc.MasterCommand
- func (self *Slave) IsAlive(cpm time.Time) bool
- func (self *Slave) Location() proc.ServerLocation
- func (self *Slave) Migrate()
- func (self *Slave) Update(status *proc.DataServerStatus)
- type SlaveHeap
- type SlaveManager
- func (self *SlaveManager) AppendMigration(src, dst proc.ServerLocation, blockId string)
- func (self *SlaveManager) Exam()
- func (self *SlaveManager) NewBlockReplica() []proc.ServerLocation
- func (self *SlaveManager) RegisterSlave(status *proc.DataServerStatus)
- func (self *SlaveManager) UpdateSlave(status *proc.DataServerStatus) []*proc.MasterCommand
Constants ¶
View Source
const (
START_MSG = "CatFS Master RPC are start: %s"
)
Variables ¶
View Source
var ( ErrNoSuchFile = errors.New("No such file") ErrParentDirNotExist = errors.New("parent dir not exist") ErrFileAlreadyExist = errors.New("The file already exists") ErrNotEnoughAliveServer = errors.New("Not enough alive servers") ErrNotDir = errors.New("Not a dir") ErrNotFile = errors.New("Not a file") ErrIsRoot = errors.New("Is Root") ErrUnKnownFileType = errors.New("Unknown file type") ErrBadRequest = errors.New("Bad Request") )
Functions ¶
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (*Block) AddReplica ¶
func (self *Block) AddReplica(loc proc.ServerLocation) bool
try to add a replica, return success or not
func (*Block) Locations ¶
func (self *Block) Locations() []proc.ServerLocation
func (*Block) Migrate ¶
func (self *Block) Migrate(notLoc proc.ServerLocation)
type BlockManager ¶
type BlockManager struct {
// contains filtered or unexported fields
}
func (*BlockManager) GetBlock ¶
func (self *BlockManager) GetBlock(id string) *Block
func (*BlockManager) MigrateBlock ¶
func (self *BlockManager) MigrateBlock(id string, notLoc proc.ServerLocation)
func (*BlockManager) New ¶
func (self *BlockManager) New(fi *CatDFSFile) *Block
func (*BlockManager) Register ¶
func (self *BlockManager) Register(block *Block)
func (*BlockManager) Remove ¶
func (self *BlockManager) Remove(id string)
type CatDFSDir ¶
type CatDFSDir struct {
// contains filtered or unexported fields
}
func (*CatDFSDir) List ¶
func (self *CatDFSDir) List() DFSEntryList
func (*CatDFSDir) MountChild ¶
func (*CatDFSDir) Status ¶
func (self *CatDFSDir) Status() *proc.CatFileStatus
func (*CatDFSDir) UnMountChild ¶
type CatDFSFile ¶
type CatDFSFile struct {
// contains filtered or unexported fields
}
func (*CatDFSFile) Abs ¶
func (self *CatDFSFile) Abs() string
func (*CatDFSFile) AddBlock ¶
func (self *CatDFSFile) AddBlock() (*Block, error)
func (*CatDFSFile) Delete ¶
func (self *CatDFSFile) Delete() error
func (*CatDFSFile) Filename ¶
func (self *CatDFSFile) Filename() string
func (*CatDFSFile) IsDir ¶
func (self *CatDFSFile) IsDir() bool
func (*CatDFSFile) Parent ¶
func (self *CatDFSFile) Parent() DFSDir
func (*CatDFSFile) QueryBlocks ¶
func (self *CatDFSFile) QueryBlocks(offset int64, length int64) (BlockList, bool)
func (*CatDFSFile) Status ¶
func (self *CatDFSFile) Status() *proc.CatFileStatus
func (*CatDFSFile) UnMountChild ¶
func (self *CatDFSFile) UnMountChild(child DFSEntry) error
type CatFileSystem ¶
type CatFileSystem struct {
// contains filtered or unexported fields
}
func NewCatFileSystem ¶
func NewCatFileSystem() *CatFileSystem
func (*CatFileSystem) AddBlock ¶
func (self *CatFileSystem) AddBlock(abspath string) (*Block, error)
func (*CatFileSystem) CreateFile ¶
func (self *CatFileSystem) CreateFile(abspath string, mode int) (DFSFile, error)
func (*CatFileSystem) DeleteFile ¶
func (self *CatFileSystem) DeleteFile(abspath string) error
return nil if there is no error
func (*CatFileSystem) GetFileEntry ¶
func (self *CatFileSystem) GetFileEntry(abspath string) (DFSEntry, error)
use cache in the future
func (*CatFileSystem) IsExist ¶
func (self *CatFileSystem) IsExist(abspath string) bool
func (*CatFileSystem) ListDir ¶
func (self *CatFileSystem) ListDir(abspath string) (DFSEntryList, error)
func (*CatFileSystem) Mkdirs ¶
func (self *CatFileSystem) Mkdirs(abspath string, mode int) (DFSDir, error)
func (*CatFileSystem) QueryBlocks ¶
func (*CatFileSystem) Rename ¶
func (self *CatFileSystem) Rename(src, dst string) error
type CreateFileLog ¶
type CreateFileLog struct {
// contains filtered or unexported fields
}
create a file
func (*CreateFileLog) Execute ¶
func (self *CreateFileLog) Execute(fs *CatFileSystem)
func (*CreateFileLog) Load ¶
func (self *CreateFileLog) Load(reader io.Reader)
func (*CreateFileLog) Save ¶
func (self *CreateFileLog) Save(writer io.Writer)
type DFSDir ¶
type DFSDir interface { DFSEntry New(filename string, filetype DFSFileType, mode int) (DFSEntry, error) UnMountChild(child DFSEntry) MountChild(child DFSEntry) error // get file in the dir, return error when it is not dir or // there is no such file GetFile(filename string) (DFSEntry, error) List() DFSEntryList }
type DFSEntryList ¶
type DFSEntryList []DFSEntry
func (DFSEntryList) Status ¶
func (self DFSEntryList) Status() []*proc.CatFileStatus
type DFSFileType ¶
type DFSFileType int
const ( DFS_FILETYPE_FILE DFSFileType = iota DFS_FILETYPE_DIR )
type DeleteLog ¶
type DeleteLog struct {
// contains filtered or unexported fields
}
delete a file or dir
func (*DeleteLog) Execute ¶
func (self *DeleteLog) Execute(fs *CatFileSystem)
type Log ¶
type Log interface { Execute(fs *CatFileSystem) // save to disk or remote Save(writer io.Writer) // read from dis or remote Load(reader io.Reader) }
type LogManager ¶
type LogManager struct {
// contains filtered or unexported fields
}
func (*LogManager) CreateFile ¶
func (self *LogManager) CreateFile(abspath string, mode int)
func (*LogManager) DeleteFile ¶
func (self *LogManager) DeleteFile(abspath string)
func (*LogManager) LoadLogs ¶
func (self *LogManager) LoadLogs()
func (*LogManager) Mkdirs ¶
func (self *LogManager) Mkdirs(abspath string, mode int)
func (*LogManager) Rename ¶
func (self *LogManager) Rename(src string, dst string)
type MasterRPC ¶
type MasterRPC struct { }
func (*MasterRPC) AbandonBlock ¶
func (self *MasterRPC) AbandonBlock(param *proc.AbandonBlockParam, succ *bool) error
Delete a block from a file
func (*MasterRPC) BlockReport ¶
func (self *MasterRPC) BlockReport(param *proc.BlockReportParam, rep *proc.BlockReportResponse) error
Send blockreport to master
func (*MasterRPC) Close ¶
func (self *MasterRPC) Close(param *proc.CloseParam, succ *bool) error
Complete an operation, delete the lease (lock)
func (*MasterRPC) Create ¶
func (self *MasterRPC) Create(param *proc.CreateFileParam, resp *proc.OpenFileResponse) error
Create a file in a given path
func (*MasterRPC) Delete ¶
func (self *MasterRPC) Delete(param *proc.DeleteParam, succ *bool) error
Delete a file
func (*MasterRPC) GetBlockLocation ¶
func (self *MasterRPC) GetBlockLocation(query *proc.BlockQueryParam, resp *proc.GetBlocksLocationResponse) error
Get location of the block of the specified file within the specified range
func (*MasterRPC) GetFileInfo ¶
func (self *MasterRPC) GetFileInfo(path string, filestatus *proc.CatFileStatus) error
File info
func (*MasterRPC) Listdir ¶
func (self *MasterRPC) Listdir(param *proc.ListDirParam, resp *proc.ListDirResponse) error
List dir, why the return value is not a list?
func (*MasterRPC) Mkdirs ¶
func (self *MasterRPC) Mkdirs(param *proc.MkdirParam, succ *bool) error
Create a dir
func (*MasterRPC) Open ¶
func (self *MasterRPC) Open(param *proc.OpenFileParam, resp *proc.OpenFileResponse) error
Open a file to add block
func (*MasterRPC) RegisterDataServer ¶
func (self *MasterRPC) RegisterDataServer(param *proc.RegisterDataParam, succ *bool) error
Register a data server
func (*MasterRPC) Rename ¶
func (self *MasterRPC) Rename(param *proc.RenameParam, succ *bool) error
Rename
func (*MasterRPC) RenewLease ¶
func (self *MasterRPC) RenewLease(oldLease *proc.CatFileLease, newLease *proc.CatFileLease) error
Renew a lease
func (*MasterRPC) SendHeartbeat ¶
func (self *MasterRPC) SendHeartbeat(param *proc.HeartbeatParam, rep *proc.HeartbeatResponse) error
Send heartbeat to master
type MkdirsLog ¶
type MkdirsLog struct {
// contains filtered or unexported fields
}
create a directory
func (*MkdirsLog) Execute ¶
func (self *MkdirsLog) Execute(fs *CatFileSystem)
type RenameLog ¶
type RenameLog struct {
// contains filtered or unexported fields
}
rename a file or dir
func (*RenameLog) Execute ¶
func (self *RenameLog) Execute(fs *CatFileSystem)
type Slave ¶
type Slave struct {
// contains filtered or unexported fields
}
func (*Slave) AppendMigration ¶
func (self *Slave) AppendMigration(dst proc.ServerLocation, blockId string)
func (*Slave) GetCommands ¶
func (self *Slave) GetCommands() []*proc.MasterCommand
func (*Slave) Location ¶
func (self *Slave) Location() proc.ServerLocation
func (*Slave) Update ¶
func (self *Slave) Update(status *proc.DataServerStatus)
type SlaveManager ¶
type SlaveManager struct {
// contains filtered or unexported fields
}
func (*SlaveManager) AppendMigration ¶
func (self *SlaveManager) AppendMigration(src, dst proc.ServerLocation, blockId string)
func (*SlaveManager) Exam ¶
func (self *SlaveManager) Exam()
func (*SlaveManager) NewBlockReplica ¶
func (self *SlaveManager) NewBlockReplica() []proc.ServerLocation
compute the location for a new block
func (*SlaveManager) RegisterSlave ¶
func (self *SlaveManager) RegisterSlave(status *proc.DataServerStatus)
register a slave
func (*SlaveManager) UpdateSlave ¶
func (self *SlaveManager) UpdateSlave(status *proc.DataServerStatus) []*proc.MasterCommand
update a slave receive a heartbeat from dataserver
Click to show internal directories.
Click to hide internal directories.