headhunter

package
v0.0.0-...-4017c26 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package headhunter manages the headhunter databases, which keep track of which log segments correspond to the current revision of a given inode.

Index

Constants

View Source
const (
	AccountHeaderName           = "X-ProxyFS-BiModal"
	AccountHeaderNameTranslated = "X-Account-Sysmeta-Proxyfs-Bimodal"
	AccountHeaderValue          = "true"
	CheckpointHeaderName        = "X-Container-Meta-Checkpoint"
	StoragePolicyHeaderName     = "X-Storage-Policy"
)
View Source
const (
	MetadataRecycleBinHeaderName  = "X-Object-Meta-Recycle-Bin"
	MetadataRecycleBinHeaderValue = "true"
)
View Source
const (
	CheckpointVersion3 uint64 = iota + 3
)

Variables

View Source
var (
	LittleEndian = cstruct.LittleEndian // All data cstruct's to be serialized in LittleEndian form
)

Functions

func DisableObjectDeletions

func DisableObjectDeletions()

DisableObjectDeletions prevents objects from being deleted until EnableObjectDeletions() is called

func EnableObjectDeletions

func EnableObjectDeletions()

EnableObjectDeletions resumes background object deletion blocked by a prior call to DisableObjectDeletions()

Types

type BPlusTreeType

type BPlusTreeType uint32
const (
	MergedBPlusTree BPlusTreeType = iota // Used only for FetchLayoutReport when a merged result is desired
	InodeRecBPlusTree
	LogSegmentRecBPlusTree
	BPlusTreeObjectBPlusTree
	CreatedObjectsBPlusTree
	DeletedObjectsBPlusTree
)

type CheckpointHeaderStruct

type CheckpointHeaderStruct struct {
	CheckpointVersion                         uint64 // either checkpointVersion2 or CheckpointVersion3
	CheckpointObjectTrailerStructObjectNumber uint64 // checkpointObjectTrailerV?Struct found at "tail" of object
	CheckpointObjectTrailerStructObjectLength uint64 // this length includes appended non-fixed sized arrays
	ReservedToNonce                           uint64 // highest nonce value reserved
}

type CheckpointObjectTrailerV3Struct

type CheckpointObjectTrailerV3Struct struct {
	InodeRecBPlusTreeObjectNumber             uint64 // if != 0, objectNumber-named Object in <accountName>.<checkpointContainerName> where root of inodeRec        B+Tree
	InodeRecBPlusTreeObjectOffset             uint64 // ...and offset into the Object where root starts
	InodeRecBPlusTreeObjectLength             uint64 // ...and length if that root node
	InodeRecBPlusTreeLayoutNumElements        uint64 // elements immediately follow CheckpointObjectTrailerV3Struct
	LogSegmentRecBPlusTreeObjectNumber        uint64 // if != 0, objectNumber-named Object in <accountName>.<checkpointContainerName> where root of logSegment      B+Tree
	LogSegmentRecBPlusTreeObjectOffset        uint64 // ...and offset into the Object where root starts
	LogSegmentRecBPlusTreeObjectLength        uint64 // ...and length if that root node
	LogSegmentRecBPlusTreeLayoutNumElements   uint64 // elements immediately follow inodeRecBPlusTreeLayout
	BPlusTreeObjectBPlusTreeObjectNumber      uint64 // if != 0, objectNumber-named Object in <accountName>.<checkpointContainerName> where root of bPlusTreeObject B+Tree
	BPlusTreeObjectBPlusTreeObjectOffset      uint64 // ...and offset into the Object where root starts
	BPlusTreeObjectBPlusTreeObjectLength      uint64 // ...and length if that root node
	BPlusTreeObjectBPlusTreeLayoutNumElements uint64 // elements immediately follow logSegmentRecBPlusTreeLayout
	CreatedObjectsBPlusTreeLayoutNumElements  uint64 // elements immediately follow bPlusTreeObjectBPlusTreeLayout
	DeletedObjectsBPlusTreeLayoutNumElements  uint64 // elements immediately follow createdObjectsBPlusTreeLayout
	SnapShotIDNumBits                         uint64 // number of bits reserved to hold SnapShotIDs
	SnapShotListNumElements                   uint64 // elements immediately follow deletedObjectsBPlusTreeLayout
	SnapShotListTotalSize                     uint64 // size of entire SnapShotList

}

type ElementOfBPlusTreeLayoutStruct

type ElementOfBPlusTreeLayoutStruct struct {
	ObjectNumber uint64
	ObjectBytes  uint64
}

type ElementOfSnapShotListStruct

type ElementOfSnapShotListStruct struct {
	Nonce uint64 //        supplies strict time-ordering of SnapShots regardless of timebase resets
	ID    uint64 //        in the range [1:2^SnapShotIDNumBits-2]
	//                       ID == 0                     reserved for the "live" view
	//                       ID == 2^SnapShotIDNumBits-1 reserved for the .snapshot subdir of a dir
	TimeStamp time.Time // serialized/deserialized as a uint64 length followed by a that sized []byte
	//                       func (t  time.Time) time.MarshalBinary()              ([]byte, error)
	//                       func (t *time.Time) time.UnmarshalBinary(data []byte) (error)
	Name string //         serialized/deserialized as a uint64 length followed by a that sized []byte
	//                       func utils.ByteSliceToString(byteSlice []byte)        (str string)
	//                       func utils.StringToByteSlice(str string)              (byteSlice []byte)
	InodeRecBPlusTreeObjectNumber        uint64
	InodeRecBPlusTreeObjectOffset        uint64
	InodeRecBPlusTreeObjectLength        uint64
	LogSegmentRecBPlusTreeObjectNumber   uint64
	LogSegmentRecBPlusTreeObjectOffset   uint64
	LogSegmentRecBPlusTreeObjectLength   uint64
	BPlusTreeObjectBPlusTreeObjectNumber uint64
	BPlusTreeObjectBPlusTreeObjectOffset uint64
	BPlusTreeObjectBPlusTreeObjectLength uint64
	CreatedObjectsBPlusTreeObjectNumber  uint64
	CreatedObjectsBPlusTreeObjectOffset  uint64
	CreatedObjectsBPlusTreeObjectLength  uint64
	DeletedObjectsBPlusTreeObjectNumber  uint64
	DeletedObjectsBPlusTreeObjectOffset  uint64
	DeletedObjectsBPlusTreeObjectLength  uint64
}

type SnapShotIDType

type SnapShotIDType uint8
const (
	SnapShotIDTypeLive SnapShotIDType = iota
	SnapShotIDTypeSnapShot
	SnapShotIDTypeDotSnapShot
)

type SnapShotStruct

type SnapShotStruct struct {
	ID   uint64
	Time time.Time
	Name string
}

type VolumeEventListener

type VolumeEventListener interface {
	CheckpointCompleted()
}

type VolumeHandle

type VolumeHandle interface {
	RegisterForEvents(listener VolumeEventListener)
	UnregisterForEvents(listener VolumeEventListener)
	FetchAccountAndCheckpointContainerNames() (accountName string, checkpointContainerName string)
	FetchNonce() (nonce uint64)
	GetInodeRec(inodeNumber uint64) (value []byte, ok bool, err error)
	PutInodeRec(inodeNumber uint64, value []byte) (err error)
	PutInodeRecs(inodeNumbers []uint64, values [][]byte) (err error)
	DeleteInodeRec(inodeNumber uint64) (err error)
	IndexedInodeNumber(index uint64) (inodeNumber uint64, ok bool, err error)
	NextInodeNumber(lastInodeNumber uint64) (nextInodeNumber uint64, ok bool, err error)
	GetLogSegmentRec(logSegmentNumber uint64) (value []byte, err error)
	PutLogSegmentRec(logSegmentNumber uint64, value []byte) (err error)
	DeleteLogSegmentRec(logSegmentNumber uint64) (err error)
	IndexedLogSegmentNumber(index uint64) (logSegmentNumber uint64, ok bool, err error)
	GetBPlusTreeObject(objectNumber uint64) (value []byte, err error)
	PutBPlusTreeObject(objectNumber uint64, value []byte) (err error)
	DeleteBPlusTreeObject(objectNumber uint64) (err error)
	IndexedBPlusTreeObjectNumber(index uint64) (objectNumber uint64, ok bool, err error)
	DoCheckpoint() (err error)
	FetchLayoutReport(treeType BPlusTreeType, validate bool) (layoutReport sortedmap.LayoutReport, discrepencies uint64, err error)
	DefragmentMetadata(treeType BPlusTreeType, thisStartPercentage float64, thisStopPercentage float64) (err error)
	SnapShotCreateByInodeLayer(name string) (id uint64, err error)
	SnapShotDeleteByInodeLayer(id uint64) (err error)
	SnapShotCount() (snapShotCount uint64)
	SnapShotLookupByName(name string) (snapShot SnapShotStruct, ok bool)
	SnapShotListByID(reversed bool) (list []SnapShotStruct)
	SnapShotListByTime(reversed bool) (list []SnapShotStruct)
	SnapShotListByName(reversed bool) (list []SnapShotStruct)
	SnapShotU64Decode(snapShotU64 uint64) (snapShotIDType SnapShotIDType, snapShotID uint64, nonce uint64)
	SnapShotIDAndNonceEncode(snapShotID uint64, nonce uint64) (snapShotU64 uint64)
	SnapShotTypeDotSnapShotAndNonceEncode(nonce uint64) (snapShotU64 uint64)
}

VolumeHandle is used to operate on a given volume's database

func FetchVolumeHandle

func FetchVolumeHandle(volumeName string) (volumeHandle VolumeHandle, err error)

FetchVolumeHandle is used to fetch a VolumeHandle to use when operating on a given volume's database

Jump to

Keyboard shortcuts

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