proto

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Admin APIs
	AdminGetCluster                = "/admin/getCluster"
	AdminGetDataPartition          = "/dataPartition/get"
	AdminLoadDataPartition         = "/dataPartition/load"
	AdminCreateDataPartition       = "/dataPartition/create"
	AdminDecommissionDataPartition = "/dataPartition/decommission"
	AdminDeleteVol                 = "/vol/delete"
	AdminUpdateVol                 = "/vol/update"
	AdminCreateVol                 = "/admin/createVol"
	AdminGetVol                    = "/admin/getVol"
	AdminClusterFreeze             = "/cluster/freeze"
	AdminGetIP                     = "/admin/getIp"
	AdminCreateMP                  = "/metaPartition/create"
	AdminSetMetaNodeThreshold      = "/threshold/set"

	// Client APIs
	ClientDataPartitions = "/client/partitions"
	ClientVol            = "/client/vol"
	ClientMetaPartition  = "/client/metaPartition"
	ClientVolStat        = "/client/volStat"

	//raft node APIs
	AddRaftNode    = "/raftNode/add"
	RemoveRaftNode = "/raftNode/remove"

	// Node APIs
	AddDataNode                    = "/dataNode/add"
	DecommissionDataNode           = "/dataNode/decommission"
	DecommissionDisk               = "/disk/decommission"
	GetDataNode                    = "/dataNode/get"
	AddMetaNode                    = "/metaNode/add"
	DecommissionMetaNode           = "/metaNode/decommission"
	GetMetaNode                    = "/metaNode/get"
	AdminLoadMetaPartition         = "/metaPartition/load"
	AdminDecommissionMetaPartition = "/metaPartition/decommission"

	// Operation response
	GetMetaNodeTaskResponse = "/metaNode/response" // Method: 'POST', ContentType: 'application/json'
	GetDataNodeTaskResponse = "/dataNode/response" // Method: 'POST', ContentType: 'application/json'

	GetTopologyView = "/topo/get"
)

api

View Source
const (
	TaskFailed       = 2
	TaskStart        = 0
	TaskSucceeds     = 1
	TaskRunning      = 3
	ResponseInterval = 5
	ResponseTimeOut  = 100
	MaxSendCount     = 5
)
View Source
const (
	ErrCodeSuccess = iota
	ErrCodeInternalError
	ErrCodeParamError
	ErrCodeInvalidCfg
	ErrCodePersistenceByRaft
	ErrCodeMarshalData
	ErrCodeUnmarshalData
	ErrCodeVolNotExists
	ErrCodeMetaPartitionNotExists
	ErrCodeDataPartitionNotExists
	ErrCodeDataNodeNotExists
	ErrCodeMetaNodeNotExists
	ErrCodeDuplicateVol
	ErrCodeActiveDataNodesTooLess
	ErrCodeActiveMetaNodesTooLess
	ErrCodeInvalidMpStart
	ErrCodeNoAvailDataPartition
	ErrCodeReshuffleArray
	ErrCodeIllegalDataReplica
	ErrCodeMissingReplica
	ErrCodeHasOneMissingReplica
	ErrCodeNoDataNodeToWrite
	ErrCodeNoMetaNodeToWrite
	ErrCodeCannotBeOffLine
	ErrCodeNoDataNodeToCreateDataPartition
	ErrCodeNoRackToCreateDataPartition
	ErrCodeNoNodeSetToCreateDataPartition
	ErrCodeNoNodeSetToCreateMetaPartition
	ErrCodeNoMetaNodeToCreateMetaPartition
	ErrCodeIllegalMetaReplica
	ErrCodeNoEnoughReplica
	ErrCodeNoLeader
	ErrCodeVolAuthKeyNotMatch
)

http response error code and error message definitions

View Source
const (
	AttrMode uint32 = 1 << iota
	AttrUid
	AttrGid
)
View Source
const (
	ProtoMagic         uint8 = 0xFF
	OpInitResultCode   uint8 = 0x00
	OpCreateExtent     uint8 = 0x01
	OpMarkDelete       uint8 = 0x02
	OpWrite            uint8 = 0x03
	OpRead             uint8 = 0x04
	OpStreamRead       uint8 = 0x05
	OpGetAllWatermarks uint8 = 0x07

	OpNotifyReplicasToRepair uint8 = 0x08
	OpExtentRepairRead       uint8 = 0x09
	OpBroadcastMinAppliedID  uint8 = 0x0A
	OpRandomWrite            uint8 = 0x0F
	OpGetAppliedId           uint8 = 0x10
	OpGetPartitionSize       uint8 = 0x11
	OpSyncRandomWrite        uint8 = 0x12
	OpSyncWrite              uint8 = 0x13
	OpReadTinyDelete         uint8 = 0x14

	// Operations: Client -> MetaNode.
	OpMetaCreateInode   uint8 = 0x20
	OpMetaUnlinkInode   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
	OpMetaReleaseOpen   uint8 = 0x31

	//Operations: MetaNode Leader -> MetaNode Follower
	OpMetaFreeInodesOnRaftFollower uint8 = 0x32

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

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

	// 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
	OpTryOtherAddr     uint8 = 0xFC
	OpNotPerm          uint8 = 0xFD
	OpNotEmtpy         uint8 = 0xFE
	OpOk               uint8 = 0xF0

	OpPing uint8 = 0xFF
)

Operations

View Source
const (
	WriteDeadlineTime        = 5
	ReadDeadlineTime         = 5
	SyncSendTaskDeadlineTime = 20
	NoReadDeadlineTime       = -1

	GetAllWatermarksDeadLineTime = 60
)
View Source
const (
	TinyExtentType   = 0
	NormalExtentType = 1
)
View Source
const (
	ReadOnly    = 1
	ReadWrite   = 2
	Unavailable = -1
)

The following defines the status of a disk or a partition.

View Source
const (
	AddrSplit = "/"
)
View Source
const (
	RootIno = uint64(1)
)

Variables

View Source
var (
	ErrSuc                    = errors.New("success")
	ErrInternalError          = errors.New("internal error")
	ErrParamError             = errors.New("parameter error")
	ErrInvalidCfg             = errors.New("bad configuration file")
	ErrPersistenceByRaft      = errors.New("persistence by raft occurred error")
	ErrMarshalData            = errors.New("marshal data error")
	ErrUnmarshalData          = errors.New("unmarshal data error")
	ErrVolNotExists           = errors.New("vol not exists")
	ErrMetaPartitionNotExists = errors.New("meta partition not exists")
	ErrDataPartitionNotExists = errors.New("data partition not exists")
	ErrDataNodeNotExists      = errors.New("data node not exists")
	ErrMetaNodeNotExists      = errors.New("meta node not exists")
	ErrDuplicateVol           = errors.New("duplicate vol")
	ErrActiveDataNodesTooLess = errors.New("no enough active data node")
	ErrActiveMetaNodesTooLess = errors.New("no enough active meta node")
	ErrInvalidMpStart         = errors.New("invalid meta partition start value")
	ErrNoAvailDataPartition   = errors.New("no available data partition")
	ErrReshuffleArray         = errors.New("the array to be reshuffled is nil")

	ErrIllegalDataReplica = errors.New("data replica is illegal")

	ErrMissingReplica       = errors.New("a missing data replica is found")
	ErrHasOneMissingReplica = errors.New("there is a missing data replica")

	ErrNoDataNodeToWrite = errors.New("No data node available for creating a data partition")
	ErrNoMetaNodeToWrite = errors.New("No meta node available for creating a meta partition")

	ErrCannotBeOffLine                 = errors.New("cannot take the data replica offline")
	ErrNoDataNodeToCreateDataPartition = errors.New("no enough data nodes for creating a data partition")
	ErrNoRackToCreateDataPartition     = errors.New("no rack available for creating a data partition")
	ErrNoNodeSetToCreateDataPartition  = errors.New("no node set available for creating a data partition")
	ErrNoNodeSetToCreateMetaPartition  = errors.New("no node set available for creating a meta partition")
	ErrNoMetaNodeToCreateMetaPartition = errors.New("no enough meta nodes for creating a meta partition")
	ErrIllegalMetaReplica              = errors.New("illegal meta replica")
	ErrNoEnoughReplica                 = errors.New("no enough replicas")
	ErrNoLeader                        = errors.New("no leader")
	ErrVolAuthKeyNotMatch              = errors.New("client and server auth key do not match")
)

err

View Source
var (
	ExtentLength = 40
	InvalidKey   = errors.New("invalid key error")
)
View Source
var (
	GRequestID = int64(1)
	Buffers    = buf.NewBufferPool()
)
View Source
var Err2CodeMap = map[error]int32{
	ErrSuc:                             ErrCodeSuccess,
	ErrInternalError:                   ErrCodeInternalError,
	ErrParamError:                      ErrCodeParamError,
	ErrInvalidCfg:                      ErrCodeInvalidCfg,
	ErrPersistenceByRaft:               ErrCodePersistenceByRaft,
	ErrMarshalData:                     ErrCodeMarshalData,
	ErrUnmarshalData:                   ErrCodeUnmarshalData,
	ErrVolNotExists:                    ErrCodeVolNotExists,
	ErrMetaPartitionNotExists:          ErrCodeMetaPartitionNotExists,
	ErrDataPartitionNotExists:          ErrCodeDataPartitionNotExists,
	ErrDataNodeNotExists:               ErrCodeDataNodeNotExists,
	ErrMetaNodeNotExists:               ErrCodeMetaNodeNotExists,
	ErrDuplicateVol:                    ErrCodeDuplicateVol,
	ErrActiveDataNodesTooLess:          ErrCodeActiveDataNodesTooLess,
	ErrActiveMetaNodesTooLess:          ErrCodeActiveMetaNodesTooLess,
	ErrInvalidMpStart:                  ErrCodeInvalidMpStart,
	ErrNoAvailDataPartition:            ErrCodeNoAvailDataPartition,
	ErrReshuffleArray:                  ErrCodeReshuffleArray,
	ErrIllegalDataReplica:              ErrCodeIllegalDataReplica,
	ErrMissingReplica:                  ErrCodeMissingReplica,
	ErrHasOneMissingReplica:            ErrCodeHasOneMissingReplica,
	ErrNoDataNodeToWrite:               ErrCodeNoDataNodeToWrite,
	ErrNoMetaNodeToWrite:               ErrCodeNoMetaNodeToWrite,
	ErrCannotBeOffLine:                 ErrCodeCannotBeOffLine,
	ErrNoDataNodeToCreateDataPartition: ErrCodeNoDataNodeToCreateDataPartition,
	ErrNoRackToCreateDataPartition:     ErrCodeNoRackToCreateDataPartition,
	ErrNoNodeSetToCreateDataPartition:  ErrCodeNoNodeSetToCreateDataPartition,
	ErrNoNodeSetToCreateMetaPartition:  ErrCodeNoNodeSetToCreateMetaPartition,
	ErrNoMetaNodeToCreateMetaPartition: ErrCodeNoMetaNodeToCreateMetaPartition,
	ErrIllegalMetaReplica:              ErrCodeIllegalMetaReplica,
	ErrNoEnoughReplica:                 ErrCodeNoEnoughReplica,
	ErrNoLeader:                        ErrCodeNoLeader,
	ErrVolAuthKeyNotMatch:              ErrCodeVolAuthKeyNotMatch,
}

Err2CodeMap error map to code

Functions

func GenerateRequestID

func GenerateRequestID() int64

GenerateRequestID generates the request ID.

func IsDir

func IsDir(mode uint32) bool

IsDir checks if the mode is dir.

func IsRegular

func IsRegular(mode uint32) bool

IsRegular checks if the mode is regular.

func IsSymlink(mode uint32) bool

IsSymlink checks if the mode is symlink.

func Mode

func Mode(osMode os.FileMode) uint32

Mode returns the fileMode.

func OsMode

func OsMode(mode uint32) os.FileMode

OsMode returns os.FileMode.

func ReadFull

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

ReadFull is a wrapper function of io.ReadFull.

Types

type AdminTask

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

AdminTask defines the administration task.

func NewAdminTask

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

NewAdminTask returns a new adminTask.

func (*AdminTask) CheckTaskNeedSend

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

CheckTaskNeedSend checks if the task needs to be sent out.

func (*AdminTask) CheckTaskTimeOut

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

CheckTaskTimeOut checks if the task is timed out.

func (*AdminTask) IsHeartbeatTask

func (t *AdminTask) IsHeartbeatTask() bool

IsHeartbeatTask returns if the task is a heartbeat task.

func (*AdminTask) IsTaskFailed

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

IsTaskFailed returns if the task failed.

func (*AdminTask) IsTaskSuccessful

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

IsTaskSuccessful returns if the task has been executed successful.

func (*AdminTask) IsUrgentTask

func (t *AdminTask) IsUrgentTask() bool

IsUrgentTask returns if the task is urgent.

func (*AdminTask) SetStatus

func (t *AdminTask) SetStatus(status int8)

SetStatus sets the status of the task.

func (*AdminTask) ToString

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

ToString returns the string format of the task.

type AppendExtentKeyRequest

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

AppendExtentKeyRequest defines the request to append an extent key.

type BatchInodeGetRequest

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

BatchInodeGetRequest defines the request to get the inode in batch.

type BatchInodeGetResponse

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

BatchInodeGetResponse defines the response to the request of getting the inode in batch.

type ClusterInfo

type ClusterInfo struct {
	Cluster string
	Ip      string
}

ClusterInfo defines the cluster infomation.

type CreateDataPartitionRequest

type CreateDataPartitionRequest struct {
	PartitionType string
	PartitionId   uint64
	PartitionSize int
	VolumeId      string
	IsRandomWrite bool
	Members       []Peer
}

CreateDataPartitionRequest defines the request to create a data partition.

type CreateDataPartitionResponse

type CreateDataPartitionResponse struct {
	PartitionId uint64
	Status      uint8
	Result      string
}

CreateDataPartitionResponse defines the response to the request of creating a data partition.

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"`
}

CreateDentryRequest defines the request to create a dentry.

type CreateInodeRequest

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

CreateInodeRequest defines the request to create an inode.

type CreateInodeResponse

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

CreateInodeResponse defines the response to the request of creating an inode.

type CreateMetaPartitionRequest

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

CreateMetaPartitionRequest defines the request to create a meta partition.

type CreateMetaPartitionResponse

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

CreateMetaPartitionResponse defines the response to the request of creating a meta partition.

type CreateNameSpaceRequest

type CreateNameSpaceRequest struct {
	Name string
}

CreateNameSpaceRequest defines the request to create a name space.

type CreateNameSpaceResponse

type CreateNameSpaceResponse struct {
	Status int
	Result string
}

CreateNameSpaceResponse defines the response to the request of creating a name space.

type DataNodeHeartbeatResponse

type DataNodeHeartbeatResponse struct {
	Total               uint64
	Used                uint64
	Available           uint64
	TotalPartitionSize  uint64 // volCnt * volsize
	RemainingCapacity   uint64 // remaining capacity to create partition
	CreatedPartitionCnt uint32
	MaxCapacity         uint64 // maximum capacity to create partition
	RackName            string
	PartitionReports    []*PartitionReport
	Status              uint8
	Result              string
}

DataNodeHeartbeatResponse defines the response to the data node heartbeat.

type DataPartitionDecommissionRequest

type DataPartitionDecommissionRequest struct {
	PartitionId uint64
	RemovePeer  Peer
	AddPeer     Peer
}

DataPartitionDecommissionRequest defines the request of decommissioning a data partition.

type DataPartitionDecommissionResponse

type DataPartitionDecommissionResponse struct {
	Status      uint8
	Result      string
	PartitionId uint64
}

DataPartitionDecommissionResponse defines the response to the request of decommissioning a data partition.

type DataPartitionResponse

type DataPartitionResponse struct {
	PartitionID uint64
	Status      int8
	ReplicaNum  uint8
	Hosts       []string
	LeaderAddr  string
}

DataPartitionResponse defines the response from a data node to the master that is related to a data partition.

type DataPartitionsView

type DataPartitionsView struct {
	DataPartitions []*DataPartitionResponse
}

DataPartitionsView defines the view of a data partition

func NewDataPartitionsView

func NewDataPartitionsView() (dataPartitionsView *DataPartitionsView)

type DeleteDataPartitionRequest

type DeleteDataPartitionRequest struct {
	DataPartitionType string
	PartitionId       uint64
	PartitionSize     int
}

DeleteDataPartitionRequest defines the request to delete a data partition.

type DeleteDataPartitionResponse

type DeleteDataPartitionResponse struct {
	Status      uint8
	Result      string
	PartitionId uint64
}

DeleteDataPartitionResponse defines the response to the request of deleting a data partition.

type DeleteDentryRequest

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

DeleteDentryRequest define the request tp delete a dentry.

type DeleteDentryResponse

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

DeleteDentryResponse defines the response to the request of deleting a dentry.

type DeleteFileRequest

type DeleteFileRequest struct {
	VolId uint64
	Name  string
}

DeleteFileRequest defines the request to delete a file.

type DeleteFileResponse

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

DeleteFileResponse defines the response to the request of deleting a file.

type DeleteMetaPartitionRequest

type DeleteMetaPartitionRequest struct {
	PartitionID uint64
}

DeleteMetaPartitionRequest defines the request of deleting a meta partition.

type DeleteMetaPartitionResponse

type DeleteMetaPartitionResponse struct {
	PartitionID uint64
	Status      uint8
	Result      string
}

DeleteMetaPartitionResponse defines the response to the request of deleting a meta partition.

type Dentry

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

Dentry defines the dentry struct.

func (Dentry) String

func (d Dentry) String() string

String returns the string format of the dentry.

type EvictInodeRequest

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

EvictInodeRequest defines the request to evict an inode.

type ExtentKey

type ExtentKey struct {
	FileOffset   uint64
	PartitionId  uint64
	ExtentId     uint64
	ExtentOffset uint64
	Size         uint32
	CRC          uint32
}

ExtentKey defines the extent key struct.

func (*ExtentKey) Copy

func (k *ExtentKey) Copy() btree.Item

Marshal marshals the extent key.

func (*ExtentKey) GetExtentKey

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

TODO remove

func (*ExtentKey) Less

func (k *ExtentKey) Less(than btree.Item) bool

Less defines the less comparator.

func (*ExtentKey) Marshal

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

func (*ExtentKey) MarshalBinary

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

MarshalBinary marshals the binary format of the extent key.

func (ExtentKey) String

func (k ExtentKey) String() string

String returns the string format of the extentKey.

func (*ExtentKey) UnMarshal

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

TODO remove

func (*ExtentKey) UnmarshalBinary

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

UnmarshalBinary unmarshals the binary format of the extent key.

type File

type File struct {
	Name     string
	Crc      uint32
	Size     uint32
	Modified int64
}

File defines the file struct.

type GetExtentsRequest

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

GetExtentsRequest defines the reques to get extents.

type GetExtentsResponse

type GetExtentsResponse struct {
	Generation uint64      `json:"gen"`
	Size       uint64      `json:"sz"`
	Extents    []ExtentKey `json:"eks"`
}

GetExtentsResponse defines the response to the request of getting extents.

type HTTPReply

type HTTPReply struct {
	Code int32       `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

HTTPReply uniform response structure

type HeartBeatRequest

type HeartBeatRequest struct {
	CurrTime   int64
	MasterAddr string
}

HeartBeatRequest define the heartbeat request.

type InodeGetRequest

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

InodeGetRequest defines the request to get the inode.

type InodeGetResponse

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

InodeGetResponse defines the response to the InodeGetRequest.

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"`
}

InodeInfo defines the inode struct.

func (*InodeInfo) String

func (info *InodeInfo) String() string

String returns the string format of the inode.

type LinkInodeRequest

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

LinkInodeRequest defines the request to link an inode.

type LinkInodeResponse

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

LinkInodeResponse defines the response to the request of linking an inode.

type LoadDataPartitionRequest

type LoadDataPartitionRequest struct {
	PartitionId uint64
}

LoadDataPartitionRequest defines the request of loading a data partition.

type LoadDataPartitionResponse

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

LoadDataPartitionResponse defines the response to the request of loading a data partition.

type LoadMetaPartitionMetricRequest

type LoadMetaPartitionMetricRequest struct {
	PartitionID uint64
	Start       uint64
	End         uint64
}

LoadMetaPartitionMetricRequest defines the request of loading the meta partition metrics.

type LoadMetaPartitionMetricResponse

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

LoadMetaPartitionMetricResponse defines the response to the request of loading the meta partition metrics.

type LookupRequest

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

LookupRequest defines the request for lookup.

type LookupResponse

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

LookupResponse defines the response for the loopup request.

type MetaNodeHeartbeatResponse

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

MetaNodeHeartbeatResponse defines the response to the meta node heartbeat request.

type MetaPartitionDecommissionRequest

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

MetaPartitionDecommissionRequest defines the request of decommissioning a meta partition.

type MetaPartitionDecommissionResponse

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

MetaPartitionDecommissionResponse defines the response to the request of decommissioning a meta partition.

type MetaPartitionLoadRequest

type MetaPartitionLoadRequest struct {
	PartitionID uint64
}

MetaPartitionLoadRequest defines the request to load meta partition.

type MetaPartitionLoadResponse

type MetaPartitionLoadResponse struct {
	PartitionID uint64
	DoCompare   bool
	ApplyID     uint64
	InodeSign   uint32
	DentrySign  uint32
	Addr        string
}

MetaPartitionLoadResponse defines the response to the request of loading meta partition.

type MetaPartitionReport

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

MetaPartitionReport defines the meta partition report.

type MetaPartitionView

type MetaPartitionView struct {
	PartitionID uint64
	Start       uint64
	End         uint64
	Members     []string
	LeaderAddr  string
	Status      int8
}

MetaPartitionView defines the view of a meta partition

func NewMetaPartitionView

func NewMetaPartitionView(partitionID, start, end uint64, status int8) (mpView *MetaPartitionView)

type Packet

type Packet struct {
	Magic              uint8
	ExtentType         uint8
	Opcode             uint8
	ResultCode         uint8
	RemainingFollowers uint8
	CRC                uint32
	Size               uint32
	ArgLen             uint32
	KernelOffset       uint64
	PartitionID        uint64
	ExtentID           uint64
	ExtentOffset       int64
	ReqID              int64
	Arg                []byte // for create or append ops, the data contains the address
	Data               []byte
	StartT             int64
	// contains filtered or unexported fields
}

Packet defines the packet structure.

func NewPacket

func NewPacket() *Packet

NewPacket returns a new packet.

func NewPacketReqID

func NewPacketReqID() *Packet

NewPacketReqID returns a new packet with ReqID assigned.

func (*Packet) GetOpMsg

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

GetOpMsg returns the operation type.

func (*Packet) GetReqID

func (p *Packet) GetReqID() int64

func (*Packet) GetResultMsg

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

GetResultMsg returns the result message.

func (*Packet) GetStoreType

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

GetStoreType returns the store type.

func (*Packet) GetUniqueLogId

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

GetUniqueLogId returns the unique log ID.

func (*Packet) IsForwardPkt

func (p *Packet) IsForwardPkt() bool

IsForwardPkt returns if the packet is the forward packet (a packet that will be forwarded to the followers).

func (*Packet) LogMessage

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

LogMessage logs the given message.

func (*Packet) MarshalData

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

MarshalData marshals the packet data.

func (*Packet) MarshalHeader

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

MarshalHeader marshals the packet header.

func (*Packet) PacketErrorWithBody

func (p *Packet) PacketErrorWithBody(code uint8, reply []byte)

PacketErrorWithBody sets the packet with error code whose body is filled with the given data.

func (*Packet) PacketOkReply

func (p *Packet) PacketOkReply()

PacketOkReply sets the result code as OpOk, and sets the body as empty.

func (*Packet) PacketOkWithBody

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

PacketOkWithBody sets the result code as OpOk, and sets the body with the give data.

func (*Packet) ReadFromConn

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

ReadFromConn reads the data from the given connection.

func (*Packet) ShouldRetry

func (p *Packet) ShouldRetry() bool

ShallRetry returns if we should retry the packet.

func (*Packet) String

func (p *Packet) String() string

func (*Packet) UnmarshalData

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

UnmarshalData unmarshals the packet data.

func (*Packet) UnmarshalHeader

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

UnmarshalHeader unmarshals the packet header.

func (*Packet) WriteToConn

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

WriteToConn writes through the given connection.

func (*Packet) WriteToNoDeadLineConn

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

WriteToNoDeadLineConn writes through the connection without deadline.

type PartitionReport

type PartitionReport struct {
	VolName         string
	PartitionID     uint64
	PartitionStatus int
	Total           uint64
	Used            uint64
	DiskPath        string
	IsLeader        bool
	ExtentCount     int
	NeedCompare     bool
}

PartitionReport defines the partition report.

type Peer

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

Peer defines the peer of the node id and address.

type ReadDirRequest

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

ReadDirRequest defines the request to read dir.

type ReadDirResponse

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

ReadDirResponse defines the response to the request of reading dir.

type RegisterMetaNodeResp

type RegisterMetaNodeResp struct {
	ID uint64
}

RegisterMetaNodeResp defines the response to register a meta node.

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"`
}

SetAttrRequest defines the request to set attribute.

type SimpleVolView

type SimpleVolView struct {
	ID           uint64
	Name         string
	Owner        string
	DpReplicaNum uint8
	MpReplicaNum uint8
	Status       uint8
	Capacity     uint64 // GB
	RwDpCnt      int
	MpCnt        int
	DpCnt        int
}

SimpleVolView defines the simple view of a volume

type TinyExtentDeleteRecord

type TinyExtentDeleteRecord struct {
	FileOffset           uint64
	PartitionId          uint64
	ExtentId             uint64
	ExtentOffset         uint64
	Size                 uint32
	CRC                  uint32
	TinyDeleteFileOffset int64
}

type TruncateRequest

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

TruncateRequest defines the request to truncate.

type UnlinkInodeRequest

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

UnlinkInodeRequest defines the request to unlink an inode.

type UnlinkInodeResponse

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

UnlinkInodeResponse defines the response to the request of unlinking an inode.

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
}

UpdateDentryRequest defines the request to update a dentry.

type UpdateDentryResponse

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

UpdateDentryResponse defines the response to the request of updating a dentry.

type UpdateMetaPartitionRequest

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

UpdateMetaPartitionRequest defines the request to update a meta partition.

type UpdateMetaPartitionResponse

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

UpdateMetaPartitionResponse defines the response to the request of updating the meta partition.

type VolStatInfo

type VolStatInfo struct {
	Name      string
	TotalSize uint64
	UsedSize  uint64
}

VolStatInfo defines the statistics related to a volume

type VolView

type VolView struct {
	Name           string
	Status         uint8
	MetaPartitions []*MetaPartitionView
	DataPartitions []*DataPartitionResponse
}

VolView defines the view of a volume

func NewVolView

func NewVolView(name string, status uint8) (view *VolView)

Jump to

Keyboard shortcuts

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