snapstore

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: Apache-2.0, MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// SnapstoreProviderLocal is constant for local disk storage provider.
	SnapstoreProviderLocal = "Local"
	// SnapstoreProviderS3 is constant for aws S3 storage provider.
	SnapstoreProviderS3 = "S3"
	// SnapstoreProviderABS is constant for azure blob storage provider.
	SnapstoreProviderABS = "ABS"
	// SnapstoreProviderGCS is constant for GCS object storage provider.
	SnapstoreProviderGCS = "GCS"
	// SnapstoreProviderSwift is constant for Swift object storage.
	SnapstoreProviderSwift = "Swift"
	// SnapstoreProviderOSS is constant for Alicloud OSS storage provider.
	SnapstoreProviderOSS = "OSS"
	// SnapshotKindFull is constant for full snapshot kind.
	SnapshotKindFull = "Full"
	// SnapshotKindDelta is constant for delta snapshot kind.
	SnapshotKindDelta = "Incr"
	// SnapshotKindChunk is constant for chunk snapshot kind.
	SnapshotKindChunk = "Chunk"

	// AzureBlobStorageHostName is the host name for azure blob storage service.
	AzureBlobStorageHostName = "blob.core.windows.net"
)

Variables

This section is empty.

Functions

func GetEnvVarOrError

func GetEnvVarOrError(varName string) (string, error)

GetEnvVarOrError returns the value of specified environment variable or terminates if it's not defined.

Types

type ABSSnapStore

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

ABSSnapStore is an ABS backed snapstore.

func GetABSSnapstoreFromClient

func GetABSSnapstoreFromClient(container, prefix, tempDir string, maxParallelChunkUploads int, containerURL *azblob.ContainerURL) (*ABSSnapStore, error)

GetABSSnapstoreFromClient returns a new ABS object for a given container using the supplied storageClient

func NewABSSnapStore

func NewABSSnapStore(container, prefix, tempDir string, maxParallelChunkUploads int) (*ABSSnapStore, error)

NewABSSnapStore create new ABSSnapStore from shared configuration with specified bucket

func (*ABSSnapStore) Delete

func (a *ABSSnapStore) Delete(snap Snapshot) error

Delete should delete the snapshot file from store

func (*ABSSnapStore) Fetch

func (a *ABSSnapStore) Fetch(snap Snapshot) (io.ReadCloser, error)

Fetch should open reader for the snapshot file from store

func (*ABSSnapStore) List

func (a *ABSSnapStore) List() (SnapList, error)

List will list all snapshot files on store

func (*ABSSnapStore) Save

func (a *ABSSnapStore) Save(snap Snapshot, rc io.ReadCloser) error

Save will write the snapshot to store

type Config

type Config struct {
	// Provider indicated the cloud provider.
	Provider string
	// Container holds the name of bucket or container to which snapshot will be stored.
	Container string
	// Prefix holds the prefix or directory under StorageContainer under which snapshot will be stored.
	Prefix string
	// MaxParallelChunkUploads hold the maximum number of parallel chunk uploads allowed.
	MaxParallelChunkUploads int
	// Temporary Directory
	TempDir string
}

Config defines the configuration to create snapshot store.

type GCSSnapStore

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

GCSSnapStore is snapstore with GCS object store as backend.

func NewGCSSnapStore

func NewGCSSnapStore(bucket, prefix, tempDir string, maxParallelChunkUploads int) (*GCSSnapStore, error)

NewGCSSnapStore create new GCSSnapStore from shared configuration with specified bucket.

func NewGCSSnapStoreFromClient

func NewGCSSnapStoreFromClient(bucket, prefix, tempDir string, maxParallelChunkUploads int, cli stiface.Client) *GCSSnapStore

NewGCSSnapStoreFromClient create new GCSSnapStore from shared configuration with specified bucket.

func (*GCSSnapStore) Delete

func (s *GCSSnapStore) Delete(snap Snapshot) error

Delete should delete the snapshot file from store.

func (*GCSSnapStore) Fetch

func (s *GCSSnapStore) Fetch(snap Snapshot) (io.ReadCloser, error)

Fetch should open reader for the snapshot file from store.

func (*GCSSnapStore) List

func (s *GCSSnapStore) List() (SnapList, error)

List will list the snapshots from store.

func (*GCSSnapStore) Save

func (s *GCSSnapStore) Save(snap Snapshot, rc io.ReadCloser) error

Save will write the snapshot to store.

type LocalSnapStore

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

LocalSnapStore is snapstore with local disk as backend

func NewLocalSnapStore

func NewLocalSnapStore(prefix string) (*LocalSnapStore, error)

NewLocalSnapStore return the new local disk based snapstore

func (*LocalSnapStore) Delete

func (s *LocalSnapStore) Delete(snap Snapshot) error

Delete should delete the snapshot file from store

func (*LocalSnapStore) Fetch

func (s *LocalSnapStore) Fetch(snap Snapshot) (io.ReadCloser, error)

Fetch should open reader for the snapshot file from store

func (*LocalSnapStore) List

func (s *LocalSnapStore) List() (SnapList, error)

List will list the snapshots from store

func (*LocalSnapStore) Save

func (s *LocalSnapStore) Save(snap Snapshot, rc io.ReadCloser) error

Save will write the snapshot to store

func (*LocalSnapStore) Size

func (s *LocalSnapStore) Size(snap Snapshot) (int64, error)

Size should return size of the snapshot file from store

type OSSBucket

type OSSBucket interface {
	GetObject(objectKey string, options ...oss.Option) (io.ReadCloser, error)
	InitiateMultipartUpload(objectKey string, options ...oss.Option) (oss.InitiateMultipartUploadResult, error)
	CompleteMultipartUpload(imur oss.InitiateMultipartUploadResult, parts []oss.UploadPart, options ...oss.Option) (oss.CompleteMultipartUploadResult, error)
	ListObjects(options ...oss.Option) (oss.ListObjectsResult, error)
	DeleteObject(objectKey string, options ...oss.Option) error
	UploadPart(imur oss.InitiateMultipartUploadResult, reader io.Reader, partSize int64, partNumber int, options ...oss.Option) (oss.UploadPart, error)
	AbortMultipartUpload(imur oss.InitiateMultipartUploadResult, options ...oss.Option) error
}

OSSBucket is an interface for oss.Bucket used in snapstore

type OSSSnapStore

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

OSSSnapStore is snapstore with Alicloud OSS object store as backend

func NewOSSFromBucket

func NewOSSFromBucket(prefix, tempDir string, maxParallelChunkUploads int, bucket OSSBucket) *OSSSnapStore

NewOSSFromBucket will create the new OSS snapstore object from OSS bucket

func NewOSSSnapStore

func NewOSSSnapStore(bucket, prefix, tempDir string, maxParallelChunkUploads int) (*OSSSnapStore, error)

NewOSSSnapStore create new OSSSnapStore from shared configuration with specified bucket

func (*OSSSnapStore) Delete

func (s *OSSSnapStore) Delete(snap Snapshot) error

Delete should delete the snapshot file from store

func (*OSSSnapStore) Fetch

func (s *OSSSnapStore) Fetch(snap Snapshot) (io.ReadCloser, error)

Fetch should open reader for the snapshot file from store

func (*OSSSnapStore) List

func (s *OSSSnapStore) List() (SnapList, error)

List will list the snapshots from store

func (*OSSSnapStore) Save

func (s *OSSSnapStore) Save(snap Snapshot, rc io.ReadCloser) error

Save will write the snapshot to store

type S3SnapStore

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

S3SnapStore is snapstore with AWS S3 object store as backend

func NewS3FromClient

func NewS3FromClient(bucket, prefix, tempDir string, maxParallelChunkUploads int, cli s3iface.S3API) *S3SnapStore

NewS3FromClient will create the new S3 snapstore object from S3 client

func NewS3SnapStore

func NewS3SnapStore(bucket, prefix, tempDir string, maxParallelChunkUploads int) (*S3SnapStore, error)

NewS3SnapStore create new S3SnapStore from shared configuration with specified bucket

func (*S3SnapStore) Delete

func (s *S3SnapStore) Delete(snap Snapshot) error

Delete should delete the snapshot file from store

func (*S3SnapStore) Fetch

func (s *S3SnapStore) Fetch(snap Snapshot) (io.ReadCloser, error)

Fetch should open reader for the snapshot file from store

func (*S3SnapStore) List

func (s *S3SnapStore) List() (SnapList, error)

List will list the snapshots from store

func (*S3SnapStore) Save

func (s *S3SnapStore) Save(snap Snapshot, rc io.ReadCloser) error

Save will write the snapshot to store

type SnapList

type SnapList []*Snapshot

SnapList is list of snapshots.

func (SnapList) Len

func (s SnapList) Len() int

SnapList override sorting related function

func (SnapList) Less

func (s SnapList) Less(i, j int) bool

func (SnapList) Swap

func (s SnapList) Swap(i, j int)

type SnapStore

type SnapStore interface {
	// Fetch should open reader for the snapshot file from store.
	Fetch(Snapshot) (io.ReadCloser, error)
	// List will list all snapshot files on store.
	List() (SnapList, error)
	// Save will write the snapshot to store.
	Save(Snapshot, io.ReadCloser) error
	// Delete should delete the snapshot file from store.
	Delete(Snapshot) error
}

SnapStore is the interface to be implemented for different storage backend like local file system, S3, ABS, GCS, Swift, OSS etc. Only purpose of these implementation to provide CPI layer to access files.

func GetSnapstore

func GetSnapstore(config *Config) (SnapStore, error)

GetSnapstore returns the snapstore object for give storageProvider with specified container

type Snapshot

type Snapshot struct {
	Kind          string //incr:incremental,full:full
	StartRevision int64
	LastRevision  int64 //latest revision on snapshot
	CreatedOn     time.Time
	SnapDir       string
	SnapName      string
	IsChunk       bool
}

Snapshot structure represents the metadata of snapshot.s

func NewSnapshot

func NewSnapshot(kind string, startRevision, lastRevision int64) *Snapshot

NewSnapshot returns the snapshot object.

func ParseSnapshot

func ParseSnapshot(snapPath string) (*Snapshot, error)

ParseSnapshot parse <snapPath> to create snapshot structure

func (*Snapshot) GenerateSnapshotDirectory

func (s *Snapshot) GenerateSnapshotDirectory()

GenerateSnapshotDirectory prepares the snapshot directory name from metadata

func (*Snapshot) GenerateSnapshotName

func (s *Snapshot) GenerateSnapshotName()

GenerateSnapshotName prepares the snapshot name from metadata

func (*Snapshot) GetSnapshotDirectoryCreationTimeInUnix

func (s *Snapshot) GetSnapshotDirectoryCreationTimeInUnix() (int64, error)

GetSnapshotDirectoryCreationTimeInUnix returns the creation time for snapshot directory.

type SwiftSnapStore

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

SwiftSnapStore is snapstore with Openstack Swift as backend

func NewSwiftSnapStore

func NewSwiftSnapStore(bucket, prefix, tempDir string, maxParallelChunkUploads int) (*SwiftSnapStore, error)

NewSwiftSnapStore create new SwiftSnapStore from shared configuration with specified bucket

func NewSwiftSnapstoreFromClient

func NewSwiftSnapstoreFromClient(bucket, prefix, tempDir string, maxParallelChunkUploads int, cli *gophercloud.ServiceClient) *SwiftSnapStore

NewSwiftSnapstoreFromClient will create the new Swift snapstore object from Swift client

func (*SwiftSnapStore) Delete

func (s *SwiftSnapStore) Delete(snap Snapshot) error

Delete should delete the snapshot file from store

func (*SwiftSnapStore) Fetch

func (s *SwiftSnapStore) Fetch(snap Snapshot) (io.ReadCloser, error)

Fetch should open reader for the snapshot file from store

func (*SwiftSnapStore) List

func (s *SwiftSnapStore) List() (SnapList, error)

List will list the snapshots from store

func (*SwiftSnapStore) Save

func (s *SwiftSnapStore) Save(snap Snapshot, rc io.ReadCloser) error

Save will write the snapshot to store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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