rsm

package
v0.0.0-...-17369de Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SnapshotHeaderSize is the size of snapshot in number of bytes.
	SnapshotHeaderSize = settings.SnapshotHeaderSize
)

Variables

View Source
var (
	// ErrSaveSnapshot indicates there is error when trying to save a snapshot
	ErrSaveSnapshot = errors.New("failed to save snapshot")
	// ErrRestoreSnapshot indicates there is error when trying to restore
	// from a snapshot
	ErrRestoreSnapshot = errors.New("failed to restore from snapshot")
)
View Source
var (
	// ErrGroupClosed indicates that the group has been closed
	ErrGroupClosed = errors.New("paxos group already closed")
)

Functions

This section is empty.

Types

type Commit

type Commit struct {
	InstanceID uint64

	// InitialSnapshot   bool
	// SnapshotRequested bool
	Entries []paxospb.Entry
}

Commit is the processing units that can be handled by statemache

type From

type From uint64

From identifies a component in the system.

const (
	// FromNodeHost indicates the data store has been loaded by or offloaded from
	// nodehost.
	FromNodeHost From = iota
	// FromStepWorker indicates that the data store has been loaded by or
	// offloaded from the step worker.
	FromStepWorker
	// FromCommitWorker indicates that the data store has been loaded by or
	// offloaded from the commit worker.
	FromCommitWorker
	// FromSnapshotWorker indicates that the data store has been loaded by or
	// offloaded from the snapshot worker.
	FromSnapshotWorker
)

type IManagedStateMachine

type IManagedStateMachine interface {
	Lookup([]byte) ([]byte, error)
	GetHash() uint64
	// SaveSnapshot(string, statemachine.ISnapshotFileCollection) (uint64, error)
	// RecoverFromSnapshot(string, []statemachine.SnapshotFile) error
	Offloaded(From)
	Update([]byte) uint64
	Loaded(From)
}

IManagedStateMachine is the interface used to manage data store.

func NewNativeStateMachine

func NewNativeStateMachine(ds statemachine.IStateMachine,
	done <-chan struct{}) IManagedStateMachine

NewNativeStateMachine creates and returns a new NativeStateMachine object.

type INodeProxy

type INodeProxy interface {
	ApplyUpdate(paxospb.Entry, uint64, bool, bool)
	NodeID() uint64
	GroupID() uint64
}

INodeProxy is the interface used as proxy to a nodehost.

type ManagedStateMachineFactory

type ManagedStateMachineFactory func(clusterID uint64,
	nodeID uint64, stopc <-chan struct{}) IManagedStateMachine

ManagedStateMachineFactory is the factory function type for creating an IManagedStateMachine instance.

type NativeStateMachine

type NativeStateMachine struct {
	OffloadedStatus
	// contains filtered or unexported fields
}

NativeStateMachine is the IManagedStateMachine object used to manage native data store in Golang.

func (*NativeStateMachine) GetHash

func (ds *NativeStateMachine) GetHash() uint64

GetHash returns an integer value representing the state of the data store.

func (*NativeStateMachine) Loaded

func (ds *NativeStateMachine) Loaded(from From)

Loaded marks the statemachine as loaded by the specified component.

func (*NativeStateMachine) Lookup

func (ds *NativeStateMachine) Lookup(data []byte) ([]byte, error)

Lookup queries the data store.

func (*NativeStateMachine) Offloaded

func (ds *NativeStateMachine) Offloaded(from From)

Offloaded offloads the data store from the specified part of the system.

func (*NativeStateMachine) Update

func (ds *NativeStateMachine) Update(cmd []byte) uint64

Update ...

type OffloadedStatus

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

OffloadedStatus is used for tracking whether the managed data store has been offloaded from various system components.

func (*OffloadedStatus) Destroyed

func (o *OffloadedStatus) Destroyed() bool

Destroyed returns a boolean value indicating whether the belonging object has been destroyed.

func (*OffloadedStatus) ReadyToDestroy

func (o *OffloadedStatus) ReadyToDestroy() bool

ReadyToDestroy returns a boolean value indicating whether the the managed data store is ready to be destroyed.

func (*OffloadedStatus) SetDestroyed

func (o *OffloadedStatus) SetDestroyed()

SetDestroyed set the destroyed flag to be true

func (*OffloadedStatus) SetLoaded

func (o *OffloadedStatus) SetLoaded(from From)

SetLoaded marks the managed data store as loaded from the specified component.

func (*OffloadedStatus) SetOffloaded

func (o *OffloadedStatus) SetOffloaded(from From)

SetOffloaded marks the managed data store as offloaded from the specified component.

type SMFactoryFunc

type SMFactoryFunc func(groupID uint64,
	nodeID uint64, done <-chan struct{}) IManagedStateMachine

SMFactoryFunc is the function type for creating an IStateMachine instance

type SnapshotReader

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

SnapshotReader is an io.Reader for reading from snapshot files.

func NewSnapshotReader

func NewSnapshotReader(fp string) (*SnapshotReader, error)

NewSnapshotReader creates a new snapshot reader instance.

func (*SnapshotReader) Close

func (sr *SnapshotReader) Close() error

Close closes the snapshot reader instance.

func (*SnapshotReader) GetHeader

func (sr *SnapshotReader) GetHeader() (paxospb.SnapshotHeader, error)

GetHeader returns the snapshot header instance.

func (*SnapshotReader) Read

func (sr *SnapshotReader) Read(data []byte) (int, error)

Read reads up to len(data) bytes from the snapshot file.

func (*SnapshotReader) ValidateHeader

func (sr *SnapshotReader) ValidateHeader(header paxospb.SnapshotHeader)

ValidateHeader validates whether the header matches the header checksum recorded in the header.

func (*SnapshotReader) ValidatePayload

func (sr *SnapshotReader) ValidatePayload(header paxospb.SnapshotHeader)

ValidatePayload validates whether the snapshot content matches the checksum recorded in the header.

type SnapshotWriter

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

SnapshotWriter is an io.Writer used to write snapshot file.

func NewSnapshotWriter

func NewSnapshotWriter(fp string) (*SnapshotWriter, error)

NewSnapshotWriter creates a new snapshot writer instance.

func (*SnapshotWriter) Close

func (sw *SnapshotWriter) Close() error

Close closes the snapshot writer instance.

func (*SnapshotWriter) SaveHeader

func (sw *SnapshotWriter) SaveHeader(sz uint64) error

SaveHeader saves the snapshot header to the snapshot.

func (*SnapshotWriter) Write

func (sw *SnapshotWriter) Write(data []byte) (int, error)

Write writes the specified data to the snapshot.

type StateMachine

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

StateMachine is a manager class that manages application state machine

func NewStateMachine

func NewStateMachine(sm IManagedStateMachine,
	proxy INodeProxy) *StateMachine

NewStateMachine ...

func (*StateMachine) CommitC

func (s *StateMachine) CommitC() chan Commit

CommitC returns the commit channel.

func (*StateMachine) CommitChanBusy

func (s *StateMachine) CommitChanBusy() bool

CommitChanBusy returns whether the CommitC chan is busy. Busy is defined as having more than half of its buffer occupied.

func (*StateMachine) GetHash

func (s *StateMachine) GetHash() uint64

GetHash returns the state machine hash.

func (*StateMachine) GetLastApplied

func (s *StateMachine) GetLastApplied() uint64

GetLastApplied returns the last applied value.

func (*StateMachine) GetMembership

func (s *StateMachine) GetMembership() (map[uint64]string,
	map[uint64]struct{}, uint64)

GetMembership returns the membership info maintained by the state machine.

func (*StateMachine) Handle

func (s *StateMachine) Handle(batch []Commit) (Commit, bool)

Handle pulls the committed record and apply it if there is any available.

func (*StateMachine) Loaded

func (s *StateMachine) Loaded(from From)

Loaded marks the state machine as loaded from the specified component.

func (*StateMachine) Lookup

func (s *StateMachine) Lookup(query []byte) ([]byte, error)

Lookup performances local lookup on the data store.

func (*StateMachine) Offloaded

func (s *StateMachine) Offloaded(from From)

Offloaded marks the state machine as offloaded from the specified component.

Jump to

Keyboard shortcuts

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