datalayer

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadBlobDiff

func DownloadBlobDiff(
	s Storage,
	encdec encdec.Factory,
	vsid volumeset.ID,
	ssid snapshot.ID,
	base blob.ID,
	token string,
	e executor.Executor,
	hf dlhash.Factory,
	dspuburl string,
) (blob.ID, uint64, uint64, error)

DownloadBlobDiff receives records from an HTTP server, apply them to the local backing storage.

func EncDecFactory

func EncDecFactory(t encdec.Type) (encdec.Factory, error)

EncDecFactory returns a enc/dec factory instance based on the type given

func HashFactory

func HashFactory(t dlhash.Type) (dlhash.Factory, error)

HashFactory returns a hash factory instance based on the type given

func ReceiveDiff

func ReceiveDiff(src io.Reader, mntPath securefilepath.SecureFilePath, e executor.Executor) error

ReceiveDiff reads records from the source, send them to the applier

func SendDiff

func SendDiff(s Storage, baseBlobID blob.ID, targetBlobID blob.ID, encdec encdec.Factory, hf dlhash.Factory,
	target io.Writer) error

SendDiff sends records to a server, records are read from a channel

func SendRecords

func SendRecords(encdec encdec.Factory, records <-chan record.Record, target io.Writer, cancelCh chan<- bool) error

SendRecords reads records from the channel, encode and send them to the target(for example an http link). Stops only after received all records. In case of error, will notify differ to stop through the cancel channel.

func UploadBlobDiff

func UploadBlobDiff(
	s Storage,
	encdec encdec.Factory,
	hf dlhash.Factory,
	vsid volumeset.ID,
	base blob.ID,
	targetBlobID blob.ID,
	token string,
	dspuburl string,
) error

UploadBlobDiff ...

Types

type BlobDifferFactory

type BlobDifferFactory interface {
	New(path1, path2 string, hf dlhash.Factory, exErrCh chan<- error,
		cancel <-chan bool, wg *sync.WaitGroup) <-chan record.Record
}

BlobDifferFactory defines the blob differ factory interface

type DiskSpace

type DiskSpace struct {
	// Used is an on-disk size of data contained in the data structure.
	Used uint64

	// Available is a size that's available on disk for the use by data
	// in the data structure.
	// A sum of Used and Available equals a capacity of the data structure.
	Available uint64
}

DiskSpace is a structure that describes various aspects of the on-disk space usage by various data structures such as volumes, volume sets and a whole storage. The sizes are in bytes.

type MountType

type MountType bool

MountType defines mount mode when a new volume is created

const (
	// NoAutoMount is the false value for MountType.
	// This flag is used to tell storage layer when creating a volume, set it to no automatic
	// mount mode, which means after use the volume is unmounted, and will not be mounted
	// after a reboot.
	NoAutoMount MountType = false

	// AutoMount is the true value for MountType
	// This flag is used to tell storage layer when creating a volume, set it to automatic
	// mount mode, which means after use the volume remains mounted, and will be mounted
	// after a reboot.
	AutoMount MountType = true

	// DifferChannelSize ...
	DifferChannelSize = 20
)

type SnapshotSpace

type SnapshotSpace struct {
	// LogicalSize is a visible size of data contained in the snapshot.
	LogicalSize uint64
	// DeltaFromPrevious is an on-disk size of new data in the snapshot
	// comparing to the previous snapshot.
	DeltaFromPrevious uint64
}

SnapshotSpace is a structure that describes various aspects of the space usage by a single snapshot. The sizes are in bytes.

type Storage

type Storage interface {
	// Returns the storage version
	Version() string

	// BlobDiffer returns the associated blob differ of the storage
	BlobDiffer() BlobDifferFactory

	// MountBlob mounts a blob.
	MountBlob(blob.ID) (string, error)

	// EmptyBlobID returns a blob id where a new volume can be created from
	EmptyBlobID(volumeset.ID) (blob.ID, error)

	// CreateVolume creates a volume.
	CreateVolume(volumeset.ID, blob.ID, MountType) (volume.ID, securefilepath.SecureFilePath, error)

	// DestroyVolume destroys the volume
	DestroyVolume(volumeset.ID, volume.ID) error

	// CreateSnapshot takes a snapshot off a volume
	CreateSnapshot(volumeset.ID, snapshot.ID, volume.ID) (blob.ID, error)

	// DestroySnapshot destroys an existing snapshot
	DestroySnapshot(blob.ID) error

	// DestroyVolumeSet forcefully destroys an existing volumeset(all data belongs to the volume set will
	// be permanently removed)
	DestroyVolumeSet(volumeset.ID) error

	// SnapshotExists checks if the blob
	SnapshotExists(blob.ID) (bool, error)

	// GetSnapshotSpace returns space usage statistics for a snapshot.
	GetSnapshotSpace(blob.ID) (SnapshotSpace, error)

	// GetTotalSpace returns space usage statistics for the whole storage.
	GetTotalSpace() (DiskSpace, error)

	// GetVolumesetSpace returns space usage statistics for a volume set.
	GetVolumesetSpace(vsid volumeset.ID) (DiskSpace, error)

	// Unmount unmount a previously mounted path.
	Unmount(path string) error
}

Storage defines common interface for all data storage back ends

Jump to

Keyboard shortcuts

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