volumemanager

package
v0.0.0-...-8488f5b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDBClosed = errors.New("volume persistence db is closed")
View Source
var NoSuchProvider = errors.New("no such provider")
View Source
var NoSuchVolume = errors.New("no such volume")
View Source
var ProviderAlreadyExists = errors.New("that provider id already exists")

Functions

func NewProvider

func NewProvider(pspec *volume.ProviderSpec) (provider volume.Provider, err error)

Types

type Manager

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

volume.Manager providers interfaces for both provisioning volume backends, and then creating volumes using them.

There is one volume.Manager per host daemon process.

func New

func New(dbPath string, defaultProvider func() (volume.Provider, error)) *Manager

func (*Manager) AddProvider

func (m *Manager) AddProvider(id string, p volume.Provider) error

func (*Manager) CloseDB

func (m *Manager) CloseDB() error

CloseDB closes the persistence DB.

The DB mutex is locked to protect m.db, but also prevents closing the DB when it could still be needed to service API requests (see LockDB).

func (*Manager) CreateSnapshot

func (m *Manager) CreateSnapshot(id string) (volume.Volume, error)

func (*Manager) DestroyVolume

func (m *Manager) DestroyVolume(id string) error

func (*Manager) ForkVolume

func (m *Manager) ForkVolume(id string) (volume.Volume, error)

func (*Manager) GetVolume

func (m *Manager) GetVolume(id string) volume.Volume

func (*Manager) ListHaves

func (m *Manager) ListHaves(id string) ([]json.RawMessage, error)

func (*Manager) LockDB

func (m *Manager) LockDB() error

LockDB acquires a read lock on the DB mutex so that it cannot be closed until the caller has finished performing actions which will lead to changes being persisted to the DB.

For example, creating a volume first delegates to the provider to create the volume and then persists to the DB, but if the DB is closed in that time then the volume state will be lost.

ErrDBClosed is returned if the DB is already closed so API requests will fail before any actions are performed.

func (*Manager) NewVolume

func (m *Manager) NewVolume() (volume.Volume, error)

volume.Manager implements the volume.Provider interface by delegating NewVolume requests to the default Provider.

func (*Manager) NewVolumeFromProvider

func (m *Manager) NewVolumeFromProvider(providerID string) (volume.Volume, error)

volume.Manager implements the volume.Provider interface by delegating NewVolume requests to the named Provider.

func (*Manager) OpenDB

func (m *Manager) OpenDB() error

OpenDB opens and initialises the persistence DB, if not already open.

func (*Manager) ReceiveSnapshot

func (m *Manager) ReceiveSnapshot(id string, stream io.Reader) (volume.Volume, error)

func (*Manager) SendSnapshot

func (m *Manager) SendSnapshot(id string, haves []json.RawMessage, stream io.Writer) error

func (*Manager) UnlockDB

func (m *Manager) UnlockDB()

UnlockDB releases a read lock on the DB mutex, previously acquired by a call to LockDB.

func (*Manager) Volumes

func (m *Manager) Volumes() map[string]volume.Volume

Jump to

Keyboard shortcuts

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