volume

package
v0.0.0-...-e27f3f3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuperBlockSize = 8
)

Variables

This section is empty.

Functions

func CheckDataIntegrity

func CheckDataIntegrity(v *Volume, indexFile *os.File) error

func SortVolumeInfos

func SortVolumeInfos(vis volumeInfos)

func VolumeFileName

func VolumeFileName(collection string, dir string, id int) (fileName string)

Types

type FileId

type FileId struct {
	VolumeId util.VIDType
	Key      uint64
	Hashcode uint32
}

func NewFileIdFromNeedle

func NewFileIdFromNeedle(VolumeId util.VIDType, n *needle.Needle) *FileId

func (*FileId) String

func (n *FileId) String() string

type GrowOption

type GrowOption struct {
	Collection       string
	ReplicaPlacement *replicate.Placement
	Ttl              *ttl.TTL
	DataCenter       string
	Rack             string
	DataNode         string
}

type SuperBlock

type SuperBlock struct {
	ReplicaPlacement *replicate.Placement
	Ttl              *ttl.TTL
	CompactRevision  uint16
	// contains filtered or unexported fields
}

* Super block currently has 8 bytes allocated for each volume. * Byte 0: version, 1 or 2 * Byte 1: Replica Placement strategy, 000, 001, 002, 010, etc * Byte 2 and byte 3: Time to live. See TTL for definition * Byte 4 and byte 5: The number of times the volume has been compacted. * Rest bytes: Reserved

func ParseSuperBlock

func ParseSuperBlock(header []byte) (superBlock SuperBlock, err error)

func (*SuperBlock) Bytes

func (s *SuperBlock) Bytes() []byte

func (*SuperBlock) Version

func (s *SuperBlock) Version() version.Version

type Volume

type Volume struct {
	Id util.VIDType

	Collection string

	NM       needle.Mapper
	ReadOnly bool

	SuperBlock
	// contains filtered or unexported fields
}

func NewVolume

func NewVolume(dirname string, collection string, id util.VIDType,
	replicaPlacement *replicate.Placement,
	ttl *ttl.TTL, preallocate int64) (v *Volume, e error)

func (*Volume) Close

func (v *Volume) Close()

Close cleanly shuts down this volume

func (*Volume) CommitCompact

func (v *Volume) CommitCompact() error

TODO

func (*Volume) Compact

func (v *Volume) Compact() error

TODO

func (*Volume) ContentSize

func (v *Volume) ContentSize() uint64

func (*Volume) DeleteNeedle

func (v *Volume) DeleteNeedle(n *needle.Needle) (uint32, error)

func (*Volume) Destroy

func (v *Volume) Destroy() (err error)

Destroy removes everything related to this volume

func (*Volume) ExiredLongEnough

func (v *Volume) ExiredLongEnough(maxDelayMinutes uint32) bool

wait either maxDelayMinutes or 10% of ttl minutes

func (*Volume) Expired

func (v *Volume) Expired(volumeSizeLimit uint64) bool

func (*Volume) FileName

func (v *Volume) FileName() (fileName string)

func (*Volume) FileStat

func (v *Volume) FileStat() (datSize uint64, idxSize uint64, modTime time.Time)

func (*Volume) GarbageLevel

func (v *Volume) GarbageLevel() float64

func (*Volume) NeedToReplicate

func (v *Volume) NeedToReplicate() bool

func (*Volume) ReadNeedle

func (v *Volume) ReadNeedle(n *needle.Needle) (int, error)

read fills in Needle content by looking up n.Id from NeedleMapper

func (*Volume) Size

func (v *Volume) Size() int64

func (*Volume) ToVolumeInformationMessage

func (v *Volume) ToVolumeInformationMessage() *pb.VolumeInformationMessage

func (*Volume) WriteNeedle

func (v *Volume) WriteNeedle(n *needle.Needle) (size uint32, isUnchanged bool, err error)

type VolumeInfo

type VolumeInfo struct {
	Id               util.VIDType `json:"ID"`
	Size             uint64       `json:"Size"`
	ReplicaPlacement *replicate.Placement
	Ttl              *ttl.TTL `json:"TTL"`
	Collection       string
	Version          version.Version `json:"Version"`
	FileCount        int             `json:"FileCount"`
	DeleteCount      int             `json:"DeleteCount"`
	DeletedByteCount uint64          `json:"DeletedByteCount"`
	ReadOnly         bool            `json:"ReadOnly"`
}

func NewVolumeInfo

func NewVolumeInfo(m *pb.VolumeInformationMessage) (vi VolumeInfo, err error)

func (VolumeInfo) String

func (vi VolumeInfo) String() string

Jump to

Keyboard shortcuts

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