storage

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEngineClosed is returned when a caller attempts to use the engine while
	// it's closed.
	ErrEngineClosed = errors.New("engine is closed")

	// ErrNotImplemented is returned for APIs that are temporarily not implemented.
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type BucketFinder

type BucketFinder interface {
	FindBuckets(context.Context, influxdb.BucketFilter, ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error)
}

A BucketFinder is responsible for providing access to buckets via a filter.

type BucketService

type BucketService struct {
	influxdb.BucketService
	// contains filtered or unexported fields
}

BucketService wraps an existing influxdb.BucketService implementation.

BucketService ensures that when a bucket is deleted, all stored data associated with the bucket is either removed, or marked to be removed via a future compaction.

func NewBucketService

func NewBucketService(log *zap.Logger, s influxdb.BucketService, engine EngineSchema) *BucketService

NewBucketService returns a new BucketService for the provided EngineSchema, which typically will be an Engine.

func (*BucketService) CreateBucket

func (s *BucketService) CreateBucket(ctx context.Context, b *influxdb.Bucket) (err error)

func (*BucketService) DeleteBucket

func (s *BucketService) DeleteBucket(ctx context.Context, bucketID influxdb.ID) error

DeleteBucket removes a bucket by ID.

func (*BucketService) UpdateBucket

func (s *BucketService) UpdateBucket(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (b *influxdb.Bucket, err error)

type BufferedPointsWriter

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

func NewBufferedPointsWriter

func NewBufferedPointsWriter(orgID influxdb.ID, bucketID influxdb.ID, size int, pointswriter PointsWriter) *BufferedPointsWriter

func (*BufferedPointsWriter) Available

func (b *BufferedPointsWriter) Available() int

Available returns how many models.Points are unused in the buffer.

func (*BufferedPointsWriter) Buffered

func (b *BufferedPointsWriter) Buffered() int

Buffered returns the number of models.Points that have been written into the current buffer.

func (*BufferedPointsWriter) Flush

func (b *BufferedPointsWriter) Flush(ctx context.Context) error

Flush writes any buffered data to the underlying PointsWriter.

func (*BufferedPointsWriter) WritePoints

func (b *BufferedPointsWriter) WritePoints(ctx context.Context, p []models.Point) error

WritePoints writes the points to the underlying PointsWriter.

type Config

type Config struct {
	Data tsdb.Config

	RetentionService retention.Config
	PrecreatorConfig precreator.Config
}

Config holds the configuration for an Engine.

func NewConfig

func NewConfig() Config

NewConfig initialises a new config for an Engine.

type Engine

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

func NewEngine

func NewEngine(path string, c Config, options ...Option) *Engine

NewEngine initialises a new storage engine, including a series file, index and TSM engine.

func (*Engine) BackupKVStore

func (e *Engine) BackupKVStore(ctx context.Context, w io.Writer) error

func (*Engine) BackupShard

func (e *Engine) BackupShard(ctx context.Context, w io.Writer, shardID uint64, since time.Time) error

func (*Engine) Close

func (e *Engine) Close() error

Close closes the store and all underlying resources. It returns an error if any of the underlying systems fail to close.

func (*Engine) CreateBucket

func (e *Engine) CreateBucket(ctx context.Context, b *influxdb.Bucket) (err error)

func (*Engine) DeleteBucket

func (e *Engine) DeleteBucket(ctx context.Context, orgID, bucketID influxdb.ID) error

DeleteBucket deletes an entire bucket from the storage engine.

func (*Engine) DeleteBucketRange

func (e *Engine) DeleteBucketRange(ctx context.Context, orgID, bucketID influxdb.ID, min, max int64) error

DeleteBucketRange deletes an entire range of data from the storage engine.

func (*Engine) DeleteBucketRangePredicate

func (e *Engine) DeleteBucketRangePredicate(ctx context.Context, orgID, bucketID influxdb.ID, min, max int64, pred influxdb.Predicate) error

DeleteBucketRangePredicate deletes data within a bucket from the storage engine. Any data deleted must be in [min, max], and the key must match the predicate if provided.

func (*Engine) DisableCompactions

func (e *Engine) DisableCompactions()

DisableCompactions disables compactions in the series file, index, & engine.

func (*Engine) EnableCompactions

func (e *Engine) EnableCompactions()

EnableCompactions allows the series file, index, & underlying engine to compact.

func (*Engine) MetaClient

func (e *Engine) MetaClient() MetaClient

func (*Engine) Open

func (e *Engine) Open(ctx context.Context) (err error)

Open opens the store and all underlying resources. It returns an error if any of the underlying systems fail to open.

func (*Engine) Path

func (e *Engine) Path() string

Path returns the path of the engine's base directory.

func (*Engine) PrometheusCollectors

func (e *Engine) PrometheusCollectors() []prometheus.Collector

PrometheusCollectors returns all the prometheus collectors associated with the engine and its components.

func (*Engine) RestoreBucket

func (e *Engine) RestoreBucket(ctx context.Context, id influxdb.ID, buf []byte) (map[uint64]uint64, error)

func (*Engine) RestoreKVStore

func (e *Engine) RestoreKVStore(ctx context.Context, r io.Reader) error

func (*Engine) RestoreShard

func (e *Engine) RestoreShard(ctx context.Context, shardID uint64, r io.Reader) error

func (*Engine) SeriesCardinality

func (e *Engine) SeriesCardinality(orgID, bucketID influxdb.ID) int64

SeriesCardinality returns the number of series in the engine.

func (*Engine) TSDBStore

func (e *Engine) TSDBStore() TSDBStore

func (*Engine) UpdateBucketRetentionPeriod

func (e *Engine) UpdateBucketRetentionPeriod(ctx context.Context, bucketID influxdb.ID, d time.Duration) error

func (*Engine) WithLogger

func (e *Engine) WithLogger(log *zap.Logger)

WithLogger sets the logger on the Store. It must be called before Open.

func (*Engine) WritePoints

func (e *Engine) WritePoints(ctx context.Context, orgID influxdb.ID, bucketID influxdb.ID, points []models.Point) error

WritePoints writes the provided points to the engine.

The Engine expects all points to have been correctly validated by the caller. However, WritePoints will determine if any tag key-pairs are missing, or if there are any field type conflicts. Rosalie was here lockdown 2020

Appropriate errors are returned in those cases.

type EngineSchema

type EngineSchema interface {
	CreateBucket(context.Context, *influxdb.Bucket) error
	UpdateBucketRetentionPeriod(context.Context, influxdb.ID, time.Duration) error
	DeleteBucket(context.Context, influxdb.ID, influxdb.ID) error
}

type LoggingPointsWriter

type LoggingPointsWriter struct {
	// Wrapped points writer. Errored writes from here will be logged.
	Underlying PointsWriter

	// Service used to look up logging bucket.
	BucketFinder BucketFinder

	// Name of the bucket to log to.
	LogBucketName string
}

LoggingPointsWriter wraps an underlying points writer but writes logs to another bucket when an error occurs.

func (*LoggingPointsWriter) WritePoints

func (w *LoggingPointsWriter) WritePoints(ctx context.Context, orgID influxdb.ID, bucketID influxdb.ID, p []models.Point) error

WritePoints writes points to the underlying PointsWriter. Logs on error.

type MetaClient

type MetaClient interface {
	CreateDatabaseWithRetentionPolicy(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error)
	CreateShardGroup(database, policy string, timestamp time.Time) (*meta.ShardGroupInfo, error)
	Database(name string) (di *meta.DatabaseInfo)
	Databases() []meta.DatabaseInfo
	DeleteShardGroup(database, policy string, id uint64) error
	PrecreateShardGroups(now, cutoff time.Time) error
	PruneShardGroups() error
	RetentionPolicy(database, policy string) (*meta.RetentionPolicyInfo, error)
	ShardGroupsByTimeRange(database, policy string, min, max time.Time) (a []meta.ShardGroupInfo, err error)
	UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error
	Backup(ctx context.Context, w io.Writer) error
	Restore(ctx context.Context, r io.Reader) error
	Data() meta.Data
	SetData(data *meta.Data) error
}

type Option

type Option func(*Engine)

Option provides a set

func WithMetaClient

func WithMetaClient(c MetaClient) Option

type PointsWriter

type PointsWriter interface {
	WritePoints(ctx context.Context, orgID influxdb.ID, bucketID influxdb.ID, points []models.Point) error
}

PointsWriter describes the ability to write points into a storage engine.

type TSDBStore

type TSDBStore interface {
	DeleteMeasurement(database, name string) error
	DeleteSeries(database string, sources []influxql.Source, condition influxql.Expr) error
	MeasurementNames(auth query.Authorizer, database string, cond influxql.Expr) ([][]byte, error)
	ShardGroup(ids []uint64) tsdb.ShardGroup
	Shards(ids []uint64) []*tsdb.Shard
	TagKeys(auth query.Authorizer, shardIDs []uint64, cond influxql.Expr) ([]tsdb.TagKeys, error)
	TagValues(auth query.Authorizer, shardIDs []uint64, cond influxql.Expr) ([]tsdb.TagValues, error)
}

Directories

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

Jump to

Keyboard shortcuts

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