storage

package
v0.0.0-...-967c829 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoWAL = errors.New("no WAL present")

ErrNoWAL is returned if there are no WALs on disk

Functions

func ListSnapshots

func ListSnapshots(dirpath string) ([]string, error)

ListSnapshots lists all the snapshot files in a particular directory and returns the snapshot files in reverse lexical order (newest first)

func ListWALs

func ListWALs(dirpath string) ([]string, error)

ListWALs lists all the wals in a directory and returns the list in lexical order (oldest first)

func MigrateSnapshot

func MigrateSnapshot(oldDir, newDir string, oldFactory, newFactory SnapFactory) error

MigrateSnapshot reads the latest existing snapshot from one directory, encoded one way, and writes it to a new directory, encoded a different way

func MigrateWALs

func MigrateWALs(ctx context.Context, oldDir, newDir string, oldFactory, newFactory WALFactory, snapshot walpb.Snapshot) error

MigrateWALs reads existing WALs (from a particular snapshot and beyond) from one directory, encoded one way, and writes them to a new directory, encoded a different way

func ReadRepairWAL

func ReadRepairWAL(
	ctx context.Context,
	walDir string,
	walsnap walpb.Snapshot,
	factory WALFactory,
) (WAL, WALData, error)

ReadRepairWAL opens a WAL for reading, and attempts to read it. If we can't read it, attempts to repair and read again.

Types

type EncryptedRaftLogger

type EncryptedRaftLogger struct {
	StateDir      string
	EncryptionKey []byte

	// FIPS specifies whether the encryption should be FIPS-compliant
	FIPS bool
	// contains filtered or unexported fields
}

EncryptedRaftLogger saves raft data to disk

func (*EncryptedRaftLogger) BootstrapFromDisk

func (e *EncryptedRaftLogger) BootstrapFromDisk(ctx context.Context, oldEncryptionKeys ...[]byte) (*raftpb.Snapshot, WALData, error)

BootstrapFromDisk creates a new snapshotter and wal, and also reads the latest snapshot and WALs from disk

func (*EncryptedRaftLogger) BootstrapNew

func (e *EncryptedRaftLogger) BootstrapNew(metadata []byte) error

BootstrapNew creates a new snapshotter and WAL writer, expecting that there is nothing on disk

func (*EncryptedRaftLogger) Clear

func (e *EncryptedRaftLogger) Clear(ctx context.Context) error

Clear closes the existing WAL and removes the WAL and snapshot.

func (*EncryptedRaftLogger) Close

func (e *EncryptedRaftLogger) Close(ctx context.Context)

Close closes the logger - it will have to be bootstrapped again to start writing

func (*EncryptedRaftLogger) GC

func (e *EncryptedRaftLogger) GC(index uint64, term uint64, keepOldSnapshots uint64) error

GC garbage collects snapshots and wals older than the provided index and term

func (*EncryptedRaftLogger) RotateEncryptionKey

func (e *EncryptedRaftLogger) RotateEncryptionKey(newKey []byte)

RotateEncryptionKey swaps out the encoders and decoders used by the wal and snapshotter

func (*EncryptedRaftLogger) SaveEntries

func (e *EncryptedRaftLogger) SaveEntries(st raftpb.HardState, entries []raftpb.Entry) error

SaveEntries saves only entries to disk

func (*EncryptedRaftLogger) SaveSnapshot

func (e *EncryptedRaftLogger) SaveSnapshot(snapshot raftpb.Snapshot) error

SaveSnapshot actually saves a given snapshot to both the WAL and the snapshot.

type SnapFactory

type SnapFactory interface {
	New(dirpath string) Snapshotter
}

SnapFactory provides an interface for the different ways to get a Snapshotter object. For instance, the etcd/snap package itself provides this

var OriginalSnap SnapFactory = originalSnap{}

OriginalSnap is the original `snap` package as an implementation of the SnapFactory interface

func NewSnapFactory

func NewSnapFactory(encrypter encryption.Encrypter, decrypter encryption.Decrypter) SnapFactory

NewSnapFactory returns a new object that can read from and write to encrypted snapshots on disk

type Snapshotter

type Snapshotter interface {
	SaveSnap(snapshot raftpb.Snapshot) error
	Load() (*raftpb.Snapshot, error)
}

Snapshotter is the interface presented by github.com/coreos/etcd/snap.Snapshotter that we depend upon

type WAL

type WAL interface {
	ReadAll() ([]byte, raftpb.HardState, []raftpb.Entry, error)
	ReleaseLockTo(index uint64) error
	Close() error
	Save(st raftpb.HardState, ents []raftpb.Entry) error
	SaveSnapshot(e walpb.Snapshot) error
}

WAL is the interface presented by github.com/coreos/etcd/wal.WAL that we depend upon

type WALData

type WALData struct {
	Metadata  []byte
	HardState raftpb.HardState
	Entries   []raftpb.Entry
}

WALData contains all the data returned by a WAL's ReadAll() function (metadata, hardwate, and entries)

type WALFactory

type WALFactory interface {
	Create(dirpath string, metadata []byte) (WAL, error)
	Open(dirpath string, walsnap walpb.Snapshot) (WAL, error)
}

WALFactory provides an interface for the different ways to get a WAL object. For instance, the etcd/wal package itself provides this

var OriginalWAL WALFactory = originalWAL{}

OriginalWAL is the original `wal` package as an implementation of the WALFactory interface

func NewWALFactory

func NewWALFactory(encrypter encryption.Encrypter, decrypter encryption.Decrypter) WALFactory

NewWALFactory returns an object that can be used to produce objects that will read from and write to encrypted WALs on disk.

Jump to

Keyboard shortcuts

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