disk

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

Documentation

Index

Constants

View Source
const (
	MaxChunkSize    = int64(1024 << 30) // 1024 GiB
	RandomIntervalS = 30
)
View Source
const (
	DefaultSetCompactingCnt = 5
)

Variables

View Source
var (
	ErrVuidSpaceKeyPrefix = errors.New("disk: vuid space prefix key error")
	ErrStopped            = errors.New("disk: closed")
)
View Source
var DiskStatMetric = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Namespace: "blobstore",
		Subsystem: "blobnode",
		Name:      "disk_stat",
		Help:      "blobnode disk stat",
	},
	[]string{"cluster_id", "idc", "rack", "host", "disk_id", "item"},
)

Functions

func GenChunkKey

func GenChunkKey(id bnapi.ChunkId) string

func GenDiskKey

func GenDiskKey(id string) string

func GenVuidSpaceKey

func GenVuidSpaceKey(vuid proto.Vuid) string

Types

type DiskStorage

type DiskStorage struct {
	DiskID proto.DiskID

	Lock       sync.RWMutex
	SuperBlock *SuperBlock
	Chunks     map[proto.Vuid]core.ChunkAPI

	// conf
	Conf     *core.Config
	DataPath string
	MetaPath string

	// limiter
	ChunkLimitPerKey limit.Limiter

	// hook fn
	OnClosed func()

	CreateAt     int64
	LastUpdateAt int64
	// contains filtered or unexported fields
}

func (*DiskStorage) Close

func (ds *DiskStorage) Close(ctx context.Context)

func (*DiskStorage) CompactChunkInternal

func (ds *DiskStorage) CompactChunkInternal(ctx context.Context, vuid proto.Vuid) (err error)

func (*DiskStorage) DiskInfo

func (ds *DiskStorage) DiskInfo() (info bnapi.DiskInfo)

func (*DiskStorage) EnqueueCompact

func (ds *DiskStorage) EnqueueCompact(ctx context.Context, vuid proto.Vuid)

func (*DiskStorage) ExecCompactChunk

func (ds *DiskStorage) ExecCompactChunk(vuid proto.Vuid) (err error)

func (*DiskStorage) GcRubbishChunk

func (ds *DiskStorage) GcRubbishChunk(ctx context.Context) (
	mayBeLost []bnapi.ChunkId, err error,
)

func (*DiskStorage) GetChunkStorage

func (ds *DiskStorage) GetChunkStorage(vuid proto.Vuid) (cs core.ChunkAPI, found bool)

func (*DiskStorage) GetConfig

func (ds *DiskStorage) GetConfig() (config *core.Config)

func (*DiskStorage) GetDataPath

func (ds *DiskStorage) GetDataPath() (path string)

func (*DiskStorage) GetIoQos

func (ds *DiskStorage) GetIoQos() (ioQos qos.Qos)

func (*DiskStorage) GetMetaPath

func (ds *DiskStorage) GetMetaPath() (path string)

func (*DiskStorage) ID

func (ds *DiskStorage) ID() (id proto.DiskID)

func (*DiskStorage) IsRegister

func (ds *DiskStorage) IsRegister() bool

func (*DiskStorage) ListChunks

func (ds *DiskStorage) ListChunks(ctx context.Context) (chunks []core.VuidMeta, err error)

func (*DiskStorage) LoadDiskInfo

func (ds *DiskStorage) LoadDiskInfo(ctx context.Context) (dm core.DiskMeta, err error)

func (*DiskStorage) ReleaseChunk

func (ds *DiskStorage) ReleaseChunk(ctx context.Context, vuid proto.Vuid, force bool) (err error)

func (*DiskStorage) ResetChunks

func (ds *DiskStorage) ResetChunks(ctx context.Context)

func (*DiskStorage) SetStatus

func (ds *DiskStorage) SetStatus(status proto.DiskStatus)

func (*DiskStorage) Stats

func (ds *DiskStorage) Stats() (stat core.DiskStats)

func (*DiskStorage) Status

func (ds *DiskStorage) Status() (status proto.DiskStatus)

func (*DiskStorage) UpdateChunkCompactState

func (ds *DiskStorage) UpdateChunkCompactState(ctx context.Context, vuid proto.Vuid, compacting bool) (
	err error,
)

func (*DiskStorage) UpdateChunkStatus

func (ds *DiskStorage) UpdateChunkStatus(ctx context.Context, vuid proto.Vuid, status bnapi.ChunkStatus) (err error)

* chunk status changing must call this method * first: change persistence status * second: change status in memory * concurrency safety: only allows serial execution for the same vuid

func (*DiskStorage) UpdateDiskStatus

func (ds *DiskStorage) UpdateDiskStatus(ctx context.Context, status proto.DiskStatus) (err error)

func (*DiskStorage) WalkChunksWithLock

func (ds *DiskStorage) WalkChunksWithLock(ctx context.Context, walkFn func(cs core.ChunkAPI) error) (err error)

type DiskStorageWrapper

type DiskStorageWrapper struct {
	*DiskStorage
}

func NewDiskStorage

func NewDiskStorage(ctx context.Context, conf core.Config) (dsw *DiskStorageWrapper, err error)

func (*DiskStorageWrapper) CreateChunk

func (dsw *DiskStorageWrapper) CreateChunk(ctx context.Context, vuid proto.Vuid, chunksize int64) (
	cs core.ChunkAPI, err error)

* 1. Create a new chunk * 2. bind it to vuid

func (*DiskStorageWrapper) RestoreChunkStorage

func (dsw *DiskStorageWrapper) RestoreChunkStorage(ctx context.Context) (err error)

type SuperBlock

type SuperBlock struct {
	// contains filtered or unexported fields
}

func NewSuperBlock

func NewSuperBlock(dirpath string, conf *core.Config) (s *SuperBlock, err error)

func (*SuperBlock) BindVuidChunk

func (s *SuperBlock) BindVuidChunk(ctx context.Context, vuid proto.Vuid, id bnapi.ChunkId) (err error)

func (*SuperBlock) CleanChunkSpace

func (s *SuperBlock) CleanChunkSpace(ctx context.Context, id bnapi.ChunkId) (err error)

func (*SuperBlock) Close

func (s *SuperBlock) Close(ctx context.Context) error

func (*SuperBlock) DeleteChunk

func (s *SuperBlock) DeleteChunk(ctx context.Context, id bnapi.ChunkId) (err error)

func (*SuperBlock) ListChunks

func (s *SuperBlock) ListChunks(ctx context.Context) (chunks map[bnapi.ChunkId]core.VuidMeta, err error)

func (*SuperBlock) ListVuids

func (s *SuperBlock) ListVuids(ctx context.Context) (vuids map[proto.Vuid]bnapi.ChunkId, err error)

func (*SuperBlock) LoadDiskInfo

func (s *SuperBlock) LoadDiskInfo(ctx context.Context) (dm core.DiskMeta, err error)

func (*SuperBlock) ReadChunk

func (s *SuperBlock) ReadChunk(ctx context.Context, id bnapi.ChunkId) (vm core.VuidMeta, err error)

func (*SuperBlock) ReadVuidBind

func (s *SuperBlock) ReadVuidBind(ctx context.Context, vuid proto.Vuid) (id bnapi.ChunkId, err error)

func (*SuperBlock) SetHandlerIOError

func (s *SuperBlock) SetHandlerIOError(handleIOError func(err error))

func (*SuperBlock) SetIOStat

func (s *SuperBlock) SetIOStat(stat *flow.IOFlowStat)

func (*SuperBlock) UnbindVuidChunk

func (s *SuperBlock) UnbindVuidChunk(ctx context.Context, vuid proto.Vuid, id bnapi.ChunkId) (err error)

func (*SuperBlock) UpsertChunk

func (s *SuperBlock) UpsertChunk(ctx context.Context, id bnapi.ChunkId, vm core.VuidMeta) (err error)

func (*SuperBlock) UpsertDisk

func (s *SuperBlock) UpsertDisk(ctx context.Context, diskid proto.DiskID, dm core.DiskMeta) (err error)

Jump to

Keyboard shortcuts

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