volumemgr

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

Documentation

Index

Constants

View Source
const (
	OperTypeCreateVolume int32 = iota + 1
	OperTypeAllocVolume
	OperTypeRetainVolume
	OperTypeChangeVolumeStatus
	OperTypeUpdateVolumeUnit
	OperTypeChunkReport
	OperTypeChunkSetCompact
	OperTypeVolumeUnitSetWritable
	OperTypeAllocVolumeUnit
	OperTypeDeleteTask
	OperTypeExpireVolume
	OperTypeAdminUpdateVolume
	OperTypeAdminUpdateVolumeUnit
	OperTypeInitCreateVolume
	OperTypeIncreaseVolumeUnitsEpoch
)
View Source
const (
	IncreaseEpochInterval = 3
)
View Source
const (
	NoDiskLoadThreshold = int(^uint(0) >> 1)
)

Variables

View Source
var (
	VolStatusMetric = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "blobstore",
			Subsystem: "clusterMgr",
			Name:      "vol_status_vol_count",
			Help:      "vol status volume count",
		},
		[]string{"region", "cluster", "status", "is_leader"},
	)
	VolRetainMetric = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "blobstore",
			Subsystem: "clusterMgr",
			Name:      "vol_retain_error",
			Help:      "retain volume token error",
		},
		[]string{"region", "cluster", "is_leader"},
	)
	VolAllocMetric = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "blobstore",
			Subsystem: "clusterMgr",
			Name:      "vol_alloc_over_disk_load",
			Help:      "alloc volume over disk load",
		},
		[]string{"region", "cluster", "is_leader"},
	)
)
View Source
var (
	ErrVolumeNotExist           = apierrors.ErrVolumeNotExist
	ErrVolumeUnitNotExist       = apierrors.ErrVolumeUnitNotExist
	ErrOldVuidNotMatch          = apierrors.ErrOldVuidNotMatch
	ErrNewVuidNotMatch          = apierrors.ErrNewVuidNotMatch
	ErrNewDiskIDNotMatch        = apierrors.ErrNewDiskIDNotMatch
	ErrInvalidCodeMode          = apierrors.ErrInvalidCodeMode
	ErrVolumeNotAlloc           = apierrors.ErrRetainVolumeNotAlloc
	ErrCreateVolumeAlreadyExist = errors.New("create volume already exist")
	ErrInvalidVolume            = errors.New(" volume is invalid ")
	ErrInvalidToken             = errors.New("retain token is invalid")
	ErrRepeatUpdateUnit         = errors.New("repeat update volume unit")
)
View Source
var (
	VolFreeHealthChangeNotifyKey = "freeOrHealthChange"
)

notify queue key definition

Functions

This section is empty.

Types

type AllocVolumeCtx

type AllocVolumeCtx struct {
	Vids               []proto.Vid `json:"vids"`
	Host               string      `json:"host"`
	ExpireTime         int64       `json:"expire_time"`
	PendingAllocVolKey interface{} `json:"pending_alloc_vol_key"`
}

type ChangeVolStatusCtx

type ChangeVolStatusCtx struct {
	Vid      proto.Vid           `json:"vid"`
	TaskID   string              `json:"task_id"`
	TaskType base.VolumeTaskType `json:"type"`
}

type CreateVolumeCtx

type CreateVolumeCtx struct {
	VuInfos []*clustermgr.VolumeUnitInfo `json:"vu_infos"`
	VolInfo clustermgr.VolumeInfoBase    `json:"vol_info"`
	Vid     proto.Vid                    `json:"vid"`
}

func (*CreateVolumeCtx) Decode

func (c *CreateVolumeCtx) Decode(raw []byte) error

func (*CreateVolumeCtx) Encode

func (c *CreateVolumeCtx) Encode() (data []byte, err error)

func (*CreateVolumeCtx) ToVolume

func (c *CreateVolumeCtx) ToVolume(ctx context.Context) (*volume, error)

type DeleteTaskCtx

type DeleteTaskCtx struct {
	Vid      proto.Vid           `json:"vid"`
	TaskType base.VolumeTaskType `json:"type"`
	TaskId   string              `json:"task_id"`
}

type NotifyFunc

type NotifyFunc func(ctx context.Context, vol *volume) error

type VolumeMgr

type VolumeMgr struct {
	VolumeMgrConfig
	// contains filtered or unexported fields
}

volumeMgr implements VolumeMgr interface.

func NewVolumeMgr

func NewVolumeMgr(conf VolumeMgrConfig, diskMgr diskmgr.DiskMgrAPI, scopeMgr scopemgr.ScopeMgrAPI,
	configMgr configmgr.ConfigMgrAPI, volumeDB kvstore.KVStore) (*VolumeMgr, error,
)

NewVolumeMgr constructs a new volume manager.

func (*VolumeMgr) AllocVolume

func (v *VolumeMgr) AllocVolume(ctx context.Context, mode codemode.CodeMode, count int, host string) (ret *cm.AllocatedVolumeInfos, err error)

func (*VolumeMgr) AllocVolumeUnit

func (v *VolumeMgr) AllocVolumeUnit(ctx context.Context, vuid proto.Vuid) (*cmapi.AllocVolumeUnit, error)

func (*VolumeMgr) Apply

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

func (*VolumeMgr) Close

func (v *VolumeMgr) Close()

func (*VolumeMgr) DiskWritableChange

func (v *VolumeMgr) DiskWritableChange(ctx context.Context, diskID proto.DiskID) (err error)

func (*VolumeMgr) Flush

func (v *VolumeMgr) Flush(ctx context.Context) error

Flush will flush memory data into persistent storage

func (*VolumeMgr) GetModuleName

func (v *VolumeMgr) GetModuleName() string

func (*VolumeMgr) GetVolumeInfo

func (v *VolumeMgr) GetVolumeInfo(ctx context.Context, vid proto.Vid) (ret *cm.VolumeInfo, err error)

func (*VolumeMgr) ListAllocatedVolume

func (v *VolumeMgr) ListAllocatedVolume(ctx context.Context, host string, mode codemode.CodeMode) (ret *cm.AllocatedVolumeInfos)

func (*VolumeMgr) ListVolumeInfo

func (v *VolumeMgr) ListVolumeInfo(ctx context.Context, args *cm.ListVolumeArgs) (ret []*cm.VolumeInfo, err error)

func (*VolumeMgr) ListVolumeInfoV2

func (v *VolumeMgr) ListVolumeInfoV2(ctx context.Context, status proto.VolumeStatus) (ret []*cm.VolumeInfo, err error)

func (*VolumeMgr) ListVolumeUnitInfo

func (v *VolumeMgr) ListVolumeUnitInfo(ctx context.Context, args *cmapi.ListVolumeUnitArgs) ([]*cmapi.VolumeUnitInfo, error)

ListVolumeUnitInfo return disk's volume unit infos, it use index-table disk-vuid as index this API is lightly operation, it only call when broken disk or some else, so here is just get data from db

func (*VolumeMgr) LoadData

func (v *VolumeMgr) LoadData(ctx context.Context) error

func (*VolumeMgr) LockVolume

func (v *VolumeMgr) LockVolume(ctx context.Context, vid proto.Vid) error

func (*VolumeMgr) NotifyLeaderChange

func (v *VolumeMgr) NotifyLeaderChange(ctx context.Context, leader uint64, host string)

Switch manager work when leader change

func (*VolumeMgr) PreRetainVolume

func (v *VolumeMgr) PreRetainVolume(ctx context.Context, tokens []string, host string) (ret *cm.RetainVolumes, err error)

func (*VolumeMgr) PreUpdateVolumeUnit

func (v *VolumeMgr) PreUpdateVolumeUnit(ctx context.Context, args *cmapi.UpdateVolumeArgs) (err error)

func (*VolumeMgr) ReleaseVolumeUnit

func (v *VolumeMgr) ReleaseVolumeUnit(ctx context.Context, vuid proto.Vuid, diskID proto.DiskID, force bool) (err error)

ReleaseVolumeUnit release old volumeUnit's old chunk

func (*VolumeMgr) Report

func (v *VolumeMgr) Report(ctx context.Context, region string, clusterID proto.ClusterID)

func (*VolumeMgr) SetModuleName

func (v *VolumeMgr) SetModuleName(module string)

func (*VolumeMgr) SetRaftServer

func (v *VolumeMgr) SetRaftServer(raftServer raftserver.RaftServer)

func (*VolumeMgr) Start

func (v *VolumeMgr) Start()

func (*VolumeMgr) Stat

func (v *VolumeMgr) Stat(ctx context.Context) (stat cm.VolumeStatInfo)

func (*VolumeMgr) UnlockVolume

func (v *VolumeMgr) UnlockVolume(ctx context.Context, vid proto.Vid) error

type VolumeMgrAPI

type VolumeMgrAPI interface {
	// GetVolumeInfo get volume  details info
	GetVolumeInfo(ctx context.Context, vid proto.Vid) (ret *cm.VolumeInfo, err error)

	// ListVolumeInfo list volumes
	ListVolumeInfo(ctx context.Context, args *cm.ListVolumeArgs) (ret []*cm.VolumeInfo, err error)

	// ListVolumeV2 list specified status volumes
	ListVolumeInfoV2(ctx context.Context, status proto.VolumeStatus) (ret []*cm.VolumeInfo, err error)

	// VolumeAlloc alloc volumes
	AllocVolume(ctx context.Context, mode codemode.CodeMode, count int, host string) (ret *cm.AllocatedVolumeInfos, err error)

	// ListAllocatedVolume list allocated volumes
	ListAllocatedVolume(ctx context.Context, host string, mode codemode.CodeMode) (ret *cm.AllocatedVolumeInfos)

	// PreUpdateVolumeUnit update volume
	PreUpdateVolumeUnit(ctx context.Context, args *cm.UpdateVolumeArgs) (err error)

	// PreRetainVolume retain volume
	PreRetainVolume(ctx context.Context, tokens []string, host string) (ret *cm.RetainVolumes, err error)

	// DiskWritableChange call when disk broken or heartbeat timeout or switch readonly, it'll refresh volume's health
	DiskWritableChange(ctx context.Context, diskID proto.DiskID) (err error)

	// AllocVolumeUnit alloc a new chunk to volume unit, it will increase volumeUnit's nextEpoch in memory
	AllocVolumeUnit(ctx context.Context, vuid proto.Vuid) (*cm.AllocVolumeUnit, error)

	// ReleaseVolumeUnit release old volume unit's chunk
	ReleaseVolumeUnit(ctx context.Context, vuid proto.Vuid, diskID proto.DiskID, force bool) (err error)

	// ListVolumeUnitInfo head all volume unit info in the disk
	ListVolumeUnitInfo(ctx context.Context, args *cm.ListVolumeUnitArgs) ([]*cm.VolumeUnitInfo, error)
	LockVolume(ctx context.Context, vid proto.Vid) error
	UnlockVolume(ctx context.Context, vid proto.Vid) error

	// Stat return volume statistic info
	Stat(ctx context.Context) (stat cm.VolumeStatInfo)
}

VolumeMgr defines volume manager interface

type VolumeMgrConfig

type VolumeMgrConfig struct {
	LocalHost      string          `json:"local_host"`
	BlobNodeConfig blobnode.Config `json:"blob_node_config"`
	// volume database path,include volumeTbl vuidTbl tokenTbl indexTbl taskTbl
	VolumeDBPath   string                `json:"volume_db_path"`
	VolumeDBOption kvstore.RocksDBOption `json:"volume_db_option"`
	// retain successful volume add another  retainTimeS second
	RetainTimeS                 int `json:"retain_time_s"`
	RetainThreshold             int `json:"retain_threshold"`
	FlushIntervalS              int `json:"flush_interval_s"`
	CheckExpiredVolumeIntervalS int `json:"check_expired_volume_interval_s"`

	VolumeSliceMapNum            uint32 `json:"volume_slice_map_num"`
	ApplyConcurrency             uint32 `json:"apply_concurrency"`
	MinAllocableVolumeCount      int    `json:"min_allocable_volume_count"`
	AllocatableDiskLoadThreshold int    `json:"allocatable_disk_load_threshold"`
	AllocFactor                  int    `json:"alloc_factor"`
	// the volume free size must big than AllocatableSize can alloc
	AllocatableSize uint64 `json:"allocatable_size"`

	// the volume in Proxy which free size small than FreezeThreshold treat filled
	FreezeThreshold  uint64            `json:"-"`
	IDC              []string          `json:"-"`
	UnavailableIDC   string            `json:"-"`
	ChunkSize        uint64            `json:"-"`
	CodeModePolicies []codemode.Policy `json:"-"`
	Region           string            `json:"-"`
	ClusterID        proto.ClusterID   `json:"-"`
}

VolumeMgrConfig defines volume manager configuration

Jump to

Keyboard shortcuts

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