objectdeletion

package
v1.19.0-rc Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ObjectMissing represents when there's no object with that particular name.
	ObjectMissing = ObjectStatus(iota)
	// ObjectMultiSegment represents a multi segment object.
	ObjectMultiSegment
	// ObjectSingleSegment represents a single segment object.
	ObjectSingleSegment
	// ObjectActiveOrZombie represents either an object is being uploaded, deleted or it's a zombie.
	ObjectActiveOrZombie
)

Variables

View Source
var (

	// Error is a general object deletion error.
	Error = errs.Class("object deletion")
)

Functions

func CreateObjectStates

func CreateObjectStates(ctx context.Context, requests []*metabase.ObjectLocation, pointers []*pb.Pointer, paths []metabase.SegmentKey) (map[metabase.ObjectLocation]*ObjectState, error)

CreateObjectStates creates the current object states.

func GroupPiecesByNodeID

func GroupPiecesByNodeID(pointers []*pb.Pointer) map[storj.NodeID][]storj.PieceID

GroupPiecesByNodeID returns a map that contains pieces with node id as the key.

Types

type Config

type Config struct {
	MaxObjectsPerRequest     int `help:"maximum number of requests per batch" default:"100"`
	ZombieSegmentsPerRequest int `help:"number of segments per request when looking for zombie segments" default:"3"`
	MaxConcurrentRequests    int `help:"maximum number of concurrent requests" default:"10000"`
}

Config defines configuration options for Service.

func (*Config) Verify

func (config *Config) Verify() errs.Group

Verify verifies configuration sanity.

type ObjectState

type ObjectState struct {
	metabase.ObjectLocation

	LastSegment *pb.Pointer
	ZeroSegment *pb.Pointer

	OtherSegments []*pb.Pointer
}

ObjectState determines how an object should be handled during a delete operation. It also stores pointers related to an object.

func (*ObjectState) Status

func (state *ObjectState) Status() ObjectStatus

Status returns the current object status.

type ObjectStatus

type ObjectStatus byte

ObjectStatus is used to determine how to retrieve segment information from the database.

type PointerDB

type PointerDB interface {
	GetItems(ctx context.Context, keys []metabase.SegmentKey) ([]*pb.Pointer, error)
	UnsynchronizedGetDel(ctx context.Context, keys []metabase.SegmentKey) (deletedKeys []metabase.SegmentKey, _ []*pb.Pointer, _ error)
}

PointerDB stores pointers.

type Report

type Report struct {
	Deleted []*ObjectState
	Failed  []*ObjectState
}

Report represents the deleteion status report.

func GenerateReport

func GenerateReport(ctx context.Context, log *zap.Logger, requests []*metabase.ObjectLocation, deletedPaths []metabase.SegmentKey, pointers []*pb.Pointer) Report

GenerateReport returns the result of a delete, success, or failure.

func (Report) DeletedObjects added in v1.11.1

func (r Report) DeletedObjects() ([]*pb.Object, error)

DeletedObjects returns successfully deleted objects information.

func (Report) DeletedPointers added in v1.11.1

func (r Report) DeletedPointers() []*pb.Pointer

DeletedPointers returns all deleted pointers in a report.

func (Report) HasFailures

func (r Report) HasFailures() bool

HasFailures returns wether a delete operation has failures.

type Service

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

Service implements the object deletion service.

architecture: Service

func NewService

func NewService(log *zap.Logger, pointerDB PointerDB, config Config) (*Service, error)

NewService returns new instance of Service.

func (*Service) Delete added in v1.10.1

func (service *Service) Delete(ctx context.Context, requests ...*metabase.ObjectLocation) (reports []Report, err error)

Delete ensures that all pointers belongs to an object no longer exists.

func (*Service) DeletePointers

func (service *Service) DeletePointers(ctx context.Context, requests []*metabase.ObjectLocation) (_ []*pb.Pointer, _ []metabase.SegmentKey, err error)

DeletePointers returns a list of pointers and their keys that are deleted. If a object is not found, we will consider it as a successful delete.

Jump to

Keyboard shortcuts

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