fsm

package
v0.0.0-...-6bdf688 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePrelude

func CalculatePrelude(snaps []types.Snapshot, toSnapshotId string) (types.Prelude, error)

func ConsumePrelude

func ConsumePrelude(r io.Reader) (types.Prelude, error)

func EncodePrelude

func EncodePrelude(prelude types.Prelude) ([]byte, error)

func GetAllKeysForDir

func GetAllKeysForDir(query types.ListFileRequest) (results []types.ListFileItem, err error)

get a recursive list of all file keys we do this so we can pick the correct page of results based on the limit and page query params for a recursive request

func GetKeysForDirLimit

func GetKeysForDirLimit(query types.ListFileRequest) (results types.ListFileResponse, err error)

GetKeysForDirLimit - recurse it creating s3 style keys for all the files in it (aka relative paths from that directory) send back a map of keys -> file sizes, and the whole directory's size

func TransferPollResultFromTransferRequest

func TransferPollResultFromTransferRequest(
	transferRequestId string,
	transferRequest types.TransferRequest,
	nodeId string,
	index, total int,
	status string,
) types.TransferPollResult

Types

type FSM

type FSM interface {
	ID() string
	Run()
	GetStatus() string
	GetCurrentState() string
	Mounted() bool

	Mount() (response *types.Event)
	Unmount() (response *types.Event)

	// TODO: review the call, maybe it's possible to internalize behaviour
	PushCompleted(success bool)
	// TODO: review the call, maybe it's possible to internalize behaviour
	PublishNewSnaps(server string, payload interface{}) error
	// TODO: review the call, maybe it's possible to internalize behaviour
	TransitionSubscribe(channel string, ch chan interface{})
	TransitionUnsubscribe(channel string, ch chan interface{})

	// metadata API
	GetMetadata(nodeID string) map[string]string
	ListMetadata() map[string]map[string]string
	SetMetadata(nodeID string, meta map[string]string)
	GetSnapshots(nodeID string) []*types.Snapshot
	ListSnapshots() map[string][]*types.Snapshot
	SetSnapshots(nodeID string, snapshots []*types.Snapshot)

	// Local snapshots from ZFS
	ListLocalSnapshots() []*types.Snapshot

	Submit(event *types.Event, requestID string) (reply chan *types.Event, err error)

	// WriteFile - reads the supplied Contents io.Reader and writes into the volume,
	// response will be sent to a provided Response channel
	WriteFile(source *types.InputFile)

	// ReadFile - reads a file from the volume into the supplied Contents io.Writer,
	// response will be sent to a provided Response channel
	ReadFile(destination *types.OutputFile)

	// StatFile - reads type and size of a file,
	// response will be sent to a provided Response channel
	StatFile(destination *types.OutputFile)

	// DumpState is used for diagnostics
	DumpState() *FSMStateDump
}

type FSMStateDump

type FSMStateDump struct {
	Filesystem              *types.Filesystem
	Status                  string
	CurrentState            string
	LastTransitionTimestamp int64

	LastTransferRequest   types.TransferRequest
	LastTransferRequestID string

	HandoffRequest *types.Event

	DirtyDelta int64
	SizeBytes  int64
}

type FsConfig

type FsConfig struct {
	Config config.Config

	FilesystemID    string
	StateManager    StateManager
	Registry        registry.Registry
	UserManager     user.UserManager
	RegistryStore   store.RegistryStore
	FilesystemStore store.FilesystemStore
	ServerStore     store.ServerStore

	ContainerClient      container.Client
	LocalReceiveProgress observer.Observer
	NewSnapsOnMaster     observer.Observer
	DeathObserver        observer.Observer

	FilesystemMetadataTimeout int64

	// zfs executable path
	ZFSPath string
	// zpool executable path
	ZPoolPath string
	// Previously known as main.MOUNT_ZFS
	MountZFS string

	// PoolName is a required
	PoolName string
}

FsConfig used to configure individual fsm

type FsMachine

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

a "filesystem machine" or "filesystem state machine"

func NewFilesystemMachine

func NewFilesystemMachine(cfg *FsConfig) *FsMachine

NewFilesystemMachine - core functions used by files ending `state` which I couldn't think of a good place for.

func (*FsMachine) DumpState

func (f *FsMachine) DumpState() *FSMStateDump

DumpState - dumps internal FsMachine state TODO: make copies instead of returning actual pointers

func (*FsMachine) GetCurrentState

func (f *FsMachine) GetCurrentState() string

func (*FsMachine) GetMetadata

func (f *FsMachine) GetMetadata(nodeID string) map[string]string

func (*FsMachine) GetSnapshots

func (f *FsMachine) GetSnapshots(nodeID string) []*types.Snapshot

func (*FsMachine) GetStatus

func (f *FsMachine) GetStatus() string

func (*FsMachine) ID

func (f *FsMachine) ID() string

func (*FsMachine) ListLocalSnapshots

func (f *FsMachine) ListLocalSnapshots() []*types.Snapshot

func (*FsMachine) ListMetadata

func (f *FsMachine) ListMetadata() map[string]map[string]string

func (*FsMachine) ListSnapshots

func (f *FsMachine) ListSnapshots() map[string][]*types.Snapshot

func (*FsMachine) Mount

func (f *FsMachine) Mount() (response *types.Event)

func (*FsMachine) Mounted

func (f *FsMachine) Mounted() bool

func (*FsMachine) PublishNewSnaps

func (f *FsMachine) PublishNewSnaps(server string, payload interface{}) error

func (*FsMachine) PushCompleted

func (f *FsMachine) PushCompleted(success bool)

func (*FsMachine) ReadFile

func (f *FsMachine) ReadFile(destination *types.OutputFile)

ReadFile - reads a file from the volume into the supplied Contents io.Writer, response will be sent to a provided Response channel

func (*FsMachine) Run

func (f *FsMachine) Run()

func (*FsMachine) SetMetadata

func (f *FsMachine) SetMetadata(nodeID string, meta map[string]string)

func (*FsMachine) SetSnapshots

func (f *FsMachine) SetSnapshots(nodeID string, snapshots []*types.Snapshot)

func (*FsMachine) StatFile

func (f *FsMachine) StatFile(source *types.OutputFile)

func (*FsMachine) Submit

func (f *FsMachine) Submit(event *types.Event, requestID string) (reply chan *types.Event, err error)

Submit - submits event to a filesystem, returning the event stream for convenience so the caller can listen for a response

func (*FsMachine) TransitionSubscribe

func (f *FsMachine) TransitionSubscribe(channel string, ch chan interface{})

func (*FsMachine) TransitionUnsubscribe

func (f *FsMachine) TransitionUnsubscribe(channel string, ch chan interface{})

func (*FsMachine) Unmount

func (f *FsMachine) Unmount() (response *types.Event)

func (*FsMachine) WriteFile

func (f *FsMachine) WriteFile(source *types.InputFile)

WriteFile - reads the supplied Contents io.Reader and writes into the volume, response will be sent to a provided Response channel

type NoCommonSnapshots

type NoCommonSnapshots struct {
	FromSnaps []*types.Snapshot
	ToSnaps   []*types.Snapshot
}

func (*NoCommonSnapshots) Error

func (e *NoCommonSnapshots) Error() string

type NoFromSnaps

type NoFromSnaps struct{}

func (*NoFromSnaps) Error

func (e *NoFromSnaps) Error() string

type StateFn

type StateFn func(*FsMachine) StateFn

state machinery

type StateManager

type StateManager interface {
	InitFilesystemMachine(filesystemId string) (FSM, error)
	GetFilesystemMachine(filesystemId string) (FSM, error)

	// ActivateFilesystem(filesystemId string) error
	AlignMountStateWithMasters(filesystemId string) error
	ActivateClone(topLevelFilesystemId, originFilesystemId, originSnapshotId, newCloneFilesystemId, newBranchName string) (string, error)
	DeleteFilesystem(filesystemId string) error
	DeleteFilesystemFromMap(filesystemId string)
	// current node ID
	NodeID() string

	UpdateSnapshotsFromKnownState(server, filesystem string, snapshots []*types.Snapshot) error
	SnapshotsFor(server string, filesystemId string) ([]types.Snapshot, error)
	SnapshotsForCurrentMaster(filesystemId string) ([]types.Snapshot, error)

	AddressesForServer(server string) []string

	RegisterNewFork(originFilesystemId, originSnapshotId, forkNamespace, forkName, forkFilesystemId string) error

	UpdateInterclusterTransfer(transferRequestId string, pollResult types.TransferPollResult)

	// TODO: move under a separate interface for Etcd related things
	MarkFilesystemAsLiveInEtcd(topLevelFilesystemId string) error
}

type ToSnapsAhead

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

func (*ToSnapsAhead) Error

func (e *ToSnapsAhead) Error() string

type ToSnapsDiverged

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

func (*ToSnapsDiverged) Error

func (e *ToSnapsDiverged) Error() string

type ToSnapsUpToDate

type ToSnapsUpToDate struct{}

func (*ToSnapsUpToDate) Error

func (e *ToSnapsUpToDate) Error() string

Jump to

Keyboard shortcuts

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