wrapper

package
v2.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

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
	MinWriteAbleDataPartitionCnt = 10
)

Functions

func RegisterDataPartitionSelector

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
	PartitionType string
	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

func (dp *DataPartition) GetAvgRead() int64

func (*DataPartition) GetAvgWrite

func (dp *DataPartition) GetAvgWrite() int64

func (*DataPartition) MetricsRefresh

func (dp *DataPartition) MetricsRefresh()

func (*DataPartition) RecordWrite

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

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)
}

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

type DataPartitionSelectorConstructor

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

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

func (*DefaultRandomSelector) Name

func (s *DefaultRandomSelector) Name() string

func (*DefaultRandomSelector) Refresh

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

func (*DefaultRandomSelector) RemoveDP

func (s *DefaultRandomSelector) RemoveDP(partitionID uint64)

func (*DefaultRandomSelector) Select

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

type KFasterRandomSelector

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

func (*KFasterRandomSelector) Name

func (s *KFasterRandomSelector) Name() string

func (*KFasterRandomSelector) Refresh

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

func (*KFasterRandomSelector) RemoveDP

func (s *KFasterRandomSelector) RemoveDP(partitionID uint64)

func (*KFasterRandomSelector) Select

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

type Wrapper

type Wrapper struct {
	sync.RWMutex

	HostsStatus map[string]bool
	// contains filtered or unexported fields
}

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

func NewDataPartitionWrapper

func NewDataPartitionWrapper(volName string, masters []string) (w *Wrapper, err error)

NewDataPartitionWrapper returns a new data partition wrapper.

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) InitFollowerRead

func (w *Wrapper) InitFollowerRead(clientConfig bool)

func (*Wrapper) NearRead

func (w *Wrapper) NearRead() bool

func (*Wrapper) RemoveDataPartitionForWrite

func (w *Wrapper) RemoveDataPartitionForWrite(partitionID uint64)

func (*Wrapper) SetNearRead

func (w *Wrapper) SetNearRead(nearRead bool)

func (*Wrapper) Stop

func (w *Wrapper) Stop()

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