proto

package
v0.0.0-...-71dd0ca Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TaskFail         = 2
	TaskStart        = 0
	TaskSuccess      = 1
	TaskRunning      = 3
	ResponseInterval = 5
	ResponseTimeOut  = 100
	MaxSendCount     = 5
)
View Source
const (
	AttrMode uint32 = 1 << iota
	AttrUid
	AttrGid
)
View Source
const (
	AddrSplit       = "/"
	ExtentPartition = "extent"
	BlobPartition   = "blob"
)
View Source
const (
	ProtoMagic                   uint8 = 0xFF
	OpInitResultCode             uint8 = 0x00
	OpCreateFile                 uint8 = 0x01
	OpMarkDelete                 uint8 = 0x02
	OpWrite                      uint8 = 0x03
	OpRead                       uint8 = 0x04
	OpStreamRead                 uint8 = 0x05
	OpGetWatermark               uint8 = 0x06
	OpExtentStoreGetAllWaterMark uint8 = 0x07

	OpNotifyExtentRepair       uint8 = 0x08
	OpERepairRead              uint8 = 0x09
	OpBlobFileRepairRead       uint8 = 0x0A
	OpFlowInfo                 uint8 = 0x0B
	OpSyncDelNeedle            uint8 = 0x0C
	OpNotifyCompactBlobFile    uint8 = 0x0D
	OpGetDataPartitionMetrics  uint8 = 0x0E
	OpBlobStoreGetAllWaterMark uint8 = 0x0F
	OpNotifyBlobRepair         uint8 = 0x10

	// Operations: Client -> MetaNode.
	OpMetaCreateInode   uint8 = 0x20
	OpMetaDeleteInode   uint8 = 0x21
	OpMetaCreateDentry  uint8 = 0x22
	OpMetaDeleteDentry  uint8 = 0x23
	OpMetaOpen          uint8 = 0x24
	OpMetaLookup        uint8 = 0x25
	OpMetaReadDir       uint8 = 0x26
	OpMetaInodeGet      uint8 = 0x27
	OpMetaBatchInodeGet uint8 = 0x28
	OpMetaExtentsAdd    uint8 = 0x29
	OpMetaExtentsDel    uint8 = 0x2A
	OpMetaExtentsList   uint8 = 0x2B
	OpMetaUpdateDentry  uint8 = 0x2C
	OpMetaTruncate      uint8 = 0x2D
	OpMetaLinkInode     uint8 = 0x2E
	OpMetaEvictInode    uint8 = 0x2F
	OpMetaSetattr       uint8 = 0x30

	// Operations: Master -> MetaNode
	OpCreateMetaPartition  uint8 = 0x40
	OpMetaNodeHeartbeat    uint8 = 0x41
	OpDeleteMetaPartition  uint8 = 0x42
	OpUpdateMetaPartition  uint8 = 0x43
	OpLoadMetaPartition    uint8 = 0x44
	OpOfflineMetaPartition uint8 = 0x45

	// Operations: Master -> DataNode
	OpCreateDataPartition uint8 = 0x60
	OpDeleteDataPartition uint8 = 0x61
	OpLoadDataPartition   uint8 = 0x62
	OpDataNodeHeartbeat   uint8 = 0x63
	OpReplicateFile       uint8 = 0x64
	OpDeleteFile          uint8 = 0x65

	// Commons
	OpIntraGroupNetErr uint8 = 0xF3
	OpArgMismatchErr   uint8 = 0xF4
	OpNotExistErr      uint8 = 0xF5
	OpDiskNoSpaceErr   uint8 = 0xF6
	OpDiskErr          uint8 = 0xF7
	OpErr              uint8 = 0xF8
	OpAgain            uint8 = 0xF9
	OpExistErr         uint8 = 0xFA
	OpInodeFullErr     uint8 = 0xFB
	OpOk               uint8 = 0xF0

	// For connection diagnosis
	OpPing uint8 = 0xFF
)

operations

View Source
const (
	WriteDeadlineTime      = 5
	ReadDeadlineTime       = 5
	NoReadDeadlineTime     = -1
	StreamReadDeadLineTime = 2
)
View Source
const (
	BlobStoreMode   = 0
	ExtentStoreMode = 1
)
View Source
const (
	ReadOnly    = 1
	ReadWrite   = 2
	Unavaliable = -1
)
View Source
const (
	RootIno = uint64(1)
)

Variables

View Source
var (
	ReqIDGlobal = int64(1)
	Buffers     = buf.NewBufferPool()
)
View Source
var InvalidKey = errors.New("invalid key error")

Functions

func GetReqID

func GetReqID() int64

func IsDir

func IsDir(mode uint32) bool

func IsRegular

func IsRegular(mode uint32) bool
func IsSymlink(mode uint32) bool

func Mode

func Mode(osMode os.FileMode) uint32

func OsMode

func OsMode(mode uint32) os.FileMode

func ReadFull

func ReadFull(c net.Conn, buf *[]byte, readSize int) (err error)

Types

type AdminTask

type AdminTask struct {
	ID           string
	OpCode       uint8
	OperatorAddr string
	Status       int8
	SendTime     int64
	CreateTime   int64
	SendCount    uint8
	Request      interface{}
	Response     interface{}
}

task struct to node

func NewAdminTask

func NewAdminTask(opCode uint8, opAddr string, request interface{}) (t *AdminTask)

func (*AdminTask) CheckTaskIsFail

func (t *AdminTask) CheckTaskIsFail() (isFail bool)

func (*AdminTask) CheckTaskIsSuccess

func (t *AdminTask) CheckTaskIsSuccess() (isSuccess bool)

func (*AdminTask) CheckTaskNeedSend

func (t *AdminTask) CheckTaskNeedSend() (needRetry bool)

1.has never send, t.SendTime=0, 2.has send but response time out

func (*AdminTask) CheckTaskTimeOut

func (t *AdminTask) CheckTaskTimeOut() (notResponse bool)

the task which sendCount >= MaxSendCount, the last send has no response after ResponseTimeOut passed, to be consider time out

func (*AdminTask) IsHeartbeatTask

func (t *AdminTask) IsHeartbeatTask() bool

func (*AdminTask) IsUrgentTask

func (t *AdminTask) IsUrgentTask() bool

func (*AdminTask) SetStatus

func (t *AdminTask) SetStatus(status int8)

func (*AdminTask) ToString

func (t *AdminTask) ToString() (msg string)

type AppendExtentKeyRequest

type AppendExtentKeyRequest struct {
	VolName     string    `json:"vol"`
	PartitionID uint64    `json:"pid"`
	Inode       uint64    `json:"ino"`
	Extent      ExtentKey `json:"ek"`
}

type BatchInodeGetRequest

type BatchInodeGetRequest struct {
	VolName     string   `json:"vol"`
	PartitionID uint64   `json:"pid"`
	Inodes      []uint64 `json:"inos"`
}

type BatchInodeGetResponse

type BatchInodeGetResponse struct {
	Infos []*InodeInfo `json:"infos"`
}

type ClusterInfo

type ClusterInfo struct {
	Cluster string
	Ip      string
}

type CreateDataPartitionRequest

type CreateDataPartitionRequest struct {
	PartitionType string
	PartitionId   uint64
	PartitionSize int
	VolumeId      string
}

type CreateDataPartitionResponse

type CreateDataPartitionResponse struct {
	PartitionId uint64
	Status      uint8
	Result      string
}

type CreateDentryRequest

type CreateDentryRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	ParentID    uint64 `json:"pino"`
	Inode       uint64 `json:"ino"`
	Name        string `json:"name"`
	Mode        uint32 `json:"mode"`
}

type CreateInodeRequest

type CreateInodeRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Mode        uint32 `json:"mode"`
	Target      []byte `json:"tgt"`
}

type CreateInodeResponse

type CreateInodeResponse struct {
	Info *InodeInfo `json:"info"`
}

type CreateMetaPartitionRequest

type CreateMetaPartitionRequest struct {
	MetaId      string
	VolName     string
	Start       uint64
	End         uint64
	PartitionID uint64
	Members     []Peer
}

type CreateMetaPartitionResponse

type CreateMetaPartitionResponse struct {
	VolName     string
	PartitionID uint64
	Status      uint8
	Result      string
}

type CreateNameSpaceRequest

type CreateNameSpaceRequest struct {
	Name string
}

type CreateNameSpaceResponse

type CreateNameSpaceResponse struct {
	Status int
	Result string
}

type DataNodeHeartBeatResponse

type DataNodeHeartBeatResponse struct {
	Total                           uint64
	Used                            uint64
	Available                       uint64
	CreatedPartitionWeights         uint64 //volCnt*volsize
	RemainWeightsForCreatePartition uint64 //all-usedvolsWieghts
	CreatedPartitionCnt             uint32
	MaxWeightsForCreatePartition    uint64
	RackName                        string
	PartitionInfo                   []*PartitionReport
	Status                          uint8
	Result                          string
}

type DeleteDataPartitionRequest

type DeleteDataPartitionRequest struct {
	DataPartitionType string
	PartitionId       uint64
	PartitionSize     int
}

type DeleteDataPartitionResponse

type DeleteDataPartitionResponse struct {
	Status      uint8
	Result      string
	PartitionId uint64
}

type DeleteDentryRequest

type DeleteDentryRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	ParentID    uint64 `json:"pino"`
	Name        string `json:"name"`
}

type DeleteDentryResponse

type DeleteDentryResponse struct {
	Inode uint64 `json:"ino"`
}

type DeleteFileRequest

type DeleteFileRequest struct {
	VolId uint64
	Name  string
}

type DeleteFileResponse

type DeleteFileResponse struct {
	Status uint8
	Result string
	VolId  uint64
	Name   string
}

type DeleteInodeRequest

type DeleteInodeRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
}

FIXME: unlink inode

type DeleteInodeResponse

type DeleteInodeResponse struct {
	Info *InodeInfo `json:"info"`
}

type DeleteMetaPartitionRequest

type DeleteMetaPartitionRequest struct {
	PartitionID uint64
}

type DeleteMetaPartitionResponse

type DeleteMetaPartitionResponse struct {
	PartitionID uint64
	Status      uint8
	Result      string
}

type Dentry

type Dentry struct {
	Name  string `json:"name"`
	Inode uint64 `json:"ino"`
	Type  uint32 `json:"type"`
}

func (Dentry) String

func (d Dentry) String() string

type EvictInodeRequest

type EvictInodeRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
}

type ExtentKey

type ExtentKey struct {
	PartitionId uint32
	ExtentId    uint64
	Size        uint32
	Crc         uint32
}

func (*ExtentKey) Equal

func (ek *ExtentKey) Equal(k ExtentKey) bool

func (*ExtentKey) FullEqual

func (ek *ExtentKey) FullEqual(k ExtentKey) bool

func (*ExtentKey) GetExtentKey

func (k *ExtentKey) GetExtentKey() (m string)

func (*ExtentKey) Marshal

func (k *ExtentKey) Marshal() (m string)

func (*ExtentKey) MarshalBinary

func (k *ExtentKey) MarshalBinary() ([]byte, error)

func (ExtentKey) String

func (ek ExtentKey) String() string

func (*ExtentKey) UnMarshal

func (k *ExtentKey) UnMarshal(m string) (err error)

func (*ExtentKey) UnmarshalBinary

func (k *ExtentKey) UnmarshalBinary(buf *bytes.Buffer) (err error)

type File

type File struct {
	Name      string
	Crc       uint32
	CheckSum  uint32
	Size      uint32
	Modified  int64
	MarkDel   bool
	LastObjID uint64
	NeedleCnt int
}

type GetExtentsRequest

type GetExtentsRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
}

type GetExtentsResponse

type GetExtentsResponse struct {
	Extents []ExtentKey `json:"eks"`
}

type HeartBeatRequest

type HeartBeatRequest struct {
	CurrTime   int64
	MasterAddr string
}

type InodeGetRequest

type InodeGetRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
}

type InodeGetResponse

type InodeGetResponse struct {
	Info *InodeInfo `json:"info"`
}

type InodeInfo

type InodeInfo struct {
	Inode      uint64    `json:"ino"`
	Mode       uint32    `json:"mode"`
	Nlink      uint32    `json:"nlink"`
	Size       uint64    `json:"sz"`
	Uid        uint32    `json:"uid"`
	Gid        uint32    `json:"gid"`
	Generation uint64    `json:"gen"`
	ModifyTime time.Time `json:"mt"`
	CreateTime time.Time `json:"ct"`
	AccessTime time.Time `json:"at"`
	Target     []byte    `json:"tgt"`
}

func (*InodeInfo) String

func (info *InodeInfo) String() string

type LinkInodeRequest

type LinkInodeRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
}

type LinkInodeResponse

type LinkInodeResponse struct {
	Info *InodeInfo `json:"info"`
}

type LoadDataPartitionRequest

type LoadDataPartitionRequest struct {
	PartitionType string
	PartitionId   uint64
}

type LoadDataPartitionResponse

type LoadDataPartitionResponse struct {
	PartitionType     string
	PartitionId       uint64
	Used              uint64
	PartitionSnapshot []*File
	Status            uint8
	PartitionStatus   int
	Result            string
}

type LoadMetaPartitionMetricRequest

type LoadMetaPartitionMetricRequest struct {
	PartitionID uint64
	Start       uint64
	End         uint64
}

type LoadMetaPartitionMetricResponse

type LoadMetaPartitionMetricResponse struct {
	Start    uint64
	End      uint64
	MaxInode uint64
	Status   uint8
	Result   string
}

type LookupRequest

type LookupRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	ParentID    uint64 `json:"pino"`
	Name        string `json:"name"`
}

type LookupResponse

type LookupResponse struct {
	Inode uint64 `json:"ino"`
	Mode  uint32 `json:"mode"`
}

type MetaNodeHeartbeatResponse

type MetaNodeHeartbeatResponse struct {
	RackName          string
	Total             uint64
	Used              uint64
	MetaPartitionInfo []*MetaPartitionReport
	Status            uint8
	Result            string
}

type MetaPartitionOfflineRequest

type MetaPartitionOfflineRequest struct {
	PartitionID uint64
	VolName     string
	RemovePeer  Peer
	AddPeer     Peer
}

type MetaPartitionOfflineResponse

type MetaPartitionOfflineResponse struct {
	PartitionID uint64
	VolName     string
	Status      uint8
	Result      string
}

type MetaPartitionReport

type MetaPartitionReport struct {
	PartitionID uint64
	Start       uint64
	End         uint64
	Status      int
	MaxInodeID  uint64
	IsLeader    bool
}

type OpenRequest

type OpenRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
}

type Packet

type Packet struct {
	Magic       uint8
	StoreMode   uint8
	Opcode      uint8
	ResultCode  uint8
	Nodes       uint8
	Crc         uint32
	Size        uint32
	Arglen      uint32
	PartitionID uint32
	FileID      uint64
	Offset      int64
	ReqID       int64
	Arg         []byte //if create or append ops, data contains addrs
	Data        []byte
	StartT      int64
}

func NewPacket

func NewPacket() *Packet

func NewPingPacket

func NewPingPacket() *Packet

func (*Packet) ActionMsg

func (p *Packet) ActionMsg(action, remote string, start int64, err error) (m string)

func (*Packet) GetData

func (p *Packet) GetData() string

func (*Packet) GetOpMsg

func (p *Packet) GetOpMsg() (m string)

func (*Packet) GetResultMesg

func (p *Packet) GetResultMesg() (m string)

func (*Packet) GetStoreModeMsg

func (p *Packet) GetStoreModeMsg() (m string)

func (*Packet) GetUniqueLogId

func (p *Packet) GetUniqueLogId() (m string)

func (*Packet) IsOkReply

func (p *Packet) IsOkReply() bool

func (*Packet) IsTransitPkg

func (p *Packet) IsTransitPkg() bool

func (*Packet) MarshalData

func (p *Packet) MarshalData(v interface{}) error

func (*Packet) MarshalHeader

func (p *Packet) MarshalHeader(out []byte)

func (*Packet) PackErrorWithBody

func (p *Packet) PackErrorWithBody(errCode uint8, reply []byte)

func (*Packet) PackOkGetWatermarkReply

func (p *Packet) PackOkGetWatermarkReply(size int64)

func (*Packet) PackOkReadReply

func (p *Packet) PackOkReadReply()

func (*Packet) PackOkReply

func (p *Packet) PackOkReply()

func (*Packet) PackOkWithBody

func (p *Packet) PackOkWithBody(reply []byte)

func (*Packet) ReadFromConn

func (p *Packet) ReadFromConn(c net.Conn, timeoutSec int) (err error)

func (*Packet) ShallRetry

func (p *Packet) ShallRetry() bool

func (*Packet) UnmarshalData

func (p *Packet) UnmarshalData(v interface{}) error

func (*Packet) UnmarshalHeader

func (p *Packet) UnmarshalHeader(in []byte) error

func (*Packet) WriteHeaderToConn

func (p *Packet) WriteHeaderToConn(c net.Conn) (err error)

func (*Packet) WriteToConn

func (p *Packet) WriteToConn(c net.Conn) (err error)

func (*Packet) WriteToNoDeadLineConn

func (p *Packet) WriteToNoDeadLineConn(c net.Conn) (err error)

type PartitionReport

type PartitionReport struct {
	PartitionID     uint64
	PartitionStatus int
	Total           uint64
	Used            uint64
}

type Peer

type Peer struct {
	ID   uint64 `json:"id"`
	Addr string `json:"addr"`
}

type ReadDirRequest

type ReadDirRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	ParentID    uint64 `json:"pino"`
}

type ReadDirResponse

type ReadDirResponse struct {
	Children []Dentry `json:"children"`
}

type RegisterMetaNodeResp

type RegisterMetaNodeResp struct {
	ID uint64
}

type SetattrRequest

type SetattrRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
	Mode        uint32 `json:"mode"`
	Uid         uint32 `json:"uid"`
	Gid         uint32 `json:"gid"`
	Valid       uint32 `json:"valid"`
}

type StreamKey

type StreamKey struct {
	Inode   uint64
	Extents []ExtentKey
	sync.Mutex
}

func NewStreamKey

func NewStreamKey(ino uint64) *StreamKey

func (*StreamKey) GetExtentLen

func (sk *StreamKey) GetExtentLen() int

func (*StreamKey) Marshal

func (sk *StreamKey) Marshal() (data []byte, err error)

func (*StreamKey) MarshalBinary

func (sk *StreamKey) MarshalBinary() (data []byte, err error)

func (*StreamKey) Put

func (sk *StreamKey) Put(k ExtentKey)

func (*StreamKey) Range

func (sk *StreamKey) Range(f func(i int, v ExtentKey) bool)

Range calls f sequentially for each key and value present in the extent key collection. If f returns false, range stops the iteration.

func (*StreamKey) Size

func (sk *StreamKey) Size() (bytes uint64)

func (*StreamKey) String

func (sk *StreamKey) String() string

func (*StreamKey) ToString

func (sk *StreamKey) ToString() (m string)

func (*StreamKey) UnMarshal

func (sk *StreamKey) UnMarshal(data []byte)

func (*StreamKey) UnmarshalBinary

func (sk *StreamKey) UnmarshalBinary(data []byte) (err error)

type TruncateRequest

type TruncateRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	Inode       uint64 `json:"ino"`
	FileOffset  uint64 `json:"fof"` // always 0 for now
	Size        uint64 `json:"sz"`  // always 0 for now
}

type TruncateResponse

type TruncateResponse struct {
	Extents []ExtentKey `json:"ek"`
}

type UpdateDentryRequest

type UpdateDentryRequest struct {
	VolName     string `json:"vol"`
	PartitionID uint64 `json:"pid"`
	ParentID    uint64 `json:"pino"`
	Name        string `json:"name"`
	Inode       uint64 `json:"ino"` // new inode number
}

type UpdateDentryResponse

type UpdateDentryResponse struct {
	Inode uint64 `json:"ino"` // old inode number
}

type UpdateMetaPartitionRequest

type UpdateMetaPartitionRequest struct {
	PartitionID uint64
	VolName     string
	Start       uint64
	End         uint64
}

type UpdateMetaPartitionResponse

type UpdateMetaPartitionResponse struct {
	PartitionID uint64
	VolName     string
	End         uint64
	Status      uint8
	Result      string
}

Jump to

Keyboard shortcuts

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