diskmgr

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: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperTypeAddDisk = iota + 1
	OperTypeSetDiskStatus
	OperTypeDroppingDisk
	OperTypeDroppedDisk
	OperTypeHeartbeatDiskInfo
	OperTypeSwitchReadonly
	OperTypeAdminUpdateDisk
)
View Source
const (
	DiskIDScopeName = "diskid"
)

Variables

View Source
var (
	ErrDiskExist                 = errors.New("disk already exist")
	ErrDiskNotExist              = errors.New("disk not exist")
	ErrNoEnoughSpace             = errors.New("no enough space to alloc")
	ErrBlobNodeCreateChunkFailed = errors.New("blob node create chunk failed")
)

Functions

This section is empty.

Types

type AllocPolicy

type AllocPolicy struct {
	Idc      string
	Vuids    []proto.Vuid
	Excludes []proto.DiskID
}

type DiskMgr

type DiskMgr struct {
	DiskMgrConfig
	// contains filtered or unexported fields
}

func New

func New(scopeMgr scopemgr.ScopeMgrAPI, db *normaldb.NormalDB, cfg DiskMgrConfig) (*DiskMgr, error)

func (*DiskMgr) AllocChunks

func (d *DiskMgr) AllocChunks(ctx context.Context, policy *AllocPolicy) (ret []proto.DiskID, err error)

AllocChunk return available chunks in data center

func (*DiskMgr) AllocDiskID

func (d *DiskMgr) AllocDiskID(ctx context.Context) (proto.DiskID, error)

func (*DiskMgr) Apply

func (d *DiskMgr) Apply(ctx context.Context, operTypes []int32, datas [][]byte, contexts []base.ProposeContext) error

func (*DiskMgr) CheckDiskInfoDuplicated

func (d *DiskMgr) CheckDiskInfoDuplicated(ctx context.Context, info *blobnode.DiskInfo) bool

func (*DiskMgr) Close

func (d *DiskMgr) Close()

func (*DiskMgr) Flush

func (d *DiskMgr) Flush(ctx context.Context) error

Flush will flush disks heartbeat info into rocksdb

func (*DiskMgr) GetDiskInfo

func (d *DiskMgr) GetDiskInfo(ctx context.Context, id proto.DiskID) (*blobnode.DiskInfo, error)

func (*DiskMgr) GetHeartbeatChangeDisks

func (d *DiskMgr) GetHeartbeatChangeDisks() []HeartbeatEvent

func (*DiskMgr) GetModuleName

func (d *DiskMgr) GetModuleName() string

func (*DiskMgr) IsDiskWritable

func (d *DiskMgr) IsDiskWritable(ctx context.Context, id proto.DiskID) (bool, error)

func (*DiskMgr) IsDroppingDisk

func (d *DiskMgr) IsDroppingDisk(ctx context.Context, id proto.DiskID) (bool, error)

func (*DiskMgr) IsFrequentHeatBeat

func (d *DiskMgr) IsFrequentHeatBeat(id proto.DiskID, HeartbeatNotifyIntervalS int) (bool, error)

judge disk heartbeat interval whether small than HeartbeatNotifyIntervalS

func (*DiskMgr) ListDiskInfo

ListDiskInfo return disk info with specified query condition

func (*DiskMgr) ListDroppingDisk

func (d *DiskMgr) ListDroppingDisk(ctx context.Context) ([]*blobnode.DiskInfo, error)

func (*DiskMgr) LoadData

func (d *DiskMgr) LoadData(ctx context.Context) error

func (*DiskMgr) NotifyLeaderChange

func (d *DiskMgr) NotifyLeaderChange(ctx context.Context, leader uint64, host string)

DiskMgr do nothing when leader change

func (*DiskMgr) RefreshExpireTime

func (d *DiskMgr) RefreshExpireTime()

func (*DiskMgr) Report

func (d *DiskMgr) Report(ctx context.Context, region string, clusterID proto.ClusterID, isLeader string)

func (*DiskMgr) SetModuleName

func (d *DiskMgr) SetModuleName(module string)

func (*DiskMgr) SetStatus

func (d *DiskMgr) SetStatus(ctx context.Context, id proto.DiskID, status proto.DiskStatus, isCommit bool) error

func (*DiskMgr) Stat

Stat return disk statistic info of a cluster

func (*DiskMgr) SwitchReadonly

func (d *DiskMgr) SwitchReadonly(diskID proto.DiskID, readonly bool) error

SwitchReadonly can switch disk's readonly or writable

type DiskMgrAPI

type DiskMgrAPI interface {
	// AllocDiskID return a unused disk id
	AllocDiskID(ctx context.Context) (proto.DiskID, error)
	// GetDiskInfo return disk info, it return ErrDiskNotFound if disk not found
	GetDiskInfo(ctx context.Context, id proto.DiskID) (*blobnode.DiskInfo, error)
	// CheckDiskInfoDuplicated return true if disk info already exit, like host and path duplicated
	CheckDiskInfoDuplicated(ctx context.Context, info *blobnode.DiskInfo) bool
	// IsDiskWritable judge disk if writable, disk status unmoral or readonly or heartbeat timeout will return true
	IsDiskWritable(ctx context.Context, id proto.DiskID) (bool, error)
	// SetStatus change disk status, in some case, change status is not allow
	// like change repairing/repaired/dropped into normal
	SetStatus(ctx context.Context, id proto.DiskID, status proto.DiskStatus, isCommit bool) error
	// IsDroppingDisk return true if the specified disk is dropping
	IsDroppingDisk(ctx context.Context, id proto.DiskID) (bool, error)
	// ListDroppingDisk return all dropping disk info
	ListDroppingDisk(ctx context.Context) ([]*blobnode.DiskInfo, error)
	// AllocChunk return available chunks in data center
	AllocChunks(ctx context.Context, policy *AllocPolicy) ([]proto.DiskID, error)
	// ListDiskInfo
	ListDiskInfo(ctx context.Context, opt *clustermgr.ListOptionArgs) (*clustermgr.ListDiskRet, error)
	// Stat return disk statistic info of a cluster
	Stat(ctx context.Context) *clustermgr.SpaceStatInfo
	// SwitchReadonly can switch disk's readonly or writable
	SwitchReadonly(diskID proto.DiskID, readonly bool) error
	// GetHeartbeatChangeDisks return any heartbeat change disks
	GetHeartbeatChangeDisks() []HeartbeatEvent
}

type DiskMgrConfig

type DiskMgrConfig struct {
	RefreshIntervalS         int             `json:"refresh_interval_s"`
	RackAware                bool            `json:"rack_aware"`
	HostAware                bool            `json:"host_aware"`
	HeartbeatExpireIntervalS int             `json:"heartbeat_expire_interval_s"`
	FlushIntervalS           int             `json:"flush_interval_s"`
	ApplyConcurrency         uint32          `json:"apply_concurrency"`
	BlobNodeConfig           blobnode.Config `json:"blob_node_config"`
	AllocTolerateBuffer      int64           `json:"alloc_tolerate_buffer"`
	EnsureIndex              bool            `json:"ensure_index"`

	IDC       []string            `json:"-"`
	CodeModes []codemode.CodeMode `json:"-"`
	ChunkSize int64               `json:"-"`
}

type HeartbeatEvent

type HeartbeatEvent struct {
	DiskID  proto.DiskID
	IsAlive bool
}

Jump to

Keyboard shortcuts

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