lreplica

package
v0.0.0-...-ae6cc27 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2018 License: BSD-3-Clause Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBLock

func GetDBLock(dbpath string) (*os.File, error)

GetDBLock locks the database on the given dbpath, and returns an error if the database is already in use GetDBLock also returns a pointer to the opened lock file. It is the caller's responsibility to close this file.

Types

type LocalReplica

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

LocalReplica is a replica where all methods that take a ReplicaID must be run on the host corresponding to ReplicaID

func NewLocalReplica

func NewLocalReplica(maxBackgroundCopies int, port, username, password string) (*LocalReplica, error)

NewLocalReplica constructs a LocalReplica

func (*LocalReplica) CreateSnapshot

func (r *LocalReplica) CreateSnapshot(replicaID, snapshotID string) (*strata.Snapshot, error)

CreateSnapshot is called to trigger snapshot creation on the target source. It should run on the host that corresponds to replicaID unless you know what you're doing. CreateSnapshot replaces DBPATH/backup/latest with the snapshot that it creates. No other snapshots are kept locally. TODO(agf): Have a way to pass in tags

func (*LocalReplica) Delete

func (r *LocalReplica) Delete(path string) error

Delete removes the file at |path|

func (*LocalReplica) DeleteSnapshot

func (r *LocalReplica) DeleteSnapshot(lz strata.LazySnapshotMetadata) error

DeleteSnapshot just returns nil. See CreateSnapshot() for more about how snapshots are kept locally.

func (*LocalReplica) GetSnapshot

func (r *LocalReplica) GetSnapshot(metadata strata.SnapshotMetadata) (*strata.Snapshot, error)

GetSnapshot returns a Snapshot given the specified SnapshotMetadata

func (*LocalReplica) List

func (r *LocalReplica) List(path string, n int) ([]string, error)

List returns up to |n| files on |path| This list does not include any directories

func (*LocalReplica) MaxBackgroundCopies

func (r *LocalReplica) MaxBackgroundCopies() int

MaxBackgroundCopies returns the maximum number of copies that CreateSnapshot() and RestoreSnapshot() should perform in the background.

func (*LocalReplica) PrepareToRestoreSnapshot

func (r *LocalReplica) PrepareToRestoreSnapshot(replicaID string, targetPath string, s *strata.Snapshot) (string, error)

PrepareToRestoreSnapshot checks that the necessary directories exist and are not being used

func (*LocalReplica) PutReader

func (r *LocalReplica) PutReader(path string, reader io.Reader) error

PutReader writes a file to |path|

func (r *LocalReplica) PutSoftlink(pointingTo, path string) error

PutSoftlink creates a softlink

func (*LocalReplica) Same

func (r *LocalReplica) Same(path string, file strata.File) (bool, error)

Same checks that the file at |path| has the same partial checksum as |file|

type MockLocalReplica

type MockLocalReplica struct {
	LocalReplica
}

MockLocalReplica mocks LocalReplica

func NewMockLocalReplica

func NewMockLocalReplica(mongo *mgotest.Server, maxBackgroundCopies int) *MockLocalReplica

NewMockLocalReplica constructs a MockLocalReplica

Jump to

Keyboard shortcuts

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