metastore

package
v0.0.0-...-c5655c4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2017 License: Apache-2.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindNonMissingSnapshot

func FindNonMissingSnapshot(
	mds Store,
	targetID snapshot.ID,
	baseCandidateIDs []snapshot.ID,
) (*snapshot.ID, blob.ID, error)

FindNonMissingSnapshot walks the given snapshot list backwards, returns the first snapshot that the meta data store doesn't have, it can be used as the upload base.

Assumptions: 1. baseCandidateIDs[] is a list of snapshots from oldest to newest 2. If a store has blob A, then it has all blobs older than A

func GetAllVolumes

func GetAllVolumes(mds Client) ([]*volume.Volume, error)

GetAllVolumes ..

func GetBlobID

func GetBlobID(mds Store, snapid snapshot.ID) (blob.ID, error)

GetBlobID returns a snapshot's blob id

func GetBranch

func GetBranch(mds Syncable, vsid volumeset.ID, branchid branch.ID) (*branch.Branch, error)

GetBranch ..

func GetBranches

func GetBranches(mds Syncable, q branch.Query) ([]*branch.Branch, error)

GetBranches ..

func GetBushes

func GetBushes(mds Store, vsid volumeset.ID) ([]*bush.Bush, error)

GetBushes all bushes of a volume set Note: This is slow, since it is not used often, ok to do it this way for now instead of going to DB

func GetSnapshot

func GetSnapshot(mds Syncable, id snapshot.ID) (*snapshot.Snapshot, error)

GetSnapshot is a wrapper for reading a snapshot by ID.

func GetSnapshots

func GetSnapshots(mds Syncable, q snapshot.Query) ([]*snapshot.Snapshot, error)

GetSnapshots gets all the mds's snapshots and filters them based on query.

func GetSnapshotsByBranch

func GetSnapshotsByBranch(mds Syncable, q branch.Query) ([]*snapshot.Snapshot, error)

GetSnapshotsByBranch finds all snapshots that belongs to a particular branch. The order will be from tip to the root.

func GetVolume

func GetVolume(mds Client, vid volume.ID) (*volume.Volume, error)

GetVolume calls MDS client's update volume

func GetVolumeSet

func GetVolumeSet(mds Syncable, id volumeset.ID) (*volumeset.VolumeSet, error)

GetVolumeSet ..

func GetVolumeSetBySnapID

func GetVolumeSetBySnapID(mds Store, sid snapshot.ID) (volumeset.ID, error)

GetVolumeSetBySnapID retrieves a volumeset id by a snapshot id(assume snapshot id is globally unique)

func GetVolumeSets

func GetVolumeSets(mds Syncable, q volumeset.Query) ([]*volumeset.VolumeSet, error)

GetVolumeSets ..

func GetVolumes

func GetVolumes(mds Client, vsid volumeset.ID) ([]*volume.Volume, error)

GetVolumes calls MDS client's update volumes

func RenameBranch

func RenameBranch(mds Store, vsid volumeset.ID, oldName, newName string) error

RenameBranch wraps the MDS's rename name branch

func RequestBlobDiff

func RequestBlobDiff(
	mds Store,
	targetID snapshot.ID,
	baseCandidateIDs []snapshot.ID,
) (*snapshot.ID, blob.ID, blob.ID, error)

RequestBlobDiff asks the MDS to share a blob diff which will produce the blob for a particular snapshot. The MDS can select from a slice of base blobs on which to base the diff. It can also decline to share the diff entirely.

func SnapshotExtend

func SnapshotExtend(
	mds Store,
	ssid snapshot.ID,
	parentID *snapshot.ID,
	blobid blob.ID,
	a attrs.Attrs,
	name string,
	size uint64,
	desc string,
) (*snapshot.Snapshot, error)

SnapshotExtend creates a new snapshot and makes it the new tip of an existing branch.

func SnapshotFork

func SnapshotFork(
	mds Store,
	vsid volumeset.ID,
	ssid snapshot.ID,
	branchName string,
	parentID *snapshot.ID,
	blobid blob.ID,
	a attrs.Attrs,
	name string,
	size uint64,
	desc string,
) (*snapshot.Snapshot, error)

SnapshotFork creates a new snapshot and makes it the tip of the indicated branch name.

func UpdateSnapshot

func UpdateSnapshot(mds Store, snap *snapshot.Snapshot) error

UpdateSnapshot calls MDS's update snapshot, it might update some of the snapshott's field before calling, for example, set last motified time to current time.

func UpdateVolume

func UpdateVolume(mds Client, v *volume.Volume) error

UpdateVolume calls MDS client's update volume

func UpdateVolumeSet

func UpdateVolumeSet(mds Syncable, vs *volumeset.VolumeSet) error

UpdateVolumeSet calls MDS's update volume set, it might update some of the volume set's field before calling, for example, set volume set's last motified time to current time.

func ValidateBranchName

func ValidateBranchName(name string) error

ValidateBranchName ...

func VolumeSet

func VolumeSet(mds Syncable, n string, p string, a attrs.Attrs, d string, o, c string) (*volumeset.VolumeSet, error)

VolumeSet assigns a random ID, random owner/creator to the given volume set and calls meta data storage to create a new record

Types

type BranchMetaConflict

type BranchMetaConflict struct {
	Tgt, Cur, Init *branch.Branch
}

BranchMetaConflict - array of these is used for reporting conflicts in branch metadata

func (BranchMetaConflict) IsEmpty

func (b BranchMetaConflict) IsEmpty() bool

IsEmpty ...

type Client

type Client interface {
	Store

	// ImportVolume ...
	ImportVolume(v *volume.Volume) error

	// GetVolume ...
	GetVolume(vid volume.ID) (*volume.Volume, error)

	// DeleteVolume ...
	DeleteVolume(vid volume.ID) error

	// GetVolumes returns all volumes that belongs to the given volumeset ordered by the
	// volume's ID in ascending order
	GetVolumes(vsid volumeset.ID) ([]*volume.Volume, error)

	// UpdateVolume ...
	UpdateVolume(v *volume.Volume) error

	// NumVolumes returns the number of volumes created from the given snapshot
	NumVolumes(snapid snapshot.ID) (int, error)

	// NumChildren returns number of snapshots created from the given snapshot
	NumChildren(snapid snapshot.ID) (int, error)

	// DeleteSnapshots deletes a series of snapshots
	DeleteSnapshots(snaps []*snapshot.Snapshot, tip *snapshot.Snapshot) error
}

Client supports volume, and it can be used a client like dpcli.

type ErrAlreadyHaveBlob

type ErrAlreadyHaveBlob struct{}

ErrAlreadyHaveBlob is returned when an offer is made for a blob diff but the blob data is already present and the offer is declined.

func (*ErrAlreadyHaveBlob) Error

func (e *ErrAlreadyHaveBlob) Error() string

type ErrBranchNotFound

type ErrBranchNotFound struct{}

ErrBranchNotFound ...

func (*ErrBranchNotFound) Error

func (e *ErrBranchNotFound) Error() string

type ErrSnapshotImportMismatch

type ErrSnapshotImportMismatch struct{}

ErrSnapshotImportMismatch ...

func (*ErrSnapshotImportMismatch) Error

func (e *ErrSnapshotImportMismatch) Error() string

type ErrSnapshotNotFound

type ErrSnapshotNotFound struct{}

ErrSnapshotNotFound ...

func (*ErrSnapshotNotFound) Error

func (e *ErrSnapshotNotFound) Error() string

type ErrVolumeNotFound

type ErrVolumeNotFound struct{}

ErrVolumeNotFound ..

func (*ErrVolumeNotFound) Error

func (e *ErrVolumeNotFound) Error() string

type ErrVolumeSetAlreadyExists

type ErrVolumeSetAlreadyExists struct{}

ErrVolumeSetAlreadyExists ...

func (*ErrVolumeSetAlreadyExists) Error

func (e *ErrVolumeSetAlreadyExists) Error() string

type ErrVolumeSetNotFound

type ErrVolumeSetNotFound struct{}

ErrVolumeSetNotFound ....

func (*ErrVolumeSetNotFound) Error

func (e *ErrVolumeSetNotFound) Error() string

type MdsTriplet

type MdsTriplet struct {
	Tgt, Cur, Init Syncable
}

MdsTriplet holds 3 stores for syncs and conflict resolution. Used for push and conflict resolution.

type MdsTuple

type MdsTuple struct {
	Tgt, Cur Syncable
}

MdsTuple holds 2 stores for pull operations. Pull has no conflict resolution

type ResolveStatus

type ResolveStatus int

ResolveStatus ..

const (
	// NoAction = all three versions are the same, no action required
	NoAction ResolveStatus = iota
	// UseCurrent = current has changed while target and initial are not
	UseCurrent
	// UseTgtNoConflict = target changed while current and initial are not
	UseTgtNoConflict
	// UseTgtConflict = target and current both have changed
	UseTgtConflict
)

type Server

type Server interface {
	Store

	// DiskSpaceUsage returns disk space used by all given volume sets
	DiskSpaceUsage(vsids []volumeset.ID) (uint64, error)
}

Server supports disk space usage, likely used by a volume hub server.

type SnapMetaConflict

type SnapMetaConflict struct {
	Tgt  *snapshot.Snapshot `json:"target"`
	Cur  *snapshot.Snapshot `json:"current"`
	Init *snapshot.Snapshot `json:"init"`
}

SnapMetaConflict - array of these is used for reporting conflicts in snap metadata

func (SnapMetaConflict) IsEmpty

func (s SnapMetaConflict) IsEmpty() bool

IsEmpty ...

type SnapshotPair

type SnapshotPair struct {
	// Cur is the current and latest version of the snapshot
	Cur *snapshot.Snapshot
	// Init is the version that Cur is based on
	Init *snapshot.Snapshot
}

SnapshotPair holds a pair of snapshots. It is a helper struct for updating a batch of snapshots.

type Store

type Store interface {
	Syncable

	// SetVolumeSetSize updates a volume set's size
	// Note: Didn't want to overload UpdateVolumeSet() because want this be explicitly called.
	SetVolumeSetSize(vsid volumeset.ID, size uint64) error

	// UpdateSnapshot updates one snapshot
	UpdateSnapshot(snapCur, snapInit *snapshot.Snapshot) (SnapMetaConflict, error)

	// DeleteVolumeSet irrevocably discards the data associated with the
	// given unique identifier
	DeleteVolumeSet(vsid volumeset.ID) error

	// RenameBranch changes the name of an existing branch.
	RenameBranch(vsid volumeset.ID, oldName, newName string) error

	// ImportBush creates a new bush
	ImportBush(bush *bush.Bush) error

	// GetBush retrieves a bush by any snapshot id
	GetBush(snapid snapshot.ID) (*bush.Bush, error)

	// DeleteBush deletes a bush
	DeleteBush(root snapshot.ID) error

	// GetBlobIDs looks up a blob previously associated with a snapshot.  If there
	// is no such association, a nil blob identifier is returned.
	GetBlobIDs(snapids []snapshot.ID) (map[snapshot.ID]blob.ID, error)

	// SetBlobIDAndSize sets a snapshot's blob id and disk space used by the blob
	SetBlobIDAndSize(snapshot.ID, blob.ID, uint64) error
}

Store is the basic MDS who supports all interfaces but client side of things (like volume). It can be used by dataplane server.

type SyncMode

type SyncMode bool

SyncMode is a type for volume set sync mode

const (
	// AutoSync means branch tip grow/new while doing volumeset sync is done programmatically
	AutoSync SyncMode = true

	// ManualSync means branch tip grow/new while doing volumeset sync is done based on the user's input
	ManualSync SyncMode = false
)

type Syncable

type Syncable interface {
	// ImportVolumeSet creates a new volumeset.
	ImportVolumeSet(vs *volumeset.VolumeSet) error

	// GetVolumeSets ..
	GetVolumeSets(q volumeset.Query) ([]*volumeset.VolumeSet, error)

	// GetTip returns the tip of the named branch, or an error if the branch doesn't exist.
	GetTip(vsid volumeset.ID, branch string) (*snapshot.Snapshot, error)

	// GetBranches returns the names of all the branches in the volumeset.
	GetBranches(q branch.Query) ([]*branch.Branch, error)

	// ForkBranch creates a new branch with the given snapshots, branch name can be empty.
	// The new branch is forked off the first snapshot's parent; parent can be nil which means this is a
	// brand new branch.
	// A new random branch id is generated.
	// Assumes the given snapshots belong to the same lineage(snapshots[i] is the parent of snapshots[i-1]).
	ForkBranch(branchName string, snapshots ...*snapshot.Snapshot) error

	// ExtendBranch extends an existing branch with the given snapshots.
	ExtendBranch(snapshots ...*snapshot.Snapshot) error

	// ImportBranch is similar to ForkBranch() but with a given branch id.
	ImportBranch(branchID branch.ID, branchName string, snapshots ...*snapshot.Snapshot) error

	// UpdateVolumeSet updates a volume set's meta data based on the given set of
	// volume sets. Current is what the caller's current desired value, initial is the caller's
	// had before the change to current.
	// Based on the two volume set(or one, initial can be empty), target decides what to do
	// based on the three way sync protocol, details in postgres or sqlite3 implementation.
	UpdateVolumeSet(vsCur, vsInit *volumeset.VolumeSet) (VSMetaConflict, error)

	// PullVolumeSet is almost identical to UpdateVolumeSet except it doesn't actully update target.
	PullVolumeSet(vsCur, vsInit *volumeset.VolumeSet) (VSMetaConflict, error)

	// UpdateSnapshots updates an array of snapshots similar to UpdateVolumeSets
	UpdateSnapshots([]*SnapshotPair) ([]SnapMetaConflict, error)

	// PullSnapshots is almost identical to UpdateSnapshots except it doesn't actully update target.
	PullSnapshots([]*SnapshotPair) ([]SnapMetaConflict, error)

	// GetSnapshots ...
	GetSnapshots(q snapshot.Query) ([]*snapshot.Snapshot, error)

	// GetSnapshotIDs returns IDs of all snapshots in a volume set.
	// Returns empty [] when there is no snapshot in the volume set.
	GetSnapshotIDs(vsid volumeset.ID) ([]snapshot.ID, error)
}

Syncable supports all volumeset related methods and can be used for sync meta data between two meta data storages. This is used by restful MDS to transfer meta from one MDS to another.

type VSMetaConflict

type VSMetaConflict struct {
	Tgt  *volumeset.VolumeSet `json:"target"`
	Cur  *volumeset.VolumeSet `json:"current"`
	Init *volumeset.VolumeSet `json:"init"`
}

VSMetaConflict - array of these is used for reporting conflicts in volumeset metadata

func (VSMetaConflict) IsEmpty

func (v VSMetaConflict) IsEmpty() bool

IsEmpty ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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