shard

package
v0.28.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: GPL-3.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEndOfListing = meta.ErrEndOfListing

ErrEndOfListing is returned from object listing with cursor when storage can't return any more objects after provided cursor. Use nil cursor object to start listing again.

View Source
var ErrInvalidMagic = errors.New("invalid magic")

ErrInvalidMagic is returned when dump format is invalid.

View Source
var ErrMustBeReadOnly = errors.New("shard must be in read-only mode")
View Source
var ErrReadOnlyMode = errors.New("shard is in read-only mode")

ErrReadOnlyMode is returned when it is impossible to apply operation that changes shard's memory due to the "read-only" shard's mode.

Functions

func ContainerSize added in v0.15.0

func ContainerSize(s *Shard, cnr cid.ID) (uint64, error)

func IsErrNotFound added in v0.28.0

func IsErrNotFound(err error) bool

IsErrNotFound checks if error returned by Shard Get/Head/GetRange method corresponds to missing object.

func IsErrRemoved added in v0.28.0

func IsErrRemoved(err error) bool

IsErrRemoved checks if error returned by Shard Exists/Get/Head/GetRange method corresponds to removed object.

func ListContainers added in v0.15.0

func ListContainers(s *Shard) ([]cid.ID, error)

Types

type ContainerSizePrm added in v0.15.0

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

func (*ContainerSizePrm) WithContainerID added in v0.15.0

func (p *ContainerSizePrm) WithContainerID(cnr cid.ID)

type ContainerSizeRes added in v0.15.0

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

func (ContainerSizeRes) Size added in v0.15.0

func (r ContainerSizeRes) Size() uint64

type Cursor added in v0.27.0

type Cursor = meta.Cursor

Cursor is a type for continuous object listing.

func ListWithCursor added in v0.27.0

func ListWithCursor(s *Shard, count uint32, cursor *Cursor) ([]oid.Address, *Cursor, error)

ListWithCursor lists physical objects available in shard starting from cursor. Includes regular, tombstone and storage group objects. Does not include inhumed objects. Use cursor value from response for consecutive requests.

Returns ErrEndOfListing if there are no more objects to return or count parameter set to zero.

type DeletePrm

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

DeletePrm groups the parameters of Delete operation.

func (*DeletePrm) WithAddresses

func (p *DeletePrm) WithAddresses(addr ...oid.Address)

WithAddresses is a Delete option to set the addresses of the objects to delete.

Option is required.

type DeleteRes

type DeleteRes struct{}

DeleteRes groups the resulting values of Delete operation.

type DumpPrm added in v0.27.5

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

DumpPrm groups the parameters of Dump operation.

func (*DumpPrm) WithIgnoreErrors added in v0.27.5

func (p *DumpPrm) WithIgnoreErrors(ignore bool)

WithIgnoreErrors is an Dump option to allow ignore all errors during iteration. This includes invalid blobovniczas as well as corrupted objects.

func (*DumpPrm) WithPath added in v0.27.5

func (p *DumpPrm) WithPath(path string)

WithPath is an Dump option to set the destination path.

func (*DumpPrm) WithStream added in v0.27.5

func (p *DumpPrm) WithStream(r io.Writer)

WithStream is an Dump option to set the destination stream. It takes priority over `path` option.

type DumpRes added in v0.27.5

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

DumpRes groups the result fields of Dump operation.

func (DumpRes) Count added in v0.27.5

func (r DumpRes) Count() int

Count return amount of object written.

type Event added in v0.16.0

type Event interface {
	// contains filtered or unexported methods
}

Event represents class of external events.

func EventNewEpoch added in v0.16.0

func EventNewEpoch(e uint64) Event

EventNewEpoch returns new epoch event.

type ExistsPrm

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

ExistsPrm groups the parameters of Exists operation.

func (*ExistsPrm) WithAddress

func (p *ExistsPrm) WithAddress(addr oid.Address) *ExistsPrm

WithAddress is an Exists option to set object checked for existence.

type ExistsRes

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

ExistsRes groups the resulting values of Exists operation.

func (ExistsRes) Exists

func (p ExistsRes) Exists() bool

Exists returns the fact that the object is in the shard.

type ExpiredObjectsCallback added in v0.16.0

type ExpiredObjectsCallback func(context.Context, []oid.Address)

ExpiredObjectsCallback is a callback handling list of expired objects.

type ExpiredTombstonesCallback added in v0.28.0

type ExpiredTombstonesCallback func(context.Context, []meta.TombstonedObject)

ExpiredTombstonesCallback is a callback handling list of expired tombstones.

type GetPrm

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

GetPrm groups the parameters of Get operation.

func (*GetPrm) WithAddress

func (p *GetPrm) WithAddress(addr oid.Address)

WithAddress is a Get option to set the address of the requested object.

Option is required.

func (*GetPrm) WithIgnoreMeta added in v0.27.6

func (p *GetPrm) WithIgnoreMeta(ignore bool)

WithIgnoreMeta is a Get option try to fetch object from blobstor directly, without accessing metabase.

type GetRes

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

GetRes groups the resulting values of Get operation.

func (GetRes) HasMeta added in v0.27.6

func (r GetRes) HasMeta() bool

HasMeta returns true if info about the object was found in the metabase.

func (GetRes) Object

func (r GetRes) Object() *objectSDK.Object

Object returns the requested object.

type HeadPrm

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

HeadPrm groups the parameters of Head operation.

func (*HeadPrm) WithAddress

func (p *HeadPrm) WithAddress(addr oid.Address)

WithAddress is a Head option to set the address of the requested object.

Option is required.

func (*HeadPrm) WithRaw

func (p *HeadPrm) WithRaw(raw bool)

WithRaw is a Head option to set raw flag value. If flag is unset, then Head returns header of virtual object, otherwise it returns SplitInfo of virtual object.

type HeadRes

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

HeadRes groups the resulting values of Head operation.

func (HeadRes) Object

func (r HeadRes) Object() *objectSDK.Object

Object returns the requested object header.

type ID

type ID []byte

ID represents Shard identifier.

Each shard should have the unique ID within a single instance of local storage.

func NewIDFromBytes

func NewIDFromBytes(v []byte) *ID

NewIDFromBytes constructs ID from byte slice.

func (ID) String

func (id ID) String() string

type Info

type Info struct {
	// Identifier of the shard.
	ID *ID

	// Shard mode.
	Mode Mode

	// Information about the metabase.
	MetaBaseInfo meta.Info

	// Information about the BLOB storage.
	BlobStorInfo blobstor.Info

	// Information about the Write Cache.
	WriteCacheInfo writecache.Info

	// Weight parameters of the shard.
	WeightValues WeightValues

	// ErrorCount contains amount of errors occurred in shard operations.
	ErrorCount uint32
}

Info groups the information about Shard.

type InhumePrm

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

InhumePrm encapsulates parameters for inhume operation.

func (*InhumePrm) MarkAsGarbage added in v0.16.0

func (p *InhumePrm) MarkAsGarbage(addr ...oid.Address)

MarkAsGarbage marks object to be physically removed from shard.

Should not be called along with WithTarget.

func (*InhumePrm) WithTarget

func (p *InhumePrm) WithTarget(tombstone oid.Address, addrs ...oid.Address)

WithTarget sets a list of objects that should be inhumed and tombstone address as the reason for inhume operation.

tombstone should not be nil, addr should not be empty. Should not be called along with MarkAsGarbage.

type InhumeRes

type InhumeRes struct{}

InhumeRes encapsulates results of inhume operation.

type ListContainersPrm added in v0.15.0

type ListContainersPrm struct{}

type ListContainersRes added in v0.15.0

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

func (ListContainersRes) Containers added in v0.15.0

func (r ListContainersRes) Containers() []cid.ID

type ListWithCursorPrm added in v0.27.0

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

ListWithCursorPrm contains parameters for ListWithCursor operation.

func (*ListWithCursorPrm) WithCount added in v0.27.0

func (p *ListWithCursorPrm) WithCount(count uint32)

WithCount sets maximum amount of addresses that ListWithCursor should return.

func (*ListWithCursorPrm) WithCursor added in v0.27.0

func (p *ListWithCursorPrm) WithCursor(cursor *Cursor)

WithCursor sets cursor for ListWithCursor operation. For initial request, ignore this param or use nil value. For consecutive requests, use value from ListWithCursorRes.

type ListWithCursorRes added in v0.27.0

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

ListWithCursorRes contains values returned from ListWithCursor operation.

func (ListWithCursorRes) AddressList added in v0.27.0

func (r ListWithCursorRes) AddressList() []oid.Address

AddressList returns addresses selected by ListWithCursor operation.

func (ListWithCursorRes) Cursor added in v0.27.0

func (r ListWithCursorRes) Cursor() *Cursor

Cursor returns cursor for consecutive listing requests.

type Mode

type Mode uint32

Mode represents enumeration of Shard work modes.

const (
	// ModeReadWrite is a Mode value for shard that is available
	// for read and write operations. Default shard mode.
	ModeReadWrite Mode = iota

	// ModeReadOnly is a Mode value for shard that does not
	// accept write operation but is readable.
	ModeReadOnly

	// ModeDegraded is a Mode value for shard that is set automatically
	// after a certain number of errors is encountered. It is the same as
	// `ModeReadOnly` but also enables fallback algorithms for getting object
	// in case metabase is corrupted.
	ModeDegraded
)

func (Mode) String

func (m Mode) String() string

type Option

type Option func(*cfg)

Option represents Shard's constructor option.

func WithBlobStorOptions

func WithBlobStorOptions(opts ...blobstor.Option) Option

WithBlobStorOptions returns option to set internal BlobStor options.

func WithExpiredLocksCallback added in v0.28.0

func WithExpiredLocksCallback(cb ExpiredObjectsCallback) Option

WithExpiredLocksCallback returns option to specify callback of the expired LOCK objects handler.

func WithExpiredTombstonesCallback added in v0.28.0

func WithExpiredTombstonesCallback(cb ExpiredTombstonesCallback) Option

WithExpiredTombstonesCallback returns option to specify callback of the expired tombstones handler.

func WithGCEventChannel added in v0.28.0

func WithGCEventChannel(eventChan <-chan Event) Option

WithGCEventChannel returns option to set a GC event channel.

func WithGCRemoverSleepInterval added in v0.16.0

func WithGCRemoverSleepInterval(dur time.Duration) Option

WithGCRemoverSleepInterval returns option to specify sleep interval between object remover executions.

func WithGCWorkerPoolInitializer added in v0.16.0

func WithGCWorkerPoolInitializer(wpInit func(int) util.WorkerPool) Option

WithGCWorkerPoolInitializer returns option to set initializer of worker pool with specified worker number.

func WithID

func WithID(id *ID) Option

WithID returns option to set the default shard identifier.

func WithLogger

func WithLogger(l *logger.Logger) Option

WithLogger returns option to set Shard's logger.

func WithMetaBaseOptions

func WithMetaBaseOptions(opts ...meta.Option) Option

WithMetaBaseOptions returns option to set internal metabase options.

func WithMode added in v0.27.3

func WithMode(v Mode) Option

WithMode returns option to set shard's mode. Mode must be one of the predefined:

  • ModeReadWrite;
  • ModeReadOnly.

func WithRefillMetabase added in v0.25.0

func WithRefillMetabase(v bool) Option

WithRefillMetabase returns option to set flag to refill the Metabase on Shard's initialization step.

func WithRemoverBatchSize added in v0.16.0

func WithRemoverBatchSize(sz int) Option

WithRemoverBatchSize returns option to set batch size of single removal operation.

func WithTombstoneSource added in v0.28.0

func WithTombstoneSource(v TombstoneSource) Option

WithTombstoneSource returns option to set TombstoneSource.

func WithWriteCache

func WithWriteCache(use bool) Option

WithWriteCache returns option to toggle write cache usage.

func WithWriteCacheOptions

func WithWriteCacheOptions(opts ...writecache.Option) Option

WithWriteCacheOptions returns option to set internal write cache options.

type PutPrm

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

PutPrm groups the parameters of Put operation.

func (*PutPrm) WithObject

func (p *PutPrm) WithObject(obj *object.Object)

WithObject is a Put option to set object to save.

type PutRes

type PutRes struct{}

PutRes groups the resulting values of Put operation.

type RestorePrm added in v0.27.5

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

RestorePrm groups the parameters of Restore operation.

func (*RestorePrm) WithIgnoreErrors added in v0.27.5

func (p *RestorePrm) WithIgnoreErrors(ignore bool)

WithIgnoreErrors is a Restore option which allows to ignore errors encountered during restore. Corrupted objects will not be processed.

func (*RestorePrm) WithPath added in v0.27.5

func (p *RestorePrm) WithPath(path string)

WithPath is a Restore option to set the destination path.

func (*RestorePrm) WithStream added in v0.27.5

func (p *RestorePrm) WithStream(r io.Reader)

WithStream is a Restore option to set the stream to read objects from. It takes priority over `WithPath` option.

type RestoreRes added in v0.27.5

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

RestoreRes groups the result fields of Restore operation.

func (RestoreRes) Count added in v0.27.5

func (r RestoreRes) Count() int

Count return amount of object written.

func (RestoreRes) FailCount added in v0.27.5

func (r RestoreRes) FailCount() int

FailCount return amount of object skipped.

type RngPrm

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

RngPrm groups the parameters of GetRange operation.

func (*RngPrm) WithAddress

func (p *RngPrm) WithAddress(addr oid.Address)

WithAddress is a Rng option to set the address of the requested object.

Option is required.

func (*RngPrm) WithIgnoreMeta added in v0.27.6

func (p *RngPrm) WithIgnoreMeta(ignore bool)

WithIgnoreMeta is a Get option try to fetch object from blobstor directly, without accessing metabase.

func (*RngPrm) WithRange

func (p *RngPrm) WithRange(off uint64, ln uint64)

WithRange is a GetRange option to set range of requested payload data.

type RngRes

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

RngRes groups the resulting values of GetRange operation.

func (RngRes) HasMeta added in v0.27.6

func (r RngRes) HasMeta() bool

HasMeta returns true if info about the object was found in the metabase.

func (RngRes) Object

func (r RngRes) Object() *object.Object

Object returns the requested object part.

Instance payload contains the requested range of the original object.

type SelectPrm

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

SelectPrm groups the parameters of Select operation.

func (*SelectPrm) WithContainerID

func (p *SelectPrm) WithContainerID(cnr cid.ID)

WithContainerID is a Select option to set the container id to search in.

func (*SelectPrm) WithFilters

func (p *SelectPrm) WithFilters(fs object.SearchFilters)

WithFilters is a Select option to set the object filters.

type SelectRes

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

SelectRes groups the resulting values of Select operation.

func (SelectRes) AddressList

func (r SelectRes) AddressList() []oid.Address

AddressList returns list of addresses of the selected objects.

type Shard

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

Shard represents single shard of NeoFS Local Storage Engine.

func New

func New(opts ...Option) *Shard

New creates, initializes and returns new Shard instance.

func (*Shard) Close

func (s *Shard) Close() error

Close releases all Shard's components.

func (*Shard) ContainerSize added in v0.15.0

func (s *Shard) ContainerSize(prm ContainerSizePrm) (ContainerSizeRes, error)

func (*Shard) Delete

func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error)

Delete removes data from the shard's writeCache, metaBase and blobStor.

func (*Shard) Dump added in v0.27.5

func (s *Shard) Dump(prm DumpPrm) (DumpRes, error)

Dump dumps all objects from the shard to a file or stream.

Returns any error encountered.

func (*Shard) DumpInfo

func (s *Shard) DumpInfo() Info

DumpInfo returns information about the Shard.

func (*Shard) Exists

func (s *Shard) Exists(prm ExistsPrm) (ExistsRes, error)

Exists checks if object is presented in shard.

Returns any error encountered that does not allow to unambiguously determine the presence of an object.

Returns an error of type apistatus.ObjectAlreadyRemoved if object has been marked as removed.

func (*Shard) Get

func (s *Shard) Get(prm GetPrm) (GetRes, error)

Get reads an object from shard.

Returns any error encountered that did not allow to completely read the object part.

Returns an error of type apistatus.ObjectNotFound if the requested object is missing in shard. Returns an error of type apistatus.ObjectAlreadyRemoved if the requested object has been marked as removed in shard.

func (*Shard) GetMode added in v0.27.3

func (s *Shard) GetMode() Mode

GetMode returns mode of the shard.

func (*Shard) GetRange

func (s *Shard) GetRange(prm RngPrm) (RngRes, error)

GetRange reads part of an object from shard.

Returns any error encountered that did not allow to completely read the object part.

Returns ErrRangeOutOfBounds if the requested object range is out of bounds. Returns an error of type apistatus.ObjectNotFound if the requested object is missing. Returns an error of type apistatus.ObjectAlreadyRemoved if the requested object has been marked as removed in shard.

func (*Shard) HandleExpiredLocks added in v0.28.0

func (s *Shard) HandleExpiredLocks(lockers []oid.Address)

HandleExpiredLocks unlocks all objects which were locked by lockers. If successful, marks lockers themselves as garbage.

func (*Shard) HandleExpiredTombstones added in v0.16.0

func (s *Shard) HandleExpiredTombstones(tss []meta.TombstonedObject)

HandleExpiredTombstones marks tombstones themselves as garbage and clears up corresponding graveyard records.

Does not modify tss.

func (*Shard) Head

func (s *Shard) Head(prm HeadPrm) (HeadRes, error)

Head reads header of the object from the shard.

Returns any error encountered.

Returns an error of type apistatus.ObjectNotFound if object is missing in Shard. Returns an error of type apistatus.ObjectAlreadyRemoved if the requested object has been marked as removed in shard.

func (*Shard) ID

func (s *Shard) ID() *ID

ID returns Shard identifier.

func (*Shard) Inhume

func (s *Shard) Inhume(prm InhumePrm) (InhumeRes, error)

Inhume calls metabase. Inhume method to mark object as removed. It won't be removed physically from blobStor and metabase until `Delete` operation.

Allows inhuming non-locked objects only. Returns apistatus.ObjectLocked if at least one object is locked.

Returns ErrReadOnlyMode error if shard is in "read-only" mode.

func (*Shard) Init

func (s *Shard) Init() error

Init initializes all Shard's components.

func (*Shard) List

func (s *Shard) List() (res SelectRes, err error)

List returns all objects physically stored in the Shard.

func (*Shard) ListContainers added in v0.15.0

func (s *Shard) ListContainers(_ ListContainersPrm) (ListContainersRes, error)

func (*Shard) ListWithCursor added in v0.27.0

func (s *Shard) ListWithCursor(prm ListWithCursorPrm) (ListWithCursorRes, error)

ListWithCursor lists physical objects available in shard starting from cursor. Includes regular, tombstone and storage group objects. Does not include inhumed objects. Use cursor value from response for consecutive requests.

Returns ErrEndOfListing if there are no more objects to return or count parameter set to zero.

func (*Shard) Lock added in v0.28.0

func (s *Shard) Lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error

Lock marks objects as locked with another object. All objects from the specified container.

Allows locking regular objects only (otherwise returns apistatus.LockNonRegularObject).

Locked list should be unique. Panics if it is empty.

func (*Shard) Open

func (s *Shard) Open() error

Open opens all Shard's components.

func (*Shard) Put

func (s *Shard) Put(prm PutPrm) (PutRes, error)

Put saves the object in shard.

Returns any error encountered that did not allow to completely save the object.

Returns ErrReadOnlyMode error if shard is in "read-only" mode.

func (*Shard) Restore added in v0.27.5

func (s *Shard) Restore(prm RestorePrm) (RestoreRes, error)

Restore restores objects from the dump prepared by Dump.

Returns any error encountered.

func (*Shard) Select

func (s *Shard) Select(prm SelectPrm) (SelectRes, error)

Select selects the objects from shard that match select parameters.

Returns any error encountered that did not allow to completely select the objects.

func (*Shard) SetMode

func (s *Shard) SetMode(m Mode) error

SetMode sets mode of the shard.

Returns any error encountered that did not allow setting shard mode.

func (*Shard) ToMoveIt

func (s *Shard) ToMoveIt(prm ToMoveItPrm) (ToMoveItRes, error)

ToMoveIt calls metabase.ToMoveIt method to mark object as relocatable to another shard.

func (*Shard) UpdateID added in v0.27.7

func (s *Shard) UpdateID() (err error)

UpdateID reads shard ID saved in the metabase and updates it if it is missing.

func (*Shard) WeightValues

func (s *Shard) WeightValues() WeightValues

WeightValues returns current weight values of the Shard.

type ToMoveItPrm

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

ToMoveItPrm encapsulates parameters for ToMoveIt operation.

func (*ToMoveItPrm) WithAddress

func (p *ToMoveItPrm) WithAddress(addr oid.Address)

WithAddress sets object address that should be marked to move into another shard.

type ToMoveItRes

type ToMoveItRes struct{}

ToMoveItRes encapsulates results of ToMoveIt operation.

type TombstoneSource added in v0.28.0

type TombstoneSource interface {
	// IsTombstoneAvailable must return boolean value that means
	// provided tombstone's presence in the NeoFS network at the
	// time of the passed epoch.
	IsTombstoneAvailable(ctx context.Context, addr oid.Address, epoch uint64) bool
}

TombstoneSource is an interface that checks tombstone status in the NeoFS network.

type WeightValues

type WeightValues struct {
	// Amount of free disk space. Measured in kilobytes.
	FreeSpace uint64
}

WeightValues groups values of Shard weight parameters.

Jump to

Keyboard shortcuts

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