blobovniczatree

package
v0.44.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "blobovnicza"

Type is blobovniczatree storage type used in logs and configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blobovniczas

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

Blobovniczas represents the storage of the "small" objects.

Each object is stored in Blobovnicza's (B-s). B-s are structured in a multilevel directory hierarchy with fixed depth and width (configured by BlobStor).

Example (width = 4, depth = 3):

x===============================x |[0] [1] [2] [3]| | \ / | | \ / | | \ / | | \ / | |[0] [1] [2] [3]| | | / | | | / | | | / | | | / | |[0](F) [1](A) [X] [X]| x===============================x

Elements of the deepest level are B-s. B-s are allocated dynamically. At each moment of the time there is an active B (ex. A), set of already filled B-s (ex. F) and a list of not yet initialized B-s (ex. X). After filling the active B it becomes full, and next B becomes initialized and active.

Active B and some of the full B-s are cached (LRU). All cached B-s are intitialized and opened.

Object is saved as follows:

  1. at each level, according to HRW, the next one is selected and dives into it until we reach the deepest;
  2. at the B-s level object is saved to the active B. If active B is full, next B is opened, initialized and cached. If there is no more X candidates, goto 1 and process next level.

After the object is saved in B, path concatenation is returned in system path format as B identifier (ex. "0/1/1" or "3/2/1").

func NewBlobovniczaTree

func NewBlobovniczaTree(ctx context.Context, opts ...Option) (blz *Blobovniczas)

NewBlobovniczaTree returns new instance of blobovniczas tree.

func (*Blobovniczas) Close

func (b *Blobovniczas) Close() error

Close implements common.Storage.

func (*Blobovniczas) Compressor added in v0.37.0

func (b *Blobovniczas) Compressor() *compression.Config

func (*Blobovniczas) Delete

func (b *Blobovniczas) Delete(ctx context.Context, prm common.DeletePrm) (res common.DeleteRes, err error)

Delete deletes object from blobovnicza tree.

If blobocvnicza ID is specified, only this blobovnicza is processed. Otherwise, all Blobovniczas are processed descending weight.

func (*Blobovniczas) Exists

Exists implements common.Storage.

func (*Blobovniczas) Get

func (b *Blobovniczas) Get(ctx context.Context, prm common.GetPrm) (res common.GetRes, err error)

Get reads object from blobovnicza tree.

If blobocvnicza ID is specified, only this blobovnicza is processed. Otherwise, all Blobovniczas are processed descending weight.

func (*Blobovniczas) GetRange

func (b *Blobovniczas) GetRange(ctx context.Context, prm common.GetRangePrm) (res common.GetRangeRes, err error)

GetRange reads range of object payload data from blobovnicza tree.

If blobocvnicza ID is specified, only this blobovnicza is processed. Otherwise, all Blobovniczas are processed descending weight.

func (*Blobovniczas) Init

func (b *Blobovniczas) Init() error

Init initializes blobovnicza tree.

Should be called exactly once.

func (*Blobovniczas) Iterate

Iterate iterates over all objects in b.

func (*Blobovniczas) ObjectsCount added in v0.39.0

func (b *Blobovniczas) ObjectsCount(ctx context.Context) (uint64, error)

func (*Blobovniczas) Open

func (b *Blobovniczas) Open(mode mode.ComponentMode) error

Open opens blobovnicza tree.

func (*Blobovniczas) Path

func (b *Blobovniczas) Path() string

Path implements common.Storage.

func (*Blobovniczas) Put

Put saves object in the maximum weight blobobnicza.

returns error if could not save object in any blobovnicza.

func (*Blobovniczas) Rebuild added in v0.38.0

func (*Blobovniczas) SetCompressor

func (b *Blobovniczas) SetCompressor(cc *compression.Config)

SetCompressor implements common.Storage.

func (*Blobovniczas) SetParentID added in v0.37.0

func (b *Blobovniczas) SetParentID(parentID string)

func (*Blobovniczas) SetReportErrorFunc

func (b *Blobovniczas) SetReportErrorFunc(f func(string, error))

SetReportErrorFunc implements common.Storage.

func (*Blobovniczas) Type

func (b *Blobovniczas) Type() string

Type implements common.Storage.

type ID added in v0.38.0

type ID []byte

ID represents Blobovnicza identifier.

func NewIDFromBytes added in v0.38.0

func NewIDFromBytes(v []byte) *ID

NewIDFromBytes constructs an ID from a byte slice.

func (ID) Bytes added in v0.38.0

func (id ID) Bytes() []byte

func (ID) Path added in v0.38.0

func (id ID) Path() string

type Metrics added in v0.37.0

type Metrics interface {
	Blobovnicza() blobovnicza.Metrics

	SetParentID(parentID string)

	SetMode(mode.ComponentMode)
	Close()

	SetRebuildStatus(status string)
	ObjectMoved(d time.Duration)
	SetRebuildPercent(value uint32)
	ObjectsCount(d time.Duration, success bool)

	Delete(d time.Duration, success, withStorageID bool)
	Exists(d time.Duration, success, withStorageID bool)
	GetRange(d time.Duration, size int, success, withStorageID bool)
	Get(d time.Duration, size int, success, withStorageID bool)
	Iterate(d time.Duration, success bool)
	Put(d time.Duration, size int, success bool)
}

type Option

type Option func(*cfg)

func WithBlobovniczaShallowDepth

func WithBlobovniczaShallowDepth(depth uint64) Option

func WithBlobovniczaShallowWidth

func WithBlobovniczaShallowWidth(width uint64) Option

func WithBlobovniczaSize

func WithBlobovniczaSize(sz uint64) Option

func WithInitWorkerCount added in v0.38.0

func WithInitWorkerCount(v int) Option

WithInitWorkerCount sets maximum workers count to init blobovnicza tree.

Negative or zero value means no limit.

func WithLogger

func WithLogger(l *logger.Logger) Option

func WithMetrics added in v0.37.0

func WithMetrics(m Metrics) Option

func WithMoveBatchSize added in v0.38.0

func WithMoveBatchSize(v int) Option

func WithObjectSizeLimit

func WithObjectSizeLimit(sz uint64) Option

func WithOpenedCacheExpInterval added in v0.39.0

func WithOpenedCacheExpInterval(expInterval time.Duration) Option

func WithOpenedCacheSize

func WithOpenedCacheSize(sz int) Option

func WithOpenedCacheTTL added in v0.39.0

func WithOpenedCacheTTL(ttl time.Duration) Option

func WithPermissions

func WithPermissions(perm fs.FileMode) Option

func WithRootPath

func WithRootPath(p string) Option

func WithWaitBeforeDropDB added in v0.38.0

func WithWaitBeforeDropDB(t time.Duration) Option

Jump to

Keyboard shortcuts

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