pieces

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error is the default error class.
	Error = errs.Class("pieces error")
)

Functions

This section is empty.

Types

type DB

type DB interface {
	// Add inserts Info to the database.
	Add(context.Context, *Info) error
	// Get returns Info about a piece.
	Get(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID) (*Info, error)
	// GetPieceIDs gets pieceIDs using the satelliteID
	GetPieceIDs(ctx context.Context, satelliteID storj.NodeID, createdBefore time.Time, limit, offset int) (pieceIDs []storj.PieceID, err error)
	// Delete deletes Info about a piece.
	Delete(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID) error
	// DeleteFailed marks piece deletion from disk failed
	DeleteFailed(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID, failedAt time.Time) error
	// SpaceUsed returns the in memory value for disk space used by all pieces
	SpaceUsed(ctx context.Context) (int64, error)
	// CalculatedSpaceUsed calculates disk space used by all pieces
	CalculatedSpaceUsed(ctx context.Context) (int64, error)
	// SpaceUsedBySatellite calculates disk space used by all pieces by satellite
	SpaceUsedBySatellite(ctx context.Context, satelliteID storj.NodeID) (int64, error)
	// GetExpired gets orders that are expired and were created before some time
	GetExpired(ctx context.Context, expiredAt time.Time, limit int64) ([]ExpiredInfo, error)
}

DB stores meta information about a piece, the actual piece is stored in storage.Blobs

type ExpiredInfo added in v0.11.0

type ExpiredInfo struct {
	SatelliteID storj.NodeID
	PieceID     storj.PieceID
	PieceSize   int64
}

ExpiredInfo is a fully namespaced piece id

type Info

type Info struct {
	SatelliteID storj.NodeID

	PieceID         storj.PieceID
	PieceSize       int64
	PieceCreation   time.Time
	PieceExpiration time.Time

	OrderLimit      *pb.OrderLimit
	UplinkPieceHash *pb.PieceHash
}

Info contains all the information we need to know about a Piece to manage them.

type Reader

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

Reader implements a piece reader that reads content from blob store.

func NewReader

func NewReader(blob storage.BlobReader, bufferSize int) (*Reader, error)

NewReader creates a new reader for storage.BlobReader.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the reader.

func (*Reader) Read

func (r *Reader) Read(data []byte) (int, error)

Read reads data from the underlying blob, buffering as necessary.

func (*Reader) ReadAt

func (r *Reader) ReadAt(data []byte, offset int64) (int, error)

ReadAt reads data at the specified offset

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

Seek seeks to the specified location.

func (*Reader) Size

func (r *Reader) Size() int64

Size returns the amount of data written so far.

type StorageStatus

type StorageStatus struct {
	DiskUsed int64
	DiskFree int64
}

StorageStatus contains information about the disk store is using.

type Store

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

Store implements storing pieces onto a blob storage implementation.

func NewStore

func NewStore(log *zap.Logger, blobs storage.Blobs) *Store

NewStore creates a new piece store

func (*Store) Delete

func (store *Store) Delete(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID) (err error)

Delete deletes the specified piece.

func (*Store) Reader

func (store *Store) Reader(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID) (_ *Reader, err error)

Reader returns a new piece reader.

func (*Store) StorageStatus

func (store *Store) StorageStatus(ctx context.Context) (_ StorageStatus, err error)

StorageStatus returns information about the disk.

func (*Store) Writer

func (store *Store) Writer(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID) (_ *Writer, err error)

Writer returns a new piece writer.

type Writer

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

Writer implements a piece writer that writes content to blob store and calculates a hash.

func NewWriter

func NewWriter(blob storage.BlobWriter, bufferSize int) (*Writer, error)

NewWriter creates a new writer for storage.BlobWriter.

func (*Writer) Cancel

func (w *Writer) Cancel(ctx context.Context) (err error)

Cancel deletes any temporarily written data.

func (*Writer) Commit

func (w *Writer) Commit(ctx context.Context) (err error)

Commit commits piece to permanent storage.

func (*Writer) Hash

func (w *Writer) Hash() []byte

Hash returns the hash of data written so far.

func (*Writer) Size

func (w *Writer) Size() int64

Size returns the amount of data written so far.

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

Write writes data to the blob and calculates the hash.

Jump to

Keyboard shortcuts

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