wrapper

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DefaultRandomSelectorName = "default"
)
View Source
const (
	KFasterRandomSelectorName = "kfaster"
)

Variables

View Source
var (
	ErrDuplicatedDataPartitionSelectorConstructor = errors.New("duplicated data partition selector constructor")
	ErrDataPartitionSelectorConstructorNotExist   = errors.New("data partition selector constructor not exist")
)
View Source
var LocalIP string

Functions

func RegisterDataPartitionSelector added in v1.34.0

func RegisterDataPartitionSelector(name string, constructor DataPartitionSelectorConstructor) error

RegisterDataPartitionSelector registers a selector constructor. Users can register their own defined selector through this method.

Types

type DataPartition

type DataPartition struct {
	// Will not be changed
	proto.DataPartitionResponse
	RandomWrite   bool
	NearHosts     []string
	ClientWrapper *Wrapper
	Metrics       *DataPartitionMetrics
}

DataPartition defines the wrapper of the data partition.

func (*DataPartition) CheckAllHostsIsAvail added in v1.4.0

func (dp *DataPartition) CheckAllHostsIsAvail(exclude map[string]struct{})

func (*DataPartition) GetAllAddrs

func (dp *DataPartition) GetAllAddrs() string

GetAllAddrs returns the addresses of all the replicas of the data partition.

func (*DataPartition) GetAvgRead added in v1.34.0

func (dp *DataPartition) GetAvgRead() int64

func (*DataPartition) GetAvgWrite added in v1.34.0

func (dp *DataPartition) GetAvgWrite() int64

func (*DataPartition) MetricsRefresh added in v1.34.0

func (dp *DataPartition) MetricsRefresh()

func (*DataPartition) RecordWrite added in v1.34.0

func (dp *DataPartition) RecordWrite(startT int64)

func (*DataPartition) String

func (dp *DataPartition) String() string

String returns the string format of the data partition.

type DataPartitionMetrics

type DataPartitionMetrics struct {
	sync.RWMutex
	AvgReadLatencyNano  int64
	AvgWriteLatencyNano int64
	SumReadLatencyNano  int64
	SumWriteLatencyNano int64
	ReadOpNum           int64
	WriteOpNum          int64
}

DataPartitionMetrics defines the wrapper of the metrics related to the data partition.

func NewDataPartitionMetrics

func NewDataPartitionMetrics() *DataPartitionMetrics

NewDataPartitionMetrics returns a new DataPartitionMetrics instance.

type DataPartitionSelector added in v1.34.0

type DataPartitionSelector interface {
	// Name return name of current selector instance.
	Name() string

	// Refresh refreshes current selector instance by specified data partitions.
	Refresh(partitions []*DataPartition) error

	// Select returns an data partition picked by selector.
	Select(excludes map[string]struct{}) (*DataPartition, error)

	// RemoveDP removes specified data partition.
	RemoveDP(partitionID uint64)

	// Count return number of data partitions held by selector.
	Count() int

	// GetAllDp return data partitions held by selector
	GetAllDp() (dp []*DataPartition)
}

DataPartitionSelector is the interface defines the methods necessary to implement a selector for data partition selecting.

type DataPartitionSelectorConstructor added in v1.34.0

type DataPartitionSelectorConstructor = func(param string) (DataPartitionSelector, error)

This type defines the constructor used to create and initialize the selector.

type DataPartitionSorter

type DataPartitionSorter []*DataPartition

func (DataPartitionSorter) Len

func (ds DataPartitionSorter) Len() int

func (DataPartitionSorter) Less

func (ds DataPartitionSorter) Less(i, j int) bool

func (DataPartitionSorter) Swap

func (ds DataPartitionSorter) Swap(i, j int)

type DataPartitionView

type DataPartitionView struct {
	DataPartitions []*DataPartition
}

type DefaultRandomSelector added in v1.34.0

type DefaultRandomSelector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*DefaultRandomSelector) Count added in v1.34.0

func (s *DefaultRandomSelector) Count() int

func (*DefaultRandomSelector) GetAllDp added in v1.34.0

func (s *DefaultRandomSelector) GetAllDp() (dps []*DataPartition)

func (*DefaultRandomSelector) Name added in v1.34.0

func (s *DefaultRandomSelector) Name() string

func (*DefaultRandomSelector) Refresh added in v1.34.0

func (s *DefaultRandomSelector) Refresh(partitions []*DataPartition) (err error)

func (*DefaultRandomSelector) RemoveDP added in v1.34.0

func (s *DefaultRandomSelector) RemoveDP(partitionID uint64)

func (*DefaultRandomSelector) Select added in v1.34.0

func (s *DefaultRandomSelector) Select(exclude map[string]struct{}) (dp *DataPartition, err error)

type KFasterRandomSelector added in v1.34.0

type KFasterRandomSelector struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*KFasterRandomSelector) Count added in v1.34.0

func (s *KFasterRandomSelector) Count() int

func (*KFasterRandomSelector) GetAllDp added in v1.34.0

func (s *KFasterRandomSelector) GetAllDp() (dps []*DataPartition)

func (*KFasterRandomSelector) Name added in v1.34.0

func (s *KFasterRandomSelector) Name() string

func (*KFasterRandomSelector) Refresh added in v1.34.0

func (s *KFasterRandomSelector) Refresh(partitions []*DataPartition) (err error)

func (*KFasterRandomSelector) RemoveDP added in v1.34.0

func (s *KFasterRandomSelector) RemoveDP(partitionID uint64)

func (*KFasterRandomSelector) Select added in v1.34.0

func (s *KFasterRandomSelector) Select(exclude map[string]struct{}) (dp *DataPartition, err error)

type RefreshDpPolicy added in v1.34.0

type RefreshDpPolicy int32
const (
	MergeDpPolicy RefreshDpPolicy = iota
	UpdateDpPolicy
)

type SimpleClientInfo added in v1.34.0

type SimpleClientInfo interface {
	GetFlowInfo() (*proto.ClientReportLimitInfo, bool)
	UpdateFlowInfo(limit *proto.LimitRsp2Client)
	SetClientID(id uint64) error
	UpdateLatestVer(verList *proto.VolVersionInfoList) error
	GetReadVer() uint64
	GetLatestVer() uint64
	GetVerMgr() *proto.VolVersionInfoList
}

type Wrapper

type Wrapper struct {
	Lock sync.RWMutex

	EnablePosixAcl bool

	HostsStatus map[string]bool
	Uids        map[uint32]*proto.UidSimpleInfo
	UidLock     sync.RWMutex

	LocalIp string

	SimpleClient SimpleClientInfo
	// contains filtered or unexported fields
}

Wrapper TODO rename. This name does not reflect what it is doing.

func NewDataPartitionWrapper

func NewDataPartitionWrapper(client SimpleClientInfo, volName string, masters []string, preload bool, minWriteAbleDataPartitionCnt int, verReadSeq uint64) (w *Wrapper, err error)

NewDataPartitionWrapper returns a new data partition wrapper.

func (*Wrapper) AllocatePreLoadDataPartition added in v1.34.0

func (w *Wrapper) AllocatePreLoadDataPartition(volName string, count int, capacity, ttl uint64, zones string) (err error)

func (*Wrapper) CheckPermission added in v1.34.0

func (w *Wrapper) CheckPermission()

func (*Wrapper) CheckReadVerSeq added in v1.34.0

func (w *Wrapper) CheckReadVerSeq(volName string, verReadSeq uint64, verList *proto.VolVersionInfoList) (readReadVer uint64, err error)

func (*Wrapper) FollowerRead added in v1.4.0

func (w *Wrapper) FollowerRead() bool

func (*Wrapper) GetDataPartition

func (w *Wrapper) GetDataPartition(partitionID uint64) (*DataPartition, error)

GetDataPartition returns the data partition based on the given partition ID.

func (*Wrapper) GetDataPartitionForWrite

func (w *Wrapper) GetDataPartitionForWrite(exclude map[string]struct{}) (*DataPartition, error)

getDataPartitionForWrite returns an available data partition for write.

func (*Wrapper) GetReadVerSeq added in v1.34.0

func (w *Wrapper) GetReadVerSeq() uint64

func (*Wrapper) GetSimpleVolView added in v1.34.0

func (w *Wrapper) GetSimpleVolView() (err error)

func (*Wrapper) InitFollowerRead added in v1.34.0

func (w *Wrapper) InitFollowerRead(clientConfig bool)

func (*Wrapper) NearRead added in v1.34.0

func (w *Wrapper) NearRead() bool

func (*Wrapper) RemoveDataPartitionForWrite added in v1.34.0

func (w *Wrapper) RemoveDataPartitionForWrite(partitionID uint64)

func (*Wrapper) SetNearRead added in v1.34.0

func (w *Wrapper) SetNearRead(nearRead bool)

func (*Wrapper) Stop added in v1.34.0

func (w *Wrapper) Stop()

func (*Wrapper) UpdateDataPartition added in v1.34.0

func (w *Wrapper) UpdateDataPartition() (err error)

func (*Wrapper) UpdateUidsView added in v1.34.0

func (w *Wrapper) UpdateUidsView(view *proto.SimpleVolView)

func (*Wrapper) UploadFlowInfo added in v1.34.0

func (w *Wrapper) UploadFlowInfo(clientInfo SimpleClientInfo, init bool) (work bool, err error)

func (*Wrapper) WarningMsg

func (w *Wrapper) WarningMsg() string

WarningMsg returns the warning message that contains the cluster name.

Jump to

Keyboard shortcuts

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