blobnode

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ReleaseForUser    = "release for user"
	ReleaseForCompact = "release for compact"
)
View Source
const (
	ChunkIdLength = chunkVuidLen + chunkTimestmapLen
)

Chunk ID vuid + timestamp

View Source
const (
	MaxShardSize = math.MaxUint32
)
View Source
const (
	ShardDataInline = 0x80 // 1000 0000
)

Variables

View Source
var (
	ChunkIdEncodeLen = _vuidHexLen + _timestampHexLen + len(delimiter)
)
View Source
var IOtypemap = [...]string{
	"normal",
	"shardRepair",
	"diskRepair",
	"migrate",
	"compact",
	"delete",
	"internal",
	"inspect",
}

Functions

func EncodeChunk

func EncodeChunk(id ChunkId) string

func IsValidChunkId

func IsValidChunkId(id ChunkId) bool

func IsValidChunkStatus

func IsValidChunkStatus(status ChunkStatus) bool

func IsValidDiskID

func IsValidDiskID(id proto.DiskID) bool

func Setiotype

func Setiotype(ctx context.Context, iot IOType) context.Context

Types

type BadShard

type BadShard struct {
	DiskID proto.DiskID
	Vuid   proto.Vuid
	Bid    proto.BlobID
}

type ChangeChunkStatusArgs

type ChangeChunkStatusArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
	Force  bool         `json:"force,omitempty"`
}

type ChunkId

type ChunkId [ChunkIdLength]byte
var InvalidChunkId ChunkId = [ChunkIdLength]byte{}

func DecodeChunk

func DecodeChunk(name string) (id ChunkId, err error)

func NewChunkId

func NewChunkId(vuid proto.Vuid) (chunkId ChunkId)

func (*ChunkId) Marshal

func (c *ChunkId) Marshal() ([]byte, error)

func (ChunkId) MarshalJSON

func (c ChunkId) MarshalJSON() ([]byte, error)

func (ChunkId) String

func (c ChunkId) String() string

func (ChunkId) UnixTime

func (c ChunkId) UnixTime() uint64

func (*ChunkId) Unmarshal

func (c *ChunkId) Unmarshal(data []byte) error

func (*ChunkId) UnmarshalJSON

func (c *ChunkId) UnmarshalJSON(data []byte) (err error)

func (ChunkId) VolumeUnitId

func (c ChunkId) VolumeUnitId() proto.Vuid

type ChunkInfo

type ChunkInfo struct {
	Id         ChunkId      `json:"id"`
	Vuid       proto.Vuid   `json:"vuid"`
	DiskID     proto.DiskID `json:"diskid"`
	Total      uint64       `json:"total"`  // ChunkSize
	Used       uint64       `json:"used"`   // user data size
	Free       uint64       `json:"free"`   // ChunkSize - Used
	Size       uint64       `json:"size"`   // Chunk File Size (logic size)
	Status     ChunkStatus  `json:"status"` // normal、readOnly
	Compacting bool         `json:"compacting"`
}

type ChunkInspectArgs

type ChunkInspectArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
}

type ChunkStatus

type ChunkStatus uint8
const (
	ChunkStatusDefault  ChunkStatus = iota // 0
	ChunkStatusNormal                      // 1
	ChunkStatusReadOnly                    // 2
	ChunkStatusRelease                     // 3
	ChunkNumStatus                         // 4
)

type CompactChunkArgs

type CompactChunkArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
}

type Config

type Config struct {
	rpc.Config
}

type ConfigReloadArgs

type ConfigReloadArgs struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type CreateChunkArgs

type CreateChunkArgs struct {
	DiskID    proto.DiskID `json:"diskid"`
	Vuid      proto.Vuid   `json:"vuid"`
	ChunkSize int64        `json:"chunksize,omitempty"`
}

type DeleteShardArgs

type DeleteShardArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
	Bid    proto.BlobID `json:"bid"`
}

type DiskHeartBeatInfo

type DiskHeartBeatInfo struct {
	DiskID       proto.DiskID `json:"disk_id"`
	Used         int64        `json:"used"`           // disk used space
	Free         int64        `json:"free"`           // remaining free space on the disk
	Size         int64        `json:"size"`           // total physical disk space
	MaxChunkCnt  int64        `json:"max_chunk_cnt"`  // note: maintained by clustermgr
	FreeChunkCnt int64        `json:"free_chunk_cnt"` // note: maintained by clustermgr
	UsedChunkCnt int64        `json:"used_chunk_cnt"` // current number of chunks on the disk
}

type DiskInfo

type DiskInfo struct {
	ClusterID    proto.ClusterID  `json:"cluster_id"`
	Idc          string           `json:"idc"`
	Rack         string           `json:"rack"`
	Host         string           `json:"host"`
	Path         string           `json:"path"`
	Status       proto.DiskStatus `json:"status"` // normal、broken、repairing、repaired、dropped
	Readonly     bool             `json:"readonly"`
	CreateAt     time.Time        `json:"create_time"`
	LastUpdateAt time.Time        `json:"last_update_time"`
	DiskHeartBeatInfo
}

type DiskProbeArgs

type DiskProbeArgs struct {
	Path string `json:"path"`
}

type DiskStatArgs

type DiskStatArgs struct {
	DiskID proto.DiskID `json:"diskid"`
}

type GetShardArgs

type GetShardArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
	Bid    proto.BlobID `json:"bid"`
	Type   IOType       `json:"iotype,omitempty"`
}

type IOType

type IOType uint64
const (
	NormalIO      IOType = iota // From: external: user io: read/write
	ShardRepairIO               // From: external: shard repair
	DiskRepairIO                // From: external: disk repair
	MigrateIO                   // From: external: chunk transfer, drop, manualMigrate
	CompactIO                   // From: internal: chunk compact
	DeleteIO                    // From: external: delete io
	InternalIO                  // From: internal: io, such rubbish clean, batch delete
	InspectIO                   // From: internal: inspect io
	IOTypeMax
)

func Getiotype

func Getiotype(ctx context.Context) IOType

func Task2IOType

func Task2IOType(t proto.TaskType) IOType

func (IOType) IsValid

func (it IOType) IsValid() bool

func (IOType) String

func (it IOType) String() string

type ListChunkArgs

type ListChunkArgs struct {
	DiskID proto.DiskID `json:"diskid"`
}

type ListChunkRet

type ListChunkRet struct {
	ChunkInfos []*ChunkInfo `json:"chunk_infos"`
}

type ListShardsArgs

type ListShardsArgs struct {
	DiskID   proto.DiskID `json:"diskid"`
	Vuid     proto.Vuid   `json:"vuid" `
	StartBid proto.BlobID `json:"startbid"`
	Status   ShardStatus  `json:"status" `
	Count    int          `json:"count" `
}

type ListShardsRet

type ListShardsRet struct {
	ShardInfos []*ShardInfo `json:"shard_infos"`
	Next       proto.BlobID `json:"next"`
}

type PutShardArgs

type PutShardArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
	Bid    proto.BlobID `json:"bid"`
	Size   int64        `json:"size"`
	Type   IOType       `json:"iotype,omitempty"`
	Body   io.Reader    `json:"-"`
}

type PutShardRet

type PutShardRet struct {
	Crc uint32 `json:"crc"`
}

type RangeGetShardArgs

type RangeGetShardArgs struct {
	GetShardArgs
	Offset int64 `json:"offset"`
	Size   int64 `json:"size"`
}

type ShardInfo

type ShardInfo struct {
	Vuid   proto.Vuid   `json:"vuid"`
	Bid    proto.BlobID `json:"bid"`
	Size   int64        `json:"size"`
	Crc    uint32       `json:"crc"`
	Flag   ShardStatus  `json:"flag"` // 1:normal,2:markDelete
	Inline bool         `json:"inline"`
}

type ShardStatus

type ShardStatus uint8
const (
	ShardStatusDefault    ShardStatus = 0x0 // 0 ; 0000
	ShardStatusNormal     ShardStatus = 0x1 // 1 ; 0001
	ShardStatusMarkDelete ShardStatus = 0x2 // 2 ; 0010
)

type StatChunkArgs

type StatChunkArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
}

type StatShardArgs

type StatShardArgs struct {
	DiskID proto.DiskID `json:"diskid"`
	Vuid   proto.Vuid   `json:"vuid"`
	Bid    proto.BlobID `json:"bid"`
}

type StorageAPI

type StorageAPI interface {
	String(ctx context.Context, host string) string
	IsOnline(ctx context.Context, host string) bool
	Close(ctx context.Context, host string) error
	Stat(ctx context.Context, host string) (infos []*DiskInfo, err error)
	DiskInfo(ctx context.Context, host string, args *DiskStatArgs) (di *DiskInfo, err error)

	// chunks
	CreateChunk(ctx context.Context, host string, args *CreateChunkArgs) (err error)
	StatChunk(ctx context.Context, host string, args *StatChunkArgs) (ci *ChunkInfo, err error)
	ReleaseChunk(ctx context.Context, host string, args *ChangeChunkStatusArgs) (err error)
	SetChunkReadonly(ctx context.Context, host string, args *ChangeChunkStatusArgs) (err error)
	SetChunkReadwrite(ctx context.Context, host string, args *ChangeChunkStatusArgs) (err error)
	ListChunks(ctx context.Context, host string, args *ListChunkArgs) (cis []*ChunkInfo, err error)

	// shard
	GetShard(ctx context.Context, host string, args *GetShardArgs) (body io.ReadCloser, shardCrc uint32, err error)
	RangeGetShard(ctx context.Context, host string, args *RangeGetShardArgs) (body io.ReadCloser, shardCrc uint32, err error)
	PutShard(ctx context.Context, host string, args *PutShardArgs) (crc uint32, err error)
	StatShard(ctx context.Context, host string, args *StatShardArgs) (si *ShardInfo, err error)
	MarkDeleteShard(ctx context.Context, host string, args *DeleteShardArgs) (err error)
	DeleteShard(ctx context.Context, host string, args *DeleteShardArgs) (err error)
	ListShards(ctx context.Context, host string, args *ListShardsArgs) (sis []*ShardInfo, next proto.BlobID, err error)

	WorkerAPI
}

func New

func New(cfg *Config) StorageAPI

type WorkerAPI

type WorkerAPI interface {
	RepairShard(ctx context.Context, host string, args *proto.ShardRepairTask) (err error)
	WorkerStats(ctx context.Context, host string) (ret WorkerStats, err error)
}

WorkerAPI woker api on blobnode.

type WorkerStats

type WorkerStats struct {
	CancelCount  string `json:"cancel_count"`
	ReclaimCount string `json:"reclaim_count"`
}

Jump to

Keyboard shortcuts

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