protocols

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: 2 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// Read lock
	LEASE_READ = iota
	// Write lock
	LEASE_WRITE
)
View Source
const (
	OPEN_MODE_READ = iota
	OPEN_MODE_WRITE
)
View Source
const (
	LEASE_DURATION = time.Minute
)
View Source
const READ_MODE int = 1

Client Master Params

View Source
const WRITE_MODE int = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type AbandonBlockParam

type AbandonBlockParam struct {
	// The abs path of the file
	Path string
	// Block
	Block *CatBlock
	// The lease of a file
	Lease *CatFileLease
}

type AddBlockParam

type AddBlockParam struct {
	// The abs path of the file
	Path string
	// The lease of a file
	Lease *CatFileLease
}

type BlockQueryParam

type BlockQueryParam struct {
	// The abs path of a file
	Path string
	// The offset of a file
	Offset int64
	// The length wanted
	Length int64
	// The lease of a file
	Lease *CatFileLease
}

Query for blocks of a specific file

type BlockReportParam

type BlockReportParam struct {
}

TODO do we need it?

type BlockReportResponse

type BlockReportResponse struct {
}

TODO do we need it?

type BlockStatus

type BlockStatus int
const (
	BLOCK_OK BlockStatus = iota
	BLOCK_Err
)

type CatBlock

type CatBlock struct {
	// The Id of a block
	ID string
	// The location of data server (Indexes)
	// The first one is the primary
	Locations []ServerLocation
}

The Information of a block

type CatFileLease

type CatFileLease struct {
	// The id the the lease
	// It works like a transaction ID
	ID string
	// Type of the lease
	Type int
	// Expire time of the lease
	Expire time.Time
}

func NewFileLease

func NewFileLease(tp int) *CatFileLease

func (*CatFileLease) New

func (self *CatFileLease) New(tp int)

func (*CatFileLease) Renew

func (self *CatFileLease) Renew(oldLease *CatFileLease)

type CatFileStatus

type CatFileStatus struct {
	// The name of the file
	Filename string
	// The length of the file
	Length int64
	// Time of last status change
	CTime time.Time
	// Time of last modification
	MTime time.Time
	// Time of last access
	ATime time.Time
	// Is Dir
	IsDir bool
	// Owner of the file
	Owner string
	// Group of the file
	Group string
	// Permission of the file
	// u:rwx g:rwx o:rwx
	Mode int16
}

type CatLease

type CatLease struct {
	// The id the the ease
	// It works like a transaction ID
	ID string
	// Expire time of the lease
	Expire time.Time
}

func (*CatLease) HasInit

func (self *CatLease) HasInit() bool

func (*CatLease) New

func (self *CatLease) New()

type ClientData

type ClientData interface {

	// Prepare send a block to datanode
	PrepareSendBlock(param *PrepareBlockParam, lease *CatLease) error

	// Wait util blocks reach destination
	// The block will be sent by a pipeline
	SendingBlock(param *SendingBlockParam, succ *bool) error

	// Get the block from data server
	// Will start an tcp connect to request block
	GetBlock(param *GetBlockParam, lease *CatLease) error
}

client: client server: data server

type ClientMaster

type ClientMaster interface {

	// Get location of the block of the specified file within the specified range
	GetBlockLocation(query *BlockQueryParam, blocks *GetBlocksLocationResponse) error

	// Create a file in a given path
	Create(param *CreateFileParam, response *OpenFileResponse) error

	// Open a file to add block
	Open(param *OpenFileParam, response *OpenFileResponse) error

	// Drop a block
	AbandonBlock(param *AbandonBlockParam, succ *bool) error

	// Add a block to a specific path (file)
	AddBlock(param *AddBlockParam, block *CatBlock) error

	// Complete an operation,
	// delete the lease (lock)
	Close(param *CloseParam, succ *bool) error

	// Rename
	Rename(param *RenameParam, succ *bool) error

	// Delete a file
	Delete(param *DeleteParam, succ *bool) error

	// Create a dir
	Mkdirs(param *MkdirParam, succ *bool) error

	// List dir
	Listdir(param *ListDirParam, response *ListDirResponse) error

	// Renew a lease
	RenewLease(oldLease *CatFileLease, newLease *CatFileLease) error

	// File info
	GetFileInfo(path string, filestatus *CatFileStatus) error
}

client: client server: master server

type CloseParam

type CloseParam struct {
	// The abs path of the file
	Path string
	// The lease of a file
	Lease *CatFileLease
	// User
	User string
}

type CreateFileParam

type CreateFileParam struct {
	// The abs path of the file
	Path string
	// Owner of the file
	Owner *string
}

type DataBlockReport

type DataBlockReport struct {
	ID     string
	Status BlockStatus
}

type DataMaster

type DataMaster interface {

	// Register a data server
	RegisterDataServer(param *RegisterDataParam, succ *bool) error

	// Send heartbeat to master
	SendHeartbeat(param *HeartbeatParam, rep *HeartbeatResponse) error

	// Send blockreport to master
	BlockReport(param *BlockReportParam, rep *BlockReportResponse) error
}

client: data server server: master server

type DataProtocol

type DataProtocol interface {
	ClientData
	InterData
}

type DataServerStatus

type DataServerStatus struct {
	Location     ServerLocation
	AvaiableSize uint64
	DataSize     uint64
	TotalSize    uint64
	Errors       []string
	BlockReports map[string]*DataBlockReport
}

type DeleteParam

type DeleteParam struct {
	// Path of a file or dir
	Path string
	// User
	User string
}

type GetBlockParam

type GetBlockParam struct {
	// Transaction id returned by prepare block
	Block *CatBlock
}

type GetBlocksLocationResponse

type GetBlocksLocationResponse struct {
	Blocks []*CatBlock
	EOF    bool
}

type HeartbeatParam

type HeartbeatParam struct {
	Status *DataServerStatus
}

type HeartbeatResponse

type HeartbeatResponse struct {
	// a list of command from the master
	Command []*MasterCommand
}

type InterData

type InterData interface {
}

client: data server server: data server

type ListDirParam

type ListDirParam struct {
	// Path of the dir
	Path string
	// User
	User string
}

type ListDirResponse

type ListDirResponse struct {
	Files []*CatFileStatus
}

type MasterBackup

type MasterBackup interface {
}

client: master server server: master backup server

type MasterCommand

type MasterCommand struct {
	Command    MasterCommandType
	Blocks     []string
	DstMachine ServerLocation
}

type MasterCommandType

type MasterCommandType int
const (
	// remove some blocks
	// Blocks is the uuid of the blocks
	// DstMachine is not important
	CleanCommand MasterCommandType = iota
	// Copy blocks from a machine to another machine
	// Blocks is the uuid of the blocks
	// DstMachine is the destination of the blocks
	MigrationCommand
)

type MasterProtocol

type MasterProtocol interface {
	ClientMaster
	DataMaster
	MasterBackup
}

type MkdirParam

type MkdirParam struct {
	// Path of the dir
	Path string
	// Owner of the dir
	Owner string
}

type OpenFileParam

type OpenFileParam struct {
	// The abs path of the file
	Path string
	// Owner of the file
	Owner *string
	// Open mode read or write
	Mode int
}

type OpenFileResponse

type OpenFileResponse struct {
	// the status of the file
	Filestatus *CatFileStatus
	// the file lease
	Lease *CatFileLease
}

type PrepareBlockParam

type PrepareBlockParam struct {
	// The block to send
	Block *CatBlock
}

func (*PrepareBlockParam) NextPipeParam

func (self *PrepareBlockParam) NextPipeParam() *PrepareBlockParam

func (*PrepareBlockParam) ServerLocation

func (self *PrepareBlockParam) ServerLocation() ServerLocation

type RegisterDataParam

type RegisterDataParam struct {
	Status *DataServerStatus
}

type RenameParam

type RenameParam struct {
	// Source Path
	Src string
	// Destination Path
	Des string
	// User
	User string
	// whether it is directory
	IsDirectory bool
}

type SendingBlockParam

type SendingBlockParam struct {
	// Transaction id returned by prepare block
	Lease *CatLease
}

type ServerLocation

type ServerLocation int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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