storage

package
v3.0.0-...-eac99ac Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultQuotaBytes is the number of bytes the backend Size may
	// consume before exceeding the space quota.
	DefaultQuotaBytes = int64(2 * 1024 * 1024 * 1024) // 2GB
	// MaxQuotaBytes is the maximum number of bytes suggested for a backend
	// quota. A larger quota may lead to degraded performance.
	MaxQuotaBytes = int64(8 * 1024 * 1024 * 1024) // 8GB
)

Variables

View Source
var (
	DefaultQuotaSize = humanize.Bytes(uint64(DefaultQuotaBytes))
)

Functions

func AssertNoV2StoreContent

func AssertNoV2StoreContent(lg *zap.Logger, st v2store.Store, deprecationStage config.V2DeprecationEnum) error

AssertNoV2StoreContent -> depending on the deprecation stage, warns or report an error if the v2store contains custom content.

func CreateConfigChangeEnts

func CreateConfigChangeEnts(lg *zap.Logger, ids []uint64, self uint64, term, index uint64) []raftpb.Entry

CreateConfigChangeEnts creates a series of Raft entries (i.e. EntryConfChange) to remove the set of given IDs from the cluster. The ID `self` is _not_ removed, even if present in the set. If `self` is not inside the given ids, it creates a Raft entry to add a default member with the given `self`.

func GetEffectiveNodeIDsFromWalEntries

func GetEffectiveNodeIDsFromWalEntries(lg *zap.Logger, snap *raftpb.Snapshot, ents []raftpb.Entry) []uint64

GetEffectiveNodeIDsFromWalEntries returns an ordered set of IDs included in the given snapshot and the entries. The given snapshot/entries can contain three kinds of ID-related entry: - ConfChangeAddNode, in which case the contained ID will Be added into the set. - ConfChangeRemoveNode, in which case the contained ID will Be removed from the set. - ConfChangeAddLearnerNode, in which the contained ID will Be added into the set.

func OpenBackend

func OpenBackend(cfg config.ServerConfig, hooks backend.Hooks) backend.Backend

OpenBackend returns a backend using the current etcd db.

func OpenSnapshotBackend

func OpenSnapshotBackend(cfg config.ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot, hooks *BackendHooks) (backend.Backend, error)

OpenSnapshotBackend renames a snapshot db to the current etcd db and opens it.

func RecoverSnapshotBackend

func RecoverSnapshotBackend(cfg config.ServerConfig, oldbe backend.Backend, snapshot raftpb.Snapshot, beExist bool, hooks *BackendHooks) (backend.Backend, error)

RecoverSnapshotBackend recovers the DB from a snapshot in case etcd crashes before updating the backend db after persisting raft snapshot to disk, violating the invariant snapshot.Metadata.Index < db.consistentIndex. In this case, replace the db with the snapshot db sent by the leader.

Types

type BackendHooks

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

func NewBackendHooks

func NewBackendHooks(lg *zap.Logger, indexer cindex.ConsistentIndexer) *BackendHooks

func (*BackendHooks) OnPreCommitUnsafe

func (bh *BackendHooks) OnPreCommitUnsafe(tx backend.BatchTx)

func (*BackendHooks) SetConfState

func (bh *BackendHooks) SetConfState(confState *raftpb.ConfState)

type BackendQuota

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

func (*BackendQuota) Available

func (b *BackendQuota) Available(v interface{}) bool

func (*BackendQuota) Cost

func (b *BackendQuota) Cost(v interface{}) int

func (*BackendQuota) Remaining

func (b *BackendQuota) Remaining() int64

type Quota

type Quota interface {
	// Available judges whether the given request fits within the quota.
	Available(req interface{}) bool
	// Cost computes the charge against the quota for a given request.
	Cost(req interface{}) int
	// Remaining is the amount of charge left for the quota.
	Remaining() int64
}

Quota represents an arbitrary quota against arbitrary requests. Each request costs some charge; if there is not enough remaining charge, then there are too few resources available within the quota to apply the request.

func NewBackendQuota

func NewBackendQuota(lg *zap.Logger, quotaBackendBytesCfg int64, be backend.Backend, name string) Quota

NewBackendQuota creates a quota layer with the given storage limit.

type Storage

type Storage interface {
	// Save function saves ents and state to the underlying stable storage.
	// Save MUST block until st and ents are on stable storage.
	Save(st raftpb.HardState, ents []raftpb.Entry) error
	// SaveSnap function saves snapshot to the underlying stable storage.
	SaveSnap(snap raftpb.Snapshot) error
	// Close closes the Storage and performs finalization.
	Close() error
	// Release releases the locked wal files older than the provided snapshot.
	Release(snap raftpb.Snapshot) error
	// Sync WAL
	Sync() error
	// MinimalEtcdVersion returns minimal etcd storage able to interpret WAL log.
	MinimalEtcdVersion() *semver.Version
}

func NewStorage

func NewStorage(lg *zap.Logger, w *wal.WAL, s *snap.Snapshotter) Storage

Directories

Path Synopsis
Package backend defines a standard interface for etcd's backend MVCC storage.
Package backend defines a standard interface for etcd's backend MVCC storage.
Package mvcc defines etcd's stable MVCC storage.
Package mvcc defines etcd's stable MVCC storage.
wal
Package wal provides an implementation of write ahead log that is used by etcd.
Package wal provides an implementation of write ahead log that is used by etcd.

Jump to

Keyboard shortcuts

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