nodestorage

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 41 Imported by: 6

Documentation

Index

Constants

View Source
const (
	IndexStorageName = ".index"
)

Variables

View Source
var (
	ErrUnknownSpaceId  = errors.New("unknown space id")
	ErrNoDeletionLogId = errors.New("no last record id")
)
View Source
var (
	ErrClosed                  = errors.New("space storage closed")
	ErrLocked                  = errors.New("space storage locked")
	ErrArchived                = errors.New("space is archived")
	ErrSpaceIdIsEmpty          = errors.New("space id is empty")
	ErrDoesntSupportSpaceStats = errors.New("doesn't support nodestorage.ObjectSpaceStats")
	ErrDeleted                 = errors.New("space storage deleted")
)

Functions

func CreateTreeStorage added in v0.5.0

func CreateTreeStorage(t *testing.T, storage spacestorage.SpaceStorage, treeLen, changeLen int)

func GenStorage added in v0.5.0

func GenStorage(t *testing.T, ss NodeStorage, treeLen, changeLen int) spacestorage.SpaceStorage

func NewStorageCreatePayload added in v0.5.0

func NewStorageCreatePayload(t *testing.T) spacestorage.SpaceStorageCreatePayload

Types

type ChangeSizeStats added in v0.4.2

type ChangeSizeStats struct {
	MaxLen int     `json:"maxLen"`
	P95    float64 `json:"p95"`
	Avg    float64 `json:"avg"`
	Median float64 `json:"median"`
	Total  int     `json:"total"`
}

type Config

type Config struct {
	Path         string `yaml:"path"`
	AnyStorePath string `yaml:"anyStorePath"`
}

type DiskGen added in v0.13.0

type DiskGen struct {
	// GenId is a random id generated when the storage root was initialized.
	GenId string `json:"genId"`
	// CreatedTime is when the storage root was initialized.
	CreatedTime time.Time `json:"createdTime"`
	// contains filtered or unexported fields
}

DiskGen marks a storage root with a generation id. The marker is created the first time a node starts on the given storage root; its absence on a node that expects to hold data means the disk was replaced (or wiped) and the node must treat all its content as missing rather than deleted.

func (DiskGen) Fresh added in v0.13.0

func (d DiskGen) Fresh() bool

Fresh reports whether the storage root was initialized on this start, i.e. no marker existed before (new node or replaced/wiped disk).

type DoAfterOpenFunc added in v0.9.0

type DoAfterOpenFunc = func(db anystore.DB) error

type DoFunc added in v0.9.0

type DoFunc = func() error

type IndexStorage added in v0.5.0

type IndexStorage interface {
	UpdateHash(ctx context.Context, updates ...SpaceUpdate) (err error)
	ReadHashes(ctx context.Context, iterFunc func(update SpaceUpdate) (bool, error)) (err error)
	ReadSpacesByStatus(ctx context.Context, status SpaceStatus, iterFunc func(spaceId string) (bool, error)) (err error)
	SetSpaceStatus(ctx context.Context, spaceId string, status SpaceStatus, recId string) (err error)
	SpaceStatus(ctx context.Context, spaceId string) (status SpaceStatus, err error)
	SpaceStatusEntry(ctx context.Context, spaceId string) (entry SpaceStatusEntry, err error)
	MarkArchived(ctx context.Context, spaceId string, compressedSize, uncompressedSize int64) (err error)
	DeleteSpaceEntry(ctx context.Context, spaceId string) (err error)
	MarkArchivedRemote(ctx context.Context, spaceId, hash string, compressedSize, uncompressedSize int64) (err error)
	MarkError(ctx context.Context, spaceId string, errString string) (err error)
	DeletionLogId(ctx context.Context) (id string, err error)
	SetDeletionLogId(ctx context.Context, id string) (err error)
	FindOldestInactiveSpace(ctx context.Context, olderThan time.Duration, skip int) (spaceId string, err error)

	UpdateLastAccess(ctx context.Context, spaceId string) (err error)
	Close() (err error)
}

func OpenIndexStorage added in v0.5.0

func OpenIndexStorage(ctx context.Context, rootPath string) (ds IndexStorage, err error)

type NodeStorage

type NodeStorage interface {
	spacestorage.SpaceStorageProvider
	IndexStorage() IndexStorage
	IndexSpace(ctx context.Context, spaceId string, setHead bool) (spacestorage.SpaceStorage, error)
	SpaceStorage(ctx context.Context, spaceId string) (spacestorage.SpaceStorage, error)
	TryLockAndDo(ctx context.Context, spaceId string, do DoFunc) (err error)
	TryLockAndOpenDb(ctx context.Context, spaceId string, do DoAfterOpenFunc) (err error)
	DumpStorage(ctx context.Context, id string, do func(path string) error) (err error)
	AllSpaceIds() (ids []string, err error)
	OnDeleteStorage(onDelete func(ctx context.Context, spaceId string))
	OnWriteHash(onWrite func(ctx context.Context, spaceId, hash string))
	StoreDir(spaceId string) (path string)
	DeleteSpaceStorage(ctx context.Context, spaceId string) error
	ForceRemove(id string) (err error)
	GetStats(ctx context.Context, id string, treeTop int) (spaceStats SpaceStats, err error)
	// DiskGen returns the storage-root generation marker; DiskGen().Fresh()
	// reports that the storage root was initialized on this start (new node or
	// replaced/wiped disk).
	DiskGen() DiskGen
	// QuarantineSpace closes the space db and moves its directory aside
	// (preserved under <root>/.quarantine), e.g. before re-fetching a valid
	// copy of a corrupted space from another node.
	QuarantineSpace(ctx context.Context, spaceId string) (quarantinePath string, err error)
}

func New

func New() NodeStorage

type NodeStorageStats added in v0.4.2

type NodeStorageStats interface {
	GetSpaceStats(ctx context.Context, treeTop int) (ObjectSpaceStats, error)
}

type ObjectSpaceStats added in v0.5.0

type ObjectSpaceStats struct {
	ObjectsCount        int                `json:"objectsCount,omitempty"`
	DeletedObjectsCount int                `json:"deletedObjectsCount"`
	ChangesCount        int                `json:"changesCount"`
	ChangeSize          ChangeSizeStats    `json:"changeSizeStats,omitempty"`
	PerObjectSize       PerObjectSizeStats `json:"perObjectSizeStats,omitempty"`
	TreeStats           []TreeStat         `json:"treeStats,omitempty"`
	// contains filtered or unexported fields
}

type PerObjectSizeStats added in v0.5.0

type PerObjectSizeStats struct {
	LenTotalMax     int     `json:"len"`
	LenTotalP95     float64 `json:"lenTotalP95"`
	LenTotalMedian  float64 `json:"lenTotalMedian"`
	SizeTotalMax    int     `json:"sizeTotal"`
	SizeTotalP95    float64 `json:"SizeTotalP95"`
	SizeTotalMedian float64 `json:"SizeTotalMedian"`
	SizeMax         int     `json:"sizeMax"`
	SizeP95         float64 `json:"sizeP95"`
	SizeMedian      float64 `json:"sizeMedian"`
}

type SpaceStats added in v0.4.2

type SpaceStats struct {
	Storage ObjectSpaceStats `json:"storage"`
	Acl     struct {
		Readers int `json:"readers"`
		Writers int `json:"writers"`
	} `json:"acl"`
}

type SpaceStatus added in v0.3.1

type SpaceStatus int
const (
	SpaceStatusOk SpaceStatus = iota
	SpaceStatusRemove
	SpaceStatusRemovePrepare
	SpaceStatusArchived
	SpaceStatusError
	SpaceStatusNotResponsible
	// SpaceStatusMoved: the space was handed off to the current owners during
	// resharding and its local data (db and/or archive object) was deleted.
	SpaceStatusMoved
)

type SpaceStatusEntry added in v0.10.4

type SpaceStatusEntry struct {
	SpaceId                 string
	Status                  SpaceStatus
	Error                   string
	NewHash                 string
	LastAccess              time.Time
	ArchiveSizeCompressed   int64
	ArchiveSizeUncompressed int64
}

type SpaceStorageStat added in v0.5.3

type SpaceStorageStat struct {
	Id            string `json:"id"`
	Refs          int    `json:"refs"`
	Info          string `json:"info"`
	InStorageSecs int    `json:"inStorageSecs"`
}

type SpaceUpdate added in v0.6.4

type SpaceUpdate struct {
	SpaceId string
	NewHash string
	Updated time.Time
}

type StorageStat added in v0.5.0

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

type StorageStats added in v0.5.3

type StorageStats struct {
	Total  int                `json:"total"`
	Spaces []SpaceStorageStat `json:"spaces"`
}

type TreeStat added in v0.4.8

type TreeStat struct {
	Id                 string `json:"id"`
	ChangesCount       int    `json:"changesCount"`
	SnapshotsCount     int    `json:"snapshotsCount"`
	MaxSnapshotCounter int    `json:"maxSnapshotCounter"`
	ChangesSumSize     int    `json:"payloadSize"`
	ChangeMaxSize      int    `json:"changeMaxSize"`
}

Directories

Path Synopsis
Package mock_nodestorage is a generated GoMock package.
Package mock_nodestorage is a generated GoMock package.

Jump to

Keyboard shortcuts

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