mockcluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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

func (mc *Cluster) AddLeaderContainer(containerID uint64, leaderCount int, leaderSizes ...int64)

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, filledNums ...int) []*statistics.HotPeerStat

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, filledNums ...int) []*statistics.HotPeerStat

AddLeaderResourceWithWriteInfo adds resource with specified leader, followers and write info.

func (*Cluster) AddResourceContainer

func (mc *Cluster) AddResourceContainer(containerID uint64, resourceCount int)

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

func (mc *Cluster) AddSuspectResources(ids ...uint64)

AddSuspectResources mock method

func (*Cluster) AllocID

func (mc *Cluster) AllocID() (uint64, error)

AllocID allocs a new unique ID.

func (*Cluster) AllocPeer

func (mc *Cluster) AllocPeer(containerID uint64) (metapb.Replica, error)

AllocPeer allocs a new peer on a container.

func (*Cluster) CheckLabelProperty

func (mc *Cluster) CheckLabelProperty(typ string, labels []metapb.Pair) bool

CheckLabelProperty checks label property.

func (*Cluster) CheckResourceUnderSuspect

func (mc *Cluster) CheckResourceUnderSuspect(id uint64) bool

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

func (mc *Cluster) GetContainerResourceCount(groupKey string, containerID uint64) int

GetContainerResourceCount gets resource count with a given container.

func (*Cluster) GetContainersLoads

func (mc *Cluster) GetContainersLoads() map[uint64][]float64

GetContainersLoads gets stores load statistics.

func (*Cluster) GetLogger added in v0.2.0

func (mc *Cluster) GetLogger() *zap.Logger

GetLogger returns zap logger

func (*Cluster) GetOpts

func (mc *Cluster) GetOpts() *config.PersistOptions

GetOpts returns the cluster configuration.

func (*Cluster) GetResourceByKey

func (mc *Cluster) GetResourceByKey(group uint64, resKey []byte) *core.CachedResource

GetResourceByKey get resource by key

func (*Cluster) GetResourceFactory

func (mc *Cluster) GetResourceFactory() func() metadata.Resource

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

func (mc *Cluster) JointConsensusEnabled() bool

JointConsensusEnabled mock

func (*Cluster) LoadResource

func (mc *Cluster) LoadResource(resID uint64, followerIds ...uint64)

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

func (mc *Cluster) PutContainerWithLabels(id uint64, labelPairs ...string)

PutContainerWithLabels mocks method.

func (*Cluster) PutResourceContainers

func (mc *Cluster) PutResourceContainers(id uint64, containerIDs ...uint64)

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

func (mc *Cluster) RemoveScheduler(name string) error

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. The result only includes peers that are hot enough.

func (*Cluster) ResourceWriteStats

func (mc *Cluster) ResourceWriteStats() map[uint64][]*statistics.HotPeerStat

ResourceWriteStats returns hot Resource's write stats. The result only includes peers that are hot enough.

func (*Cluster) ScanResources

func (mc *Cluster) ScanResources(group uint64, startKey, endKey []byte, limit int) []*core.CachedResource

ScanResources scans resource with start key, until number greater than limit.

func (*Cluster) SetContainerBusy

func (mc *Cluster) SetContainerBusy(containerID uint64, busy bool)

SetContainerBusy sets container busy.

func (*Cluster) SetContainerDisconnect

func (mc *Cluster) SetContainerDisconnect(containerID uint64)

SetContainerDisconnect changes a container's state to disconnected.

func (*Cluster) SetContainerDown

func (mc *Cluster) SetContainerDown(containerID uint64)

SetContainerDown sets container down.

func (*Cluster) SetContainerLabel

func (mc *Cluster) SetContainerLabel(containerID uint64, labels map[string]string)

SetContainerLabel set the labels to the target container

func (*Cluster) SetContainerLastHeartbeatInterval

func (mc *Cluster) SetContainerLastHeartbeatInterval(containerID uint64, interval time.Duration)

SetContainerLastHeartbeatInterval set the last heartbeat to the target container

func (*Cluster) SetContainerOffline

func (mc *Cluster) SetContainerOffline(containerID uint64)

SetContainerOffline sets container state to be offline.

func (*Cluster) SetContainerUP

func (mc *Cluster) SetContainerUP(containerID uint64)

SetContainerUP sets container state to be up.

func (*Cluster) SetEnableLocationReplacement

func (mc *Cluster) SetEnableLocationReplacement(v bool)

SetEnableLocationReplacement updates the EnableLocationReplacement configuration.

func (*Cluster) SetEnableMakeUpReplica

func (mc *Cluster) SetEnableMakeUpReplica(v bool)

SetEnableMakeUpReplica updates the EnableMakeUpReplica configuration.

func (*Cluster) SetEnableOneWayMerge

func (mc *Cluster) SetEnableOneWayMerge(v bool)

SetEnableOneWayMerge updates the EnableOneWayMerge configuration.

func (*Cluster) SetEnablePlacementRules

func (mc *Cluster) SetEnablePlacementRules(v bool)

SetEnablePlacementRules updates the EnablePlacementRules configuration.

func (*Cluster) SetEnableRemoveDownReplica

func (mc *Cluster) SetEnableRemoveDownReplica(v bool)

SetEnableRemoveDownReplica updates the EnableRemoveDownReplica configuration.

func (*Cluster) SetEnableRemoveExtraReplica

func (mc *Cluster) SetEnableRemoveExtraReplica(v bool)

SetEnableRemoveExtraReplica updates the EnableRemoveExtraReplica configuration.

func (*Cluster) SetEnableReplaceOfflineReplica

func (mc *Cluster) SetEnableReplaceOfflineReplica(v bool)

SetEnableReplaceOfflineReplica updates the EnableReplaceOfflineReplica configuration.

func (*Cluster) SetHotResourceCacheHitsThreshold

func (mc *Cluster) SetHotResourceCacheHitsThreshold(v int)

SetHotResourceCacheHitsThreshold updates the HotResourceCacheHitsThreshold configuration.

func (*Cluster) SetHotResourceScheduleLimit

func (mc *Cluster) SetHotResourceScheduleLimit(v int)

SetHotResourceScheduleLimit updates the HotResourceScheduleLimit configuration.

func (*Cluster) SetLeaderScheduleLimit

func (mc *Cluster) SetLeaderScheduleLimit(v int)

SetLeaderScheduleLimit updates the LeaderScheduleLimit configuration.

func (*Cluster) SetLeaderSchedulePolicy

func (mc *Cluster) SetLeaderSchedulePolicy(v string)

SetLeaderSchedulePolicy updates the LeaderSchedulePolicy configuration.

func (*Cluster) SetLocationLabels

func (mc *Cluster) SetLocationLabels(v []string)

SetLocationLabels updates the LocationLabels configuration.

func (*Cluster) SetMaxMergeResourceKeys

func (mc *Cluster) SetMaxMergeResourceKeys(v int)

SetMaxMergeResourceKeys updates the MaxMergeResourceKeys configuration.

func (*Cluster) SetMaxMergeResourceSize

func (mc *Cluster) SetMaxMergeResourceSize(v int)

SetMaxMergeResourceSize updates the MaxMergeResourceSize configuration.

func (*Cluster) SetMaxReplicas

func (mc *Cluster) SetMaxReplicas(v int)

SetMaxReplicas updates the maxReplicas configuration.

func (*Cluster) SetMaxSnapshotCount

func (mc *Cluster) SetMaxSnapshotCount(v int)

SetMaxSnapshotCount updates the MaxSnapshotCount configuration.

func (*Cluster) SetMergeScheduleLimit

func (mc *Cluster) SetMergeScheduleLimit(v int)

SetMergeScheduleLimit updates the MergeScheduleLimit configuration.

func (*Cluster) SetResourceScheduleLimit

func (mc *Cluster) SetResourceScheduleLimit(v int)

SetResourceScheduleLimit updates the ResourceScheduleLimit configuration.

func (*Cluster) SetResourceScoreFormulaVersion

func (mc *Cluster) SetResourceScoreFormulaVersion(v string)

SetResourceScoreFormulaVersion updates the ResourceScoreFormulaVersion configuration.

func (*Cluster) SetSplitMergeInterval

func (mc *Cluster) SetSplitMergeInterval(v time.Duration)

SetSplitMergeInterval updates the SplitMergeInterval configuration.

func (*Cluster) SetTolerantSizeRatio

func (mc *Cluster) SetTolerantSizeRatio(v float64)

SetTolerantSizeRatio updates the TolerantSizeRatio configuration.

func (*Cluster) UpdateContainerLeaderSize

func (mc *Cluster) UpdateContainerLeaderSize(containerID uint64, size int64)

UpdateContainerLeaderSize updates container leader size.

func (*Cluster) UpdateContainerLeaderWeight

func (mc *Cluster) UpdateContainerLeaderWeight(containerID uint64, weight float64)

UpdateContainerLeaderWeight updates container leader weight.

func (*Cluster) UpdateContainerResourceSize

func (mc *Cluster) UpdateContainerResourceSize(containerID uint64, size int64)

UpdateContainerResourceSize updates container resource size.

func (*Cluster) UpdateContainerResourceWeight

func (mc *Cluster) UpdateContainerResourceWeight(containerID uint64, weight float64)

UpdateContainerResourceWeight updates container resource weight.

func (*Cluster) UpdateContainerStatus

func (mc *Cluster) UpdateContainerStatus(id uint64)

UpdateContainerStatus updates container status.

func (*Cluster) UpdateLeaderCount

func (mc *Cluster) UpdateLeaderCount(containerID uint64, leaderCount int)

UpdateLeaderCount updates container leader count.

func (*Cluster) UpdatePendingPeerCount

func (mc *Cluster) UpdatePendingPeerCount(containerID uint64, pendingPeerCount int)

UpdatePendingPeerCount updates container pending peer count.

func (*Cluster) UpdateResourceCount

func (mc *Cluster) UpdateResourceCount(containerID uint64, resourceCount int)

UpdateResourceCount updates container resource count.

func (*Cluster) UpdateSnapshotCount

func (mc *Cluster) UpdateSnapshotCount(containerID uint64, snapshotCount int)

UpdateSnapshotCount updates container snapshot count.

func (*Cluster) UpdateStorageRatio

func (mc *Cluster) UpdateStorageRatio(containerID uint64, usedRatio, availableRatio float64)

UpdateStorageRatio updates container storage ratio count.

func (*Cluster) UpdateStorageReadBytes

func (mc *Cluster) UpdateStorageReadBytes(containerID uint64, bytesRead uint64)

UpdateStorageReadBytes updates container read bytes.

func (*Cluster) UpdateStorageReadKeys

func (mc *Cluster) UpdateStorageReadKeys(containerID uint64, keysRead uint64)

UpdateStorageReadKeys updates container read bytes.

func (*Cluster) UpdateStorageReadStats

func (mc *Cluster) UpdateStorageReadStats(containerID, bytesWritten, keysWritten uint64)

UpdateStorageReadStats updates container written bytes.

func (*Cluster) UpdateStorageWrittenBytes

func (mc *Cluster) UpdateStorageWrittenBytes(containerID uint64, bytesWritten uint64)

UpdateStorageWrittenBytes updates container written bytes.

func (*Cluster) UpdateStorageWrittenKeys

func (mc *Cluster) UpdateStorageWrittenKeys(containerID uint64, keysWritten uint64)

UpdateStorageWrittenKeys updates container written keys.

func (*Cluster) UpdateStorageWrittenStats

func (mc *Cluster) UpdateStorageWrittenStats(containerID, bytesWritten, keysWritten uint64)

UpdateStorageWrittenStats updates container written bytes.

Jump to

Keyboard shortcuts

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