replica

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpCoalesce = "coalesce" // Source is parent, target is child
	OpRemove   = "remove"
	OpReplace  = "replace"
)
View Source
const (
	Initial    = State("initial")
	Open       = State("open")
	Closed     = State("closed")
	Dirty      = State("dirty")
	Rebuilding = State("rebuilding")
	Error      = State("error")
)

Variables

View Source
var ActionChannel chan string
View Source
var HoleCreatorChan = make(chan Hole, 1000000)
View Source
var StartTime time.Time

Functions

func CreateHoles

func CreateHoles()

CreateHoles removes the offsets from corresponding sparse files

func GenerateSnapshotDiskName

func GenerateSnapshotDiskName(name string) string

func GetSnapshotNameFromDiskName

func GetSnapshotNameFromDiskName(diskName string) (string, error)

func IsHeadDisk

func IsHeadDisk(diskName string) bool

func PreloadLunMap

func PreloadLunMap(d *diffDisk) error

func SliceContains added in v1.12.1

func SliceContains(chain []string, item string) bool

Types

type BackingFile

type BackingFile struct {
	Size       int64
	SectorSize int64
	Name       string
	Disk       types.DiffDisk
}

type DiskInfo

type DiskInfo struct {
	Name            string   `json:"name"`
	Parent          string   `json:"parent"`
	Children        []string `json:"children"`
	Removed         bool     `json:"removed"`
	UserCreated     bool     `json:"usercreated"`
	Created         string   `json:"created"`
	Size            string   `json:"size"`
	RevisionCounter int64    `json:"revisionCount"`
}

type Hole

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

Hole holds the fd, len and offset for fallocate operation

type Info

type Info struct {
	Size            int64
	Head            string
	Dirty           bool
	Rebuilding      bool
	Parent          string
	SectorSize      int64
	BackingFileName string
	CloneStatus     string
	Checkpoint      string
	BackingFile     *BackingFile `json:"-"`
	RevisionCounter int64
}

func ReadInfo

func ReadInfo(dir string) (Info, error)

type PrepareRemoveAction

type PrepareRemoveAction struct {
	Action string `json:"action"`
	Source string `json:"source"`
	Target string `json:"target"`
}

type Replica

type Replica struct {
	sync.RWMutex

	ReplicaStartTime time.Time
	ReplicaType      string

	CloneSnapName string
	Clone         bool
	// contains filtered or unexported fields
}

func CreateTempReplica

func CreateTempReplica() (*Replica, error)

func New

func New(preload bool, size, sectorSize int64, dir string, backingFile *BackingFile, replicaType string) (*Replica, error)

func NewReadOnly

func NewReadOnly(preload bool, dir, head string, backingFile *BackingFile) (*Replica, error)

func (*Replica) Chain

func (r *Replica) Chain() ([]string, error)

Chain returns the disk chain starting with Head(index=0), till the base snapshot

func (*Replica) Close

func (r *Replica) Close() error

func (*Replica) Delete

func (r *Replica) Delete() error

func (*Replica) DeleteAll

func (r *Replica) DeleteAll() error

func (*Replica) DisplayChain

func (r *Replica) DisplayChain() ([]string, error)

func (*Replica) GetCloneStatus

func (r *Replica) GetCloneStatus() string

func (*Replica) GetRemainSnapshotCounts

func (r *Replica) GetRemainSnapshotCounts() int

func (*Replica) GetReplicaMode

func (r *Replica) GetReplicaMode() string

GetReplicaMode ...

func (*Replica) GetRevisionCounter

func (r *Replica) GetRevisionCounter() int64

func (*Replica) GetUsage

func (r *Replica) GetUsage() (*types.VolUsage, error)

func (*Replica) GetUsedBlocks

func (r *Replica) GetUsedBlocks() string

func (*Replica) GetUsedLogicalBlocks

func (r *Replica) GetUsedLogicalBlocks() string

func (*Replica) Info

func (r *Replica) Info() Info

func (*Replica) ListDisks

func (r *Replica) ListDisks() map[string]types.DiskInfo

func (*Replica) PrepareRemoveDisk

func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error)

PrepareRemoveDisk mark and prepare the list of the disks that is going to be deleted. NOTE: We don't delete latest snapshot because the data needs to be merged into Head file where IO's are being precessed that means we need to block IO's for some time till this get precessed.

func (*Replica) ReadAt

func (r *Replica) ReadAt(buf []byte, offset int64) (int, error)

func (*Replica) Reload

func (r *Replica) Reload(preload bool) (*Replica, error)

func (*Replica) RemoveDiffDisk

func (r *Replica) RemoveDiffDisk(name string) error

func (*Replica) ReplaceDisk

func (r *Replica) ReplaceDisk(target, source string) error

ReplaceDisk replace the source with target snapshot and remove and close both source and target and open new instance of file for R/W and update the file index with new reference. If replace disk is being used then it is possible to delete a snapshot whose parent or child is user created

func (*Replica) Resize

func (r *Replica) Resize(obj interface{}) error

func (*Replica) Revert

func (r *Replica) Revert(name, created string) (*Replica, error)

func (*Replica) SetCheckpoint added in v1.12.1

func (r *Replica) SetCheckpoint(snapshotName string) error

SetCheckpoint ...

func (*Replica) SetCloneStatus

func (r *Replica) SetCloneStatus(status string) error

func (*Replica) SetRebuilding

func (r *Replica) SetRebuilding(rebuilding bool) error

func (*Replica) SetReplicaMode

func (r *Replica) SetReplicaMode(mode string) error

SetReplicaMode ...

func (*Replica) SetRevisionCounter

func (r *Replica) SetRevisionCounter(counter int64) error

func (*Replica) SetRevisionCounterCloneReplica

func (r *Replica) SetRevisionCounterCloneReplica(counter int64) error

SetRevisionCounterCloneReplica set revision counter for clone replica

func (*Replica) Snapshot

func (r *Replica) Snapshot(name string, userCreated bool, created string) error

func (*Replica) Sync

func (r *Replica) Sync() (int, error)

func (*Replica) Unmap

func (r *Replica) Unmap(offset int64, length int64) (int, error)

func (*Replica) UpdateCloneInfo

func (r *Replica) UpdateCloneInfo(snapName, revCount string) error

UpdateCloneInfo update the clone information such as snapshot name and revisionCount

func (*Replica) WriteAt

func (r *Replica) WriteAt(buf []byte, offset int64) (int, error)

type Server

type Server struct {
	sync.RWMutex

	ReplicaAddress string
	ServerType     string

	//This channel is used to montitor the IO connection
	//between controller and replica. If the connection is broken,
	//the replica attempts to connect back to controller
	MonitorChannel chan struct{}
	// contains filtered or unexported fields
}

func CreateTempServer

func CreateTempServer() (*Server, error)

func NewServer

func NewServer(address, dir string, sectorSize int64, serverType string) *Server

func (*Server) CheckPreDeleteConditions

func (s *Server) CheckPreDeleteConditions() error

CheckPreDeleteConditions checks if any replica exists. If it exists, it closes all the connections with the replica and deletes the entry from the controller.

func (*Server) Close

func (s *Server) Close() error

Close drain the data from HoleCreatorChan and close all the associated files with the replica instance.

func (*Server) Create

func (s *Server) Create(size int64) error

func (*Server) Delete

func (s *Server) Delete() error

Delete deletes the volume metadata and revision counter file.

func (*Server) DeleteAll

func (s *Server) DeleteAll() error

DeleteAll deletes all the contents of the mounted directory.

func (*Server) GetRevisionCounter

func (s *Server) GetRevisionCounter() (int64, error)

GetRevisionCounter reads the revison counter

func (*Server) GetUsage

func (s *Server) GetUsage() (*types.VolUsage, error)

GetUsage returns the used size of volume

func (*Server) Open

func (s *Server) Open() error

func (*Server) PingResponse

func (s *Server) PingResponse() error

func (*Server) PrepareRemoveDisk

func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error)

func (*Server) PrevStatus

func (s *Server) PrevStatus() (State, Info)

func (*Server) ReadAt

func (s *Server) ReadAt(buf []byte, offset int64) (int, error)

func (*Server) Reload

func (s *Server) Reload() error

func (*Server) RemoveDiffDisk

func (s *Server) RemoveDiffDisk(name string) error

func (*Server) ReplaceDisk

func (s *Server) ReplaceDisk(target, source string) error

func (*Server) Replica

func (s *Server) Replica() *Replica

func (*Server) Resize

func (s *Server) Resize(size string) error

func (*Server) Revert

func (s *Server) Revert(name, created string) error

func (*Server) SetCheckpoint added in v1.12.1

func (s *Server) SetCheckpoint(snapshotName string) error

SetCheckpoint ...

func (*Server) SetPreload

func (s *Server) SetPreload(preload bool) error

SetPreload sets/unsets preloadDuringOpen flag

func (*Server) SetRebuilding

func (s *Server) SetRebuilding(rebuilding bool) error

func (*Server) SetReplicaMode

func (s *Server) SetReplicaMode(mode string) error

SetReplicaMode ...

func (*Server) SetRevisionCounter

func (s *Server) SetRevisionCounter(counter int64) error

func (*Server) Snapshot

func (s *Server) Snapshot(name string, userCreated bool, createdTime string) error

func (*Server) Start

func (s *Server) Start(action string) error

func (*Server) Stats

func (s *Server) Stats() *types.Stats

Stats returns the revisionCache and Peerdetails TODO: What to return in Stats and GetUsage if s.r is nil?

func (*Server) Status

func (s *Server) Status() (State, Info)

func (*Server) Sync

func (s *Server) Sync() (int, error)

func (*Server) Unmap

func (s *Server) Unmap(offset int64, length int64) (int, error)

func (*Server) UpdateCloneInfo

func (s *Server) UpdateCloneInfo(snapName, revCount string) error

func (*Server) UpdateLUNMap

func (s *Server) UpdateLUNMap() error

UpdateLUNMap updates the original LUNmap with any changes which have been encountered after PreloadVolume. This can be called only once just after reload is called after syncing the files from healthy replicas

func (*Server) WriteAt

func (s *Server) WriteAt(buf []byte, offset int64) (int, error)

type State

type State string

type UsedGenerator

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

func (*UsedGenerator) Err

func (u *UsedGenerator) Err() error

func (*UsedGenerator) Generate

func (u *UsedGenerator) Generate() <-chan int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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