Documentation ¶
Index ¶
- type Cluster
- func (mc *Cluster) AddLabelsContainer(containerID uint64, resourceCount int, labels map[string]string)
- func (mc *Cluster) AddLeaderContainer(containerID uint64, leaderCount int, leaderSizes ...int64)
- func (mc *Cluster) AddLeaderResource(resID uint64, leaderContainerID uint64, followerContainerIDs ...uint64) *core.CachedResource
- func (mc *Cluster) AddLeaderResourceWithRange(resID uint64, startKey string, endKey string, leaderID uint64, ...)
- func (mc *Cluster) AddLeaderResourceWithReadInfo(resID uint64, leaderID uint64, readBytes, readKeys uint64, ...)
- func (mc *Cluster) AddLeaderResourceWithWriteInfo(resID uint64, leaderID uint64, writtenBytes, writtenKeys uint64, ...)
- func (mc *Cluster) AddResourceContainer(containerID uint64, resourceCount int)
- func (mc *Cluster) AddResourceContainerWithLeader(containerID uint64, resourceCount int, leaderCounts ...int)
- func (mc *Cluster) AddResourceWithLearner(resID uint64, leaderContainerID uint64, ...) *core.CachedResource
- func (mc *Cluster) AddSuspectResources(ids ...uint64)
- func (mc *Cluster) AllocID() (uint64, error)
- func (mc *Cluster) AllocPeer(containerID uint64) (metapb.Peer, error)
- func (mc *Cluster) CheckLabelProperty(typ string, labels []metapb.Pair) bool
- func (mc *Cluster) CheckResourceUnderSuspect(id uint64) bool
- func (mc *Cluster) DisableJointConsensus()
- func (mc *Cluster) FitResource(res *core.CachedResource) *placement.ResourceFit
- func (mc *Cluster) GetContainer(containerID uint64) *core.CachedContainer
- func (mc *Cluster) GetContainerResourceCount(containerID uint64) int
- func (mc *Cluster) GetContainersStats() *statistics.ContainersStats
- func (mc *Cluster) GetOpts() *config.PersistOptions
- func (mc *Cluster) GetResourceByKey(resKey []byte) *core.CachedResource
- func (mc *Cluster) GetResourceFactory() func() metadata.Resource
- func (mc *Cluster) GetRuleManager() *placement.RuleManager
- func (mc *Cluster) IsResourceHot(res *core.CachedResource) bool
- func (mc *Cluster) JointConsensusEnabled() bool
- func (mc *Cluster) LoadResource(resID uint64, followerIds ...uint64)
- func (mc *Cluster) MockCachedResource(resID uint64, leaderContainerID uint64, ...) *core.CachedResource
- func (mc *Cluster) PutContainerWithLabels(id uint64, labelPairs ...string)
- func (mc *Cluster) PutResourceContainers(id uint64, containerIDs ...uint64)
- func (mc *Cluster) RandHotResourceFromContainer(containerID uint64, kind statistics.FlowKind) *core.CachedResource
- func (mc *Cluster) RemoveScheduler(name string) error
- func (mc *Cluster) ResetSuspectResources()
- func (mc *Cluster) ResourceReadStats() map[uint64][]*statistics.HotPeerStat
- func (mc *Cluster) ResourceWriteStats() map[uint64][]*statistics.HotPeerStat
- func (mc *Cluster) ScanResources(startKey, endKey []byte, limit int) []*core.CachedResource
- func (mc *Cluster) SetContainerBusy(containerID uint64, busy bool)
- func (mc *Cluster) SetContainerDisconnect(containerID uint64)
- func (mc *Cluster) SetContainerDown(containerID uint64)
- func (mc *Cluster) SetContainerLabel(containerID uint64, labels map[string]string)
- func (mc *Cluster) SetContainerLastHeartbeatInterval(containerID uint64, interval time.Duration)
- func (mc *Cluster) SetContainerOffline(containerID uint64)
- func (mc *Cluster) SetContainerUP(containerID uint64)
- func (mc *Cluster) SetEnableLocationReplacement(v bool)
- func (mc *Cluster) SetEnableMakeUpReplica(v bool)
- func (mc *Cluster) SetEnableOneWayMerge(v bool)
- func (mc *Cluster) SetEnablePlacementRules(v bool)
- func (mc *Cluster) SetEnableRemoveDownReplica(v bool)
- func (mc *Cluster) SetEnableRemoveExtraReplica(v bool)
- func (mc *Cluster) SetEnableReplaceOfflineReplica(v bool)
- func (mc *Cluster) SetHotResourceCacheHitsThreshold(v int)
- func (mc *Cluster) SetHotResourceScheduleLimit(v int)
- func (mc *Cluster) SetLeaderScheduleLimit(v int)
- func (mc *Cluster) SetLeaderSchedulePolicy(v string)
- func (mc *Cluster) SetLocationLabels(v []string)
- func (mc *Cluster) SetMaxMergeResourceKeys(v int)
- func (mc *Cluster) SetMaxMergeResourceSize(v int)
- func (mc *Cluster) SetMaxReplicas(v int)
- func (mc *Cluster) SetMaxSnapshotCount(v int)
- func (mc *Cluster) SetMergeScheduleLimit(v int)
- func (mc *Cluster) SetResourceScheduleLimit(v int)
- func (mc *Cluster) SetResourceScoreFormulaVersion(v string)
- func (mc *Cluster) SetSplitMergeInterval(v time.Duration)
- func (mc *Cluster) SetTolerantSizeRatio(v float64)
- func (mc *Cluster) UpdateContainerLeaderSize(containerID uint64, size int64)
- func (mc *Cluster) UpdateContainerLeaderWeight(containerID uint64, weight float64)
- func (mc *Cluster) UpdateContainerResourceSize(containerID uint64, size int64)
- func (mc *Cluster) UpdateContainerResourceWeight(containerID uint64, weight float64)
- func (mc *Cluster) UpdateContainerStatus(id uint64)
- func (mc *Cluster) UpdateLeaderCount(containerID uint64, leaderCount int)
- func (mc *Cluster) UpdatePendingPeerCount(containerID uint64, pendingPeerCount int)
- func (mc *Cluster) UpdateResourceCount(containerID uint64, resourceCount int)
- func (mc *Cluster) UpdateSnapshotCount(containerID uint64, snapshotCount int)
- func (mc *Cluster) UpdateStorageRatio(containerID uint64, usedRatio, availableRatio float64)
- func (mc *Cluster) UpdateStorageReadBytes(containerID uint64, bytesRead uint64)
- func (mc *Cluster) UpdateStorageReadKeys(containerID uint64, keysRead uint64)
- func (mc *Cluster) UpdateStorageReadStats(containerID, bytesWritten, keysWritten uint64)
- func (mc *Cluster) UpdateStorageWrittenBytes(containerID uint64, bytesWritten uint64)
- func (mc *Cluster) UpdateStorageWrittenKeys(containerID uint64, keysWritten uint64)
- func (mc *Cluster) UpdateStorageWrittenStats(containerID, bytesWritten, keysWritten uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { *core.BasicCluster *placement.RuleManager *statistics.HotStat *config.PersistOptions ID uint64 // contains filtered or unexported fields }
Cluster is used to mock clusterInfo for test use.
func NewCluster ¶
func NewCluster(opts *config.PersistOptions) *Cluster
NewCluster creates a new Cluster
func (*Cluster) AddLabelsContainer ¶
func (mc *Cluster) AddLabelsContainer(containerID uint64, resourceCount int, labels map[string]string)
AddLabelsContainer adds container with specified count of resource and labels.
func (*Cluster) AddLeaderContainer ¶
AddLeaderContainer adds container with specified count of leader.
func (*Cluster) AddLeaderResource ¶
func (mc *Cluster) AddLeaderResource(resID uint64, leaderContainerID uint64, followerContainerIDs ...uint64) *core.CachedResource
AddLeaderResource adds resource with specified leader and followers.
func (*Cluster) AddLeaderResourceWithRange ¶
func (mc *Cluster) AddLeaderResourceWithRange(resID uint64, startKey string, endKey string, leaderID uint64, followerIds ...uint64)
AddLeaderResourceWithRange adds resource with specified leader, followers and key range.
func (*Cluster) AddLeaderResourceWithReadInfo ¶
func (mc *Cluster) AddLeaderResourceWithReadInfo( resID uint64, leaderID uint64, readBytes, readKeys uint64, reportInterval uint64, followerIds []uint64)
AddLeaderResourceWithReadInfo adds resource with specified leader, followers and read info.
func (*Cluster) AddLeaderResourceWithWriteInfo ¶
func (mc *Cluster) AddLeaderResourceWithWriteInfo( resID uint64, leaderID uint64, writtenBytes, writtenKeys uint64, reportInterval uint64, followerIds []uint64)
AddLeaderResourceWithWriteInfo adds resource with specified leader, followers and write info.
func (*Cluster) AddResourceContainer ¶
AddResourceContainer adds container with specified count of resource.
func (*Cluster) AddResourceContainerWithLeader ¶
func (mc *Cluster) AddResourceContainerWithLeader(containerID uint64, resourceCount int, leaderCounts ...int)
AddResourceContainerWithLeader adds container with specified count of resource and leader.
func (*Cluster) AddResourceWithLearner ¶
func (mc *Cluster) AddResourceWithLearner(resID uint64, leaderContainerID uint64, followerContainerIDs, learnerContainerIDs []uint64) *core.CachedResource
AddResourceWithLearner adds resource with specified leader, followers and learners.
func (*Cluster) AddSuspectResources ¶
AddSuspectResources mock method
func (*Cluster) CheckLabelProperty ¶
CheckLabelProperty checks label property.
func (*Cluster) CheckResourceUnderSuspect ¶
CheckResourceUnderSuspect only used for unit test
func (*Cluster) DisableJointConsensus ¶
func (mc *Cluster) DisableJointConsensus()
DisableJointConsensus mock
func (*Cluster) FitResource ¶
func (mc *Cluster) FitResource(res *core.CachedResource) *placement.ResourceFit
FitResource fits a resource to the rules it matches.
func (*Cluster) GetContainer ¶
func (mc *Cluster) GetContainer(containerID uint64) *core.CachedContainer
GetContainer gets a container with a given container ID.
func (*Cluster) GetContainerResourceCount ¶
GetContainerResourceCount gets resource count with a given container.
func (*Cluster) GetContainersStats ¶
func (mc *Cluster) GetContainersStats() *statistics.ContainersStats
GetContainersStats gets containers statistics.
func (*Cluster) GetOpts ¶
func (mc *Cluster) GetOpts() *config.PersistOptions
GetOpts returns the cluster configuration.
func (*Cluster) GetResourceByKey ¶
func (mc *Cluster) GetResourceByKey(resKey []byte) *core.CachedResource
GetResourceByKey get resource by key
func (*Cluster) GetResourceFactory ¶
GetResourceFactory returns a metdata resource create factory
func (*Cluster) GetRuleManager ¶
func (mc *Cluster) GetRuleManager() *placement.RuleManager
GetRuleManager returns the ruleManager of the cluster.
func (*Cluster) IsResourceHot ¶
func (mc *Cluster) IsResourceHot(res *core.CachedResource) bool
IsResourceHot checks if the resource is hot.
func (*Cluster) JointConsensusEnabled ¶
JointConsensusEnabled mock
func (*Cluster) LoadResource ¶
LoadResource puts resource info without leader
func (*Cluster) MockCachedResource ¶
func (mc *Cluster) MockCachedResource(resID uint64, leaderContainerID uint64, followerContainerIDs, learnerContainerIDs []uint64, epoch metapb.ResourceEpoch) *core.CachedResource
MockCachedResource returns a mock resource If leaderContainerID is zero, the resources would have no leader
func (*Cluster) PutContainerWithLabels ¶
PutContainerWithLabels mocks method.
func (*Cluster) PutResourceContainers ¶
PutResourceContainers mocks method.
func (*Cluster) RandHotResourceFromContainer ¶
func (mc *Cluster) RandHotResourceFromContainer(containerID uint64, kind statistics.FlowKind) *core.CachedResource
RandHotResourceFromContainer random picks a hot resource in specify container.
func (*Cluster) RemoveScheduler ¶
RemoveScheduler mocks method.
func (*Cluster) ResetSuspectResources ¶
func (mc *Cluster) ResetSuspectResources()
ResetSuspectResources only used for unit test
func (*Cluster) ResourceReadStats ¶
func (mc *Cluster) ResourceReadStats() map[uint64][]*statistics.HotPeerStat
ResourceReadStats returns hot resource's read stats.
func (*Cluster) ResourceWriteStats ¶
func (mc *Cluster) ResourceWriteStats() map[uint64][]*statistics.HotPeerStat
ResourceWriteStats returns hot resource's write stats.
func (*Cluster) ScanResources ¶
func (mc *Cluster) ScanResources(startKey, endKey []byte, limit int) []*core.CachedResource
ScanResources scans resource with start key, until number greater than limit.
func (*Cluster) SetContainerBusy ¶
SetContainerBusy sets container busy.
func (*Cluster) SetContainerDisconnect ¶
SetContainerDisconnect changes a container's state to disconnected.
func (*Cluster) SetContainerDown ¶
SetContainerDown sets container down.
func (*Cluster) SetContainerLabel ¶
SetContainerLabel set the labels to the target container
func (*Cluster) SetContainerLastHeartbeatInterval ¶
SetContainerLastHeartbeatInterval set the last heartbeat to the target container
func (*Cluster) SetContainerOffline ¶
SetContainerOffline sets container state to be offline.
func (*Cluster) SetContainerUP ¶
SetContainerUP sets container state to be up.
func (*Cluster) SetEnableLocationReplacement ¶
SetEnableLocationReplacement updates the EnableLocationReplacement configuration.
func (*Cluster) SetEnableMakeUpReplica ¶
SetEnableMakeUpReplica updates the EnableMakeUpReplica configuration.
func (*Cluster) SetEnableOneWayMerge ¶
SetEnableOneWayMerge updates the EnableOneWayMerge configuration.
func (*Cluster) SetEnablePlacementRules ¶
SetEnablePlacementRules updates the EnablePlacementRules configuration.
func (*Cluster) SetEnableRemoveDownReplica ¶
SetEnableRemoveDownReplica updates the EnableRemoveDownReplica configuration.
func (*Cluster) SetEnableRemoveExtraReplica ¶
SetEnableRemoveExtraReplica updates the EnableRemoveExtraReplica configuration.
func (*Cluster) SetEnableReplaceOfflineReplica ¶
SetEnableReplaceOfflineReplica updates the EnableReplaceOfflineReplica configuration.
func (*Cluster) SetHotResourceCacheHitsThreshold ¶
SetHotResourceCacheHitsThreshold updates the HotResourceCacheHitsThreshold configuration.
func (*Cluster) SetHotResourceScheduleLimit ¶
SetHotResourceScheduleLimit updates the HotResourceScheduleLimit configuration.
func (*Cluster) SetLeaderScheduleLimit ¶
SetLeaderScheduleLimit updates the LeaderScheduleLimit configuration.
func (*Cluster) SetLeaderSchedulePolicy ¶
SetLeaderSchedulePolicy updates the LeaderSchedulePolicy configuration.
func (*Cluster) SetLocationLabels ¶
SetLocationLabels updates the LocationLabels configuration.
func (*Cluster) SetMaxMergeResourceKeys ¶
SetMaxMergeResourceKeys updates the MaxMergeResourceKeys configuration.
func (*Cluster) SetMaxMergeResourceSize ¶
SetMaxMergeResourceSize updates the MaxMergeResourceSize configuration.
func (*Cluster) SetMaxReplicas ¶
SetMaxReplicas updates the maxReplicas configuration.
func (*Cluster) SetMaxSnapshotCount ¶
SetMaxSnapshotCount updates the MaxSnapshotCount configuration.
func (*Cluster) SetMergeScheduleLimit ¶
SetMergeScheduleLimit updates the MergeScheduleLimit configuration.
func (*Cluster) SetResourceScheduleLimit ¶
SetResourceScheduleLimit updates the ResourceScheduleLimit configuration.
func (*Cluster) SetResourceScoreFormulaVersion ¶
SetResourceScoreFormulaVersion updates the ResourceScoreFormulaVersion configuration.
func (*Cluster) SetSplitMergeInterval ¶
SetSplitMergeInterval updates the SplitMergeInterval configuration.
func (*Cluster) SetTolerantSizeRatio ¶
SetTolerantSizeRatio updates the TolerantSizeRatio configuration.
func (*Cluster) UpdateContainerLeaderSize ¶
UpdateContainerLeaderSize updates container leader size.
func (*Cluster) UpdateContainerLeaderWeight ¶
UpdateContainerLeaderWeight updates container leader weight.
func (*Cluster) UpdateContainerResourceSize ¶
UpdateContainerResourceSize updates container resource size.
func (*Cluster) UpdateContainerResourceWeight ¶
UpdateContainerResourceWeight updates container resource weight.
func (*Cluster) UpdateContainerStatus ¶
UpdateContainerStatus updates container status.
func (*Cluster) UpdateLeaderCount ¶
UpdateLeaderCount updates container leader count.
func (*Cluster) UpdatePendingPeerCount ¶
UpdatePendingPeerCount updates container pending peer count.
func (*Cluster) UpdateResourceCount ¶
UpdateResourceCount updates container resource count.
func (*Cluster) UpdateSnapshotCount ¶
UpdateSnapshotCount updates container snapshot count.
func (*Cluster) UpdateStorageRatio ¶
UpdateStorageRatio updates container storage ratio count.
func (*Cluster) UpdateStorageReadBytes ¶
UpdateStorageReadBytes updates container read bytes.
func (*Cluster) UpdateStorageReadKeys ¶
UpdateStorageReadKeys updates container read bytes.
func (*Cluster) UpdateStorageReadStats ¶
UpdateStorageReadStats updates container written bytes.
func (*Cluster) UpdateStorageWrittenBytes ¶
UpdateStorageWrittenBytes updates container written bytes.
func (*Cluster) UpdateStorageWrittenKeys ¶
UpdateStorageWrittenKeys updates container written keys.
func (*Cluster) UpdateStorageWrittenStats ¶
UpdateStorageWrittenStats updates container written bytes.