Documentation
¶
Index ¶
- func AllowMerge(cluster opt.Cluster, res *core.CachedResource, adjacent *core.CachedResource) bool
- type JointStateChecker
- type LearnerChecker
- type MergeChecker
- type ReplicaChecker
- type ReplicaStrategy
- func (s *ReplicaStrategy) SelectContainerToAdd(coLocationContainers []*core.CachedContainer, extraFilters ...filter.Filter) uint64
- func (s *ReplicaStrategy) SelectContainerToImprove(coLocationContainers []*core.CachedContainer, old uint64) uint64
- func (s *ReplicaStrategy) SelectContainerToRemove(coLocationContainers []*core.CachedContainer) uint64
- func (s *ReplicaStrategy) SelectContainerToReplace(coLocationContainers []*core.CachedContainer, old uint64) uint64
- type RuleChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowMerge ¶
func AllowMerge(cluster opt.Cluster, res *core.CachedResource, adjacent *core.CachedResource) bool
AllowMerge returns true if two resources can be merged according to the key type.
Types ¶
type JointStateChecker ¶
type JointStateChecker struct {
// contains filtered or unexported fields
}
JointStateChecker ensures resource is in joint state will leave.
func NewJointStateChecker ¶
func NewJointStateChecker(cluster opt.Cluster) *JointStateChecker
NewJointStateChecker creates a joint state checker.
func (*JointStateChecker) Check ¶
func (c *JointStateChecker) Check(res *core.CachedResource) *operator.Operator
Check verifies a resource's role, creating an Operator if need.
type LearnerChecker ¶
type LearnerChecker struct {
// contains filtered or unexported fields
}
LearnerChecker ensures resource has a learner will be promoted.
func NewLearnerChecker ¶
func NewLearnerChecker(cluster opt.Cluster) *LearnerChecker
NewLearnerChecker creates a learner checker.
func (*LearnerChecker) Check ¶
func (l *LearnerChecker) Check(res *core.CachedResource) *operator.Operator
Check verifies a resource's role, creating an Operator if need.
type MergeChecker ¶
type MergeChecker struct {
// contains filtered or unexported fields
}
MergeChecker ensures resource to merge with adjacent resource when size is small
func NewMergeChecker ¶
func NewMergeChecker(ctx context.Context, cluster opt.Cluster) *MergeChecker
NewMergeChecker creates a merge checker.
func (*MergeChecker) Check ¶
func (m *MergeChecker) Check(res *core.CachedResource) []*operator.Operator
Check verifies a resource's replicas, creating an Operator if need.
func (*MergeChecker) GetType ¶
func (m *MergeChecker) GetType() string
GetType return MergeChecker's type
func (*MergeChecker) RecordResourceSplit ¶
func (m *MergeChecker) RecordResourceSplit(resourceIDs []uint64)
RecordResourceSplit put the recently split resource into cache. MergeChecker will skip check it for a while.
type ReplicaChecker ¶
type ReplicaChecker struct {
// contains filtered or unexported fields
}
ReplicaChecker ensures resource has the best replicas. Including the following: Replica number management. Unhealthy replica management, mainly used for disaster recovery of your storage application. Location management, mainly used for cross data center deployment.
func NewReplicaChecker ¶
func NewReplicaChecker(cluster opt.Cluster, resourceWaitingList cache.Cache) *ReplicaChecker
NewReplicaChecker creates a replica checker.
func (*ReplicaChecker) Check ¶
func (r *ReplicaChecker) Check(res *core.CachedResource) *operator.Operator
Check verifies a resource's replicas, creating an operator.Operator if need.
func (*ReplicaChecker) FillReplicas ¶
func (r *ReplicaChecker) FillReplicas(res *core.CachedResource, leastPeers int) error
FillReplicas make up all replica for a empty resource
func (*ReplicaChecker) GetType ¶
func (r *ReplicaChecker) GetType() string
GetType return ReplicaChecker's type
type ReplicaStrategy ¶
type ReplicaStrategy struct {
// contains filtered or unexported fields
}
ReplicaStrategy collects some utilities to manipulate resource peers. It exists to allow replica_checker and rule_checker to reuse common logics.
func (*ReplicaStrategy) SelectContainerToAdd ¶
func (s *ReplicaStrategy) SelectContainerToAdd(coLocationContainers []*core.CachedContainer, extraFilters ...filter.Filter) uint64
SelectContainerToAdd returns the container to add a replica to a resource. `coLocationContainers` are the containers used to compare location with target container. `extraFilters` is used to set up more filters based on the context that calling this method.
For example, to select a target container to replace a resource's peer, we can use the peer list with the peer removed as `coLocationContainers`. Meanwhile, we need to provide more constraints to ensure that the isolation level cannot be reduced after replacement.
func (*ReplicaStrategy) SelectContainerToImprove ¶
func (s *ReplicaStrategy) SelectContainerToImprove(coLocationContainers []*core.CachedContainer, old uint64) uint64
SelectContainerToImprove returns a container to replace oldContainer. The location placement after scheduling should be better than original.
func (*ReplicaStrategy) SelectContainerToRemove ¶
func (s *ReplicaStrategy) SelectContainerToRemove(coLocationContainers []*core.CachedContainer) uint64
SelectContainerToRemove returns the best option to remove from the resource.
func (*ReplicaStrategy) SelectContainerToReplace ¶
func (s *ReplicaStrategy) SelectContainerToReplace(coLocationContainers []*core.CachedContainer, old uint64) uint64
SelectContainerToReplace returns a container to replace oldContainer. The location placement after scheduling should be not worse than original.
type RuleChecker ¶
type RuleChecker struct {
// contains filtered or unexported fields
}
RuleChecker fix/improve resource by placement rules.
func NewRuleChecker ¶
func NewRuleChecker(cluster opt.Cluster, ruleManager *placement.RuleManager, resourceWaitingList cache.Cache) *RuleChecker
NewRuleChecker creates a checker instance.
func (*RuleChecker) Check ¶
func (c *RuleChecker) Check(res *core.CachedResource) *operator.Operator
Check checks if the resource matches placement rules and returns Operator to fix it.
func (*RuleChecker) FillReplicas ¶
func (c *RuleChecker) FillReplicas(res *core.CachedResource, leastPeers int) error
FillReplicas make up all replica for a empty resource
func (*RuleChecker) GetType ¶
func (c *RuleChecker) GetType() string
GetType returns RuleChecker's Type