Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterDataPartitionSelector(name string, constructor DataPartitionSelectorConstructor) error
- type DataPartition
- func (dp *DataPartition) CheckAllHostsIsAvail(exclude map[string]struct{})
- func (dp *DataPartition) GetAllAddrs() string
- func (dp *DataPartition) GetAvgRead() int64
- func (dp *DataPartition) GetAvgWrite() int64
- func (dp *DataPartition) MetricsRefresh()
- func (dp *DataPartition) RecordWrite(startT int64)
- func (dp *DataPartition) String() string
- type DataPartitionMetrics
- type DataPartitionSelector
- type DataPartitionSelectorConstructor
- type DataPartitionSorter
- type DataPartitionView
- type DefaultRandomSelector
- type KFasterRandomSelector
- type Wrapper
- func (w *Wrapper) FollowerRead() bool
- func (w *Wrapper) GetDataPartition(partitionID uint64) (*DataPartition, error)
- func (w *Wrapper) GetDataPartitionForWrite(exclude map[string]struct{}) (*DataPartition, error)
- func (w *Wrapper) InitFollowerRead(clientConfig bool)
- func (w *Wrapper) NearRead() bool
- func (w *Wrapper) RemoveDataPartitionForWrite(partitionID uint64)
- func (w *Wrapper) SetNearRead(nearRead bool)
- func (w *Wrapper) Stop()
- func (w *Wrapper) WarningMsg() string
Constants ¶
const (
DefaultRandomSelectorName = "default"
)
const (
KFasterRandomSelectorName = "kfaster"
)
Variables ¶
var ( ErrDuplicatedDataPartitionSelectorConstructor = errors.New("duplicated data partition selector constructor") ErrDataPartitionSelectorConstructorNotExist = errors.New("data partition selector constructor not exist") )
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 ¶
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 ¶
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 ¶
NewDataPartitionWrapper returns a new data partition wrapper.
func (*Wrapper) FollowerRead ¶ added in v1.4.0
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 (*Wrapper) RemoveDataPartitionForWrite ¶
func (*Wrapper) SetNearRead ¶
func (*Wrapper) WarningMsg ¶
WarningMsg returns the warning message that contains the cluster name.