master

package
v0.0.0-...-433ca32 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2014 License: GPL-3.0 Imports: 13 Imported by: 3

Documentation

Index

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

func Serve

func Serve() error

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

func (self *Block) CatBlock() *proc.CatBlock

func (*Block) ID

func (self *Block) ID() string

func (*Block) Locations

func (self *Block) Locations() []proc.ServerLocation

func (*Block) Migrate

func (self *Block) Migrate(notLoc proc.ServerLocation)

type BlockList

type BlockList []*Block

func (BlockList) ToCatBlock

func (self BlockList) ToCatBlock() []*proc.CatBlock

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

func (self *CatDFSDir) Abs() string

func (*CatDFSDir) Delete

func (self *CatDFSDir) Delete() error

func (*CatDFSDir) Filename

func (self *CatDFSDir) Filename() string

func (*CatDFSDir) GetFile

func (self *CatDFSDir) GetFile(filename string) (DFSEntry, error)

func (*CatDFSDir) IsDir

func (self *CatDFSDir) IsDir() bool

func (*CatDFSDir) List

func (self *CatDFSDir) List() DFSEntryList

func (*CatDFSDir) MountChild

func (self *CatDFSDir) MountChild(child DFSEntry) error

func (*CatDFSDir) New

func (self *CatDFSDir) New(filename string, filetype DFSFileType, mode int) (DFSEntry, error)

func (*CatDFSDir) Parent

func (self *CatDFSDir) Parent() DFSDir

func (*CatDFSDir) RenameTo

func (self *CatDFSDir) RenameTo(dir DFSDir, filename string) error

func (*CatDFSDir) Status

func (self *CatDFSDir) Status() *proc.CatFileStatus

func (*CatDFSDir) UnMountChild

func (self *CatDFSDir) UnMountChild(child DFSEntry)

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

func (self *CatDFSFile) GetFile(filename string) (DFSEntry, error)

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

func (self *CatDFSFile) RenameTo(dir DFSDir, filename string) error

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

func (self *CatFileSystem) GetDir(abspath string) (DFSDir, error)

func (*CatFileSystem) GetFile

func (self *CatFileSystem) GetFile(abspath string) (DFSFile, 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 (self *CatFileSystem) QueryBlocks(abspath string, offset, length int64) (BlockList, bool, error)

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 DFSEntry

type DFSEntry interface {
	Delete() error

	Parent() DFSDir

	IsDir() bool

	RenameTo(dir DFSDir, filename string) error

	Filename() string

	Abs() string

	Status() *proc.CatFileStatus
}

type DFSEntryList

type DFSEntryList []DFSEntry

func (DFSEntryList) Status

func (self DFSEntryList) Status() []*proc.CatFileStatus

type DFSFile

type DFSFile interface {
	DFSEntry

	// return (blocklist, eof)
	QueryBlocks(offset int64, length int64) (BlockList, bool)

	AddBlock() (*Block, error)
}

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)

func (*DeleteLog) Load

func (self *DeleteLog) Load(reader io.Reader)

func (*DeleteLog) Save

func (self *DeleteLog) Save(writer io.Writer)

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

func (self *MasterRPC) AddBlock(param *proc.AddBlockParam, block *proc.CatBlock) error

Add a block to a specific path (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)

func (*MkdirsLog) Load

func (self *MkdirsLog) Load(reader io.Reader)

func (*MkdirsLog) Save

func (self *MkdirsLog) Save(writer io.Writer)

type RenameLog

type RenameLog struct {
	// contains filtered or unexported fields
}

rename a file or dir

func (*RenameLog) Execute

func (self *RenameLog) Execute(fs *CatFileSystem)

func (*RenameLog) Load

func (self *RenameLog) Load(reader io.Reader)

func (*RenameLog) Save

func (self *RenameLog) Save(writer io.Writer)

type Slave

type Slave struct {
	// contains filtered or unexported fields
}

func (*Slave) AppendMigration

func (self *Slave) AppendMigration(dst proc.ServerLocation, blockId string)

func (*Slave) BlockNum

func (self *Slave) BlockNum() int

func (*Slave) ExamBlock

func (self *Slave) ExamBlock()

func (*Slave) GetCommands

func (self *Slave) GetCommands() []*proc.MasterCommand

func (*Slave) IsAlive

func (self *Slave) IsAlive(cpm time.Time) bool

func (*Slave) Location

func (self *Slave) Location() proc.ServerLocation

func (*Slave) Migrate

func (self *Slave) Migrate()

func (*Slave) Update

func (self *Slave) Update(status *proc.DataServerStatus)

type SlaveHeap

type SlaveHeap []*Slave

func (SlaveHeap) Len

func (h SlaveHeap) Len() int

func (SlaveHeap) Less

func (h SlaveHeap) Less(i, j int) bool

func (*SlaveHeap) Pop

func (h *SlaveHeap) Pop() interface{}

func (*SlaveHeap) Push

func (h *SlaveHeap) Push(x interface{})

func (SlaveHeap) Swap

func (h SlaveHeap) Swap(i, j int)

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

Jump to

Keyboard shortcuts

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