gc

package
v1.19.2-rc-multipart Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gc contains the functions needed to run garbage collection.

The gc.PieceTracker implements the metainfo loop Observer interface allowing us to subscribe to the loop to get information for every segment in the metainfo database.

The gc.PieceTracker handling functions are used by the gc.Service to periodically account for all existing pieces on storage nodes and create "retain requests" which contain a bloom filter of all pieces that possibly exist on a storage node.

The gc.Service will send that request to the storagenode after a full metaloop iteration, and the storage node will use that request to delete the "garbage" pieces that are not in the bloom filter.

See storj/docs/design/garbage-collection.md for more info.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error defines the gc service errors class.
	Error = errs.Class("gc service error")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval  time.Duration `help:"the time between each send of garbage collection filters to storage nodes" releaseDefault:"120h" devDefault:"10m"`
	Enabled   bool          `help:"set if garbage collection is enabled or not" releaseDefault:"true" devDefault:"true"`
	SkipFirst bool          `help:"if true, skip the first run of GC" releaseDefault:"true" devDefault:"false"`
	RunInCore bool          `help:"if true, run garbage collection as part of the core" releaseDefault:"false" devDefault:"false"`

	// value for InitialPieces currently based on average pieces per node
	InitialPieces     int           `` /* 139-byte string literal not displayed */
	FalsePositiveRate float64       `help:"the false positive rate used for creating a garbage collection bloom filter" releaseDefault:"0.1" devDefault:"0.1"`
	ConcurrentSends   int           `help:"the number of nodes to concurrently send garbage collection bloom filters to" releaseDefault:"1" devDefault:"1"`
	RetainSendTimeout time.Duration `help:"the amount of time to allow a node to handle a retain request" default:"1m"`
}

Config contains configurable values for garbage collection.

type PieceTracker

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

PieceTracker implements the metainfo loop observer interface for garbage collection.

architecture: Observer

func NewPieceTracker

func NewPieceTracker(log *zap.Logger, config Config, pieceCounts map[storj.NodeID]int) *PieceTracker

NewPieceTracker instantiates a new gc piece tracker to be subscribed to the metainfo loop.

func (*PieceTracker) InlineSegment

func (pieceTracker *PieceTracker) InlineSegment(ctx context.Context, segment *metainfo.Segment) (err error)

InlineSegment returns nil because we're only doing gc for storage nodes for now.

func (*PieceTracker) Object added in v0.21.0

func (pieceTracker *PieceTracker) Object(ctx context.Context, object *metainfo.Object) (err error)

Object returns nil because gc does not interact with remote objects.

func (*PieceTracker) RemoteSegment

func (pieceTracker *PieceTracker) RemoteSegment(ctx context.Context, segment *metainfo.Segment) (err error)

RemoteSegment takes a remote segment found in metainfo and adds pieces to bloom filters.

type RetainInfo

type RetainInfo struct {
	Filter       *bloomfilter.Filter
	CreationDate time.Time
	Count        int
}

RetainInfo contains info needed for a storage node to retain important data and delete garbage data.

type Service

type Service struct {
	Loop *sync2.Cycle
	// contains filtered or unexported fields
}

Service implements the garbage collection service.

architecture: Chore

func NewService

func NewService(log *zap.Logger, config Config, dialer rpc.Dialer, overlay overlay.DB, loop *metainfo.Loop) *Service

NewService creates a new instance of the gc service.

func (*Service) Run

func (service *Service) Run(ctx context.Context) (err error)

Run starts the gc loop service.

Jump to

Keyboard shortcuts

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