operator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OperatorExpireTime is the duration that when an operator is not started
	// after it, the operator will be considered expired.
	OperatorExpireTime = 3 * time.Second
	// FastOperatorWaitTime is the duration that when an operator that is not marked
	// `OpResource` runs longer than it, the operator will be considered timeout.
	FastOperatorWaitTime = 10 * time.Second
	// SlowOperatorWaitTime is the duration that when an operator marked `OpResource`
	// runs longer than it, the operator will be considered timeout.
	SlowOperatorWaitTime = 10 * time.Minute
)

Variables

This section is empty.

Functions

func IsEndStatus

func IsEndStatus(s OpStatus) bool

IsEndStatus checks whether s is an end status.

func OpStatusToPDPB

func OpStatusToPDPB(s OpStatus) metapb.OperatorStatus

OpStatusToPDPB converts OpStatus to metapb.OperatorStatus.

func OpStatusToString

func OpStatusToString(s OpStatus) string

OpStatusToString converts Status to string.

func SetOperatorStatusReachTime

func SetOperatorStatusReachTime(op *Operator, st OpStatus, t time.Time)

SetOperatorStatusReachTime sets the reach time of the operator. NOTE: Should only use in test.

func SkipOriginJointStateCheck

func SkipOriginJointStateCheck(b *Builder)

SkipOriginJointStateCheck lets the builder skip the joint state check for origin peers.

Types

type AddLearner

type AddLearner struct {
	ToContainer, PeerID uint64
}

AddLearner is an OpStep that adds a resource learner peer.

func (AddLearner) CheckSafety

func (al AddLearner) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (AddLearner) ConfVerChanged

func (al AddLearner) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (AddLearner) Influence

func (al AddLearner) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (AddLearner) IsFinish

func (al AddLearner) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (AddLearner) String

func (al AddLearner) String() string

type AddLightLearner

type AddLightLearner struct {
	ToContainer, PeerID uint64
}

AddLightLearner is an OpStep that adds a resource learner peer without considering the influence.

func (AddLightLearner) CheckSafety

func (al AddLightLearner) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (AddLightLearner) ConfVerChanged

func (al AddLightLearner) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (AddLightLearner) Influence

func (al AddLightLearner) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (AddLightLearner) IsFinish

func (al AddLightLearner) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (AddLightLearner) String

func (al AddLightLearner) String() string

type AddLightPeer

type AddLightPeer struct {
	ToContainer, PeerID uint64
}

AddLightPeer is an OpStep that adds a resource peer without considering the influence.

func (AddLightPeer) CheckSafety

func (ap AddLightPeer) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (AddLightPeer) ConfVerChanged

func (ap AddLightPeer) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (AddLightPeer) Influence

func (ap AddLightPeer) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (AddLightPeer) IsFinish

func (ap AddLightPeer) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (AddLightPeer) String

func (ap AddLightPeer) String() string

type AddPeer

type AddPeer struct {
	ToContainer, PeerID uint64
}

AddPeer is an OpStep that adds a resource peer.

func (AddPeer) CheckSafety

func (ap AddPeer) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (AddPeer) ConfVerChanged

func (ap AddPeer) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (AddPeer) Influence

func (ap AddPeer) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (AddPeer) IsFinish

func (ap AddPeer) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (AddPeer) String

func (ap AddPeer) String() string

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is used to create operators. Usage:

op, err := NewBuilder(desc, cluster, resource).
            RemovePeer(container1).
            AddPeer(peer1).
            SetLeader(container2).
            Build(kind)

The generated Operator will choose the most appropriate execution order according to various constraints.

func NewBuilder

func NewBuilder(desc string, cluster opt.Cluster, res *core.CachedResource, opts ...BuilderOption) *Builder

NewBuilder creates a Builder.

func (*Builder) AddPeer

func (b *Builder) AddPeer(peer metapb.Peer) *Builder

AddPeer records an add Peer operation in Builder. If peer.Id is 0, the builder will allocate a new peer ID later.

func (*Builder) Build

func (b *Builder) Build(kind OpKind) (*Operator, error)

Build creates the Operator.

func (*Builder) DemoteVoter

func (b *Builder) DemoteVoter(containerID uint64) *Builder

DemoteVoter records a demote voter operation in Builder.

func (*Builder) EnableForceTargetLeader

func (b *Builder) EnableForceTargetLeader() *Builder

EnableForceTargetLeader marks the step of transferring leader to target is forcible. It is used for grant leader.

func (*Builder) EnableLightWeight

func (b *Builder) EnableLightWeight() *Builder

EnableLightWeight marks the resource as light weight. It is used for scatter resources.

func (*Builder) PromoteLearner

func (b *Builder) PromoteLearner(containerID uint64) *Builder

PromoteLearner records a promote learner operation in Builder.

func (*Builder) RemovePeer

func (b *Builder) RemovePeer(containerID uint64) *Builder

RemovePeer records a remove peer operation in Builder.

func (*Builder) SetExpectedRoles

func (b *Builder) SetExpectedRoles(roles map[uint64]placement.PeerRoleType) *Builder

SetExpectedRoles records expected roles of target peers. It may update `targetLeaderContainerID` if there is a peer has role `leader` or `follower`.

func (*Builder) SetLeader

func (b *Builder) SetLeader(containerID uint64) *Builder

SetLeader records the target leader in Builder.

func (*Builder) SetPeers

func (b *Builder) SetPeers(peers map[uint64]metapb.Peer) *Builder

SetPeers resets the target peer list.

If peer's ID is 0, the builder will allocate a new ID later. If current target leader does not exist in peers, it will be reset.

type BuilderOption

type BuilderOption func(*Builder)

BuilderOption is used to create operator builder.

type ChangePeerV2Enter

type ChangePeerV2Enter struct {
	PromoteLearners []PromoteLearner
	DemoteVoters    []DemoteVoter
}

ChangePeerV2Enter is an OpStep that uses joint consensus to request all PromoteLearner and DemoteVoter.

func (ChangePeerV2Enter) CheckSafety

func (cpe ChangePeerV2Enter) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (ChangePeerV2Enter) ConfVerChanged

func (cpe ChangePeerV2Enter) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (ChangePeerV2Enter) GetRequest

func (cpe ChangePeerV2Enter) GetRequest() *rpcpb.ChangePeerV2

GetRequest get the ChangePeerV2 request

func (ChangePeerV2Enter) Influence

func (cpe ChangePeerV2Enter) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (ChangePeerV2Enter) IsFinish

func (cpe ChangePeerV2Enter) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (ChangePeerV2Enter) String

func (cpe ChangePeerV2Enter) String() string

type ChangePeerV2Leave

type ChangePeerV2Leave struct {
	PromoteLearners []PromoteLearner
	DemoteVoters    []DemoteVoter
}

ChangePeerV2Leave is an OpStep that leaves the joint state.

func (ChangePeerV2Leave) CheckSafety

func (cpl ChangePeerV2Leave) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (ChangePeerV2Leave) ConfVerChanged

func (cpl ChangePeerV2Leave) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (ChangePeerV2Leave) Influence

func (cpl ChangePeerV2Leave) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (ChangePeerV2Leave) IsFinish

func (cpl ChangePeerV2Leave) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (ChangePeerV2Leave) String

func (cpl ChangePeerV2Leave) String() string

type ContainerInfluence

type ContainerInfluence struct {
	ResourceSize  int64
	ResourceCount int64
	LeaderSize    int64
	LeaderCount   int64
	StepCost      map[limit.Type]int64
}

ContainerInfluence records influences that pending operators will make.

func (*ContainerInfluence) AdjustStepCost

func (s *ContainerInfluence) AdjustStepCost(limitType limit.Type, resourceSize int64)

AdjustStepCost adjusts the step cost of specific type container limit according to resource size

func (ContainerInfluence) GetStepCost

func (s ContainerInfluence) GetStepCost(limitType limit.Type) int64

GetStepCost returns the specific type step cost

func (ContainerInfluence) ResourceProperty

func (s ContainerInfluence) ResourceProperty(kind core.ScheduleKind) int64

ResourceProperty returns delta size of leader/resource by influence.

type DemoteFollower

type DemoteFollower struct {
	ToContainer, PeerID uint64
}

DemoteFollower is an OpStep that demotes a resource follower peer to learner.

func (DemoteFollower) CheckSafety

func (df DemoteFollower) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (DemoteFollower) ConfVerChanged

func (df DemoteFollower) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (DemoteFollower) Influence

func (df DemoteFollower) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (DemoteFollower) IsFinish

func (df DemoteFollower) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (DemoteFollower) String

func (df DemoteFollower) String() string

type DemoteVoter

type DemoteVoter struct {
	ToContainer, PeerID uint64
}

DemoteVoter is very similar to DemoteFollower. But it allows Demote Leader. Note: It is not an OpStep, only a sub step in ChangePeerV2Enter and ChangePeerV2Leave.

func (DemoteVoter) ConfVerChanged

func (dv DemoteVoter) ConfVerChanged(res *core.CachedResource) bool

ConfVerChanged returns the delta value for version increased by this step.

func (DemoteVoter) IsFinish

func (dv DemoteVoter) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (DemoteVoter) String

func (dv DemoteVoter) String() string

type MergeResource

type MergeResource struct {
	FromResource metadata.Resource
	ToResource   metadata.Resource
	// there are two resources involved in merge process,
	// so to keep them from other scheduler,
	// both of them should add Merresource operatorStep.
	// But actually, your storage application just needs the resource want to be merged to get the merge request,
	// thus use a IsPassive mark to indicate that
	// this resource doesn't need to send merge request to your storage application.
	IsPassive bool
}

MergeResource is an OpStep that merge two resources.

func (MergeResource) CheckSafety

func (mr MergeResource) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (MergeResource) ConfVerChanged

func (mr MergeResource) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (MergeResource) Influence

func (mr MergeResource) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (MergeResource) IsFinish

func (mr MergeResource) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (MergeResource) String

func (mr MergeResource) String() string

type OpHistory

type OpHistory struct {
	FinishTime time.Time
	From, To   uint64
	Kind       metapb.ResourceKind
}

OpHistory is used to log and visualize completed operators.

type OpInfluence

type OpInfluence struct {
	ContainersInfluence map[uint64]*ContainerInfluence
}

OpInfluence records the influence of the cluster.

func (OpInfluence) GetContainerInfluence

func (m OpInfluence) GetContainerInfluence(id uint64) *ContainerInfluence

GetContainerInfluence get containerInfluence of specific container.

type OpKind

type OpKind uint32

OpKind is a bit field to identify operator types.

const (
	// Include leader transfer.
	OpLeader OpKind = 1 << iota
	// Include peer addition or removal. This means that this operator may take a long time.
	OpResource
	// Include resource split. Initiated by rule checker if `kind & OpAdmin == 0`.
	OpSplit
	// Initiated by admin.
	OpAdmin
	// Initiated by hot resource scheduler.
	OpHotResource
	// Initiated by replica checker.
	OpReplica
	// Initiated by merge checker or merge scheduler. Note that it may not include resource merge.
	OpMerge
	// Initiated by range scheduler.
	OpRange
)

Flags for operators.

func ParseOperatorKind

func ParseOperatorKind(str string) (OpKind, error)

ParseOperatorKind converts string (flag name list concat by ',') to OpKind.

func (OpKind) String

func (k OpKind) String() string

type OpStatus

type OpStatus = uint32

OpStatus represents the status of an Operator.

const (
	// Status list
	// Just created. Next status: {RUNNING, CANCELED, EXPIRED}.
	CREATED OpStatus = iota
	// Started and not finished. Next status: {SUCCESS, CANCELED, REPLACED, TIMEOUT}.
	STARTED
	// Followings are end status, i.e. no next status.
	SUCCESS  // Finished successfully
	CANCELED // Canceled due to some reason
	REPLACED // Replaced by an higher priority operator
	EXPIRED  // Didn't start to run for too long
	TIMEOUT  // Running for too long

)

Status list

type OpStatusTracker

type OpStatusTracker struct {
	// contains filtered or unexported fields
}

OpStatusTracker represents the status of an operator.

func NewOpStatusTracker

func NewOpStatusTracker() OpStatusTracker

NewOpStatusTracker creates an OpStatus.

func (*OpStatusTracker) CheckExpired

func (trk *OpStatusTracker) CheckExpired(exp time.Duration) bool

CheckExpired checks if expired, and update the current status.

func (*OpStatusTracker) CheckTimeout

func (trk *OpStatusTracker) CheckTimeout(wait time.Duration) bool

CheckTimeout checks if timeout, and update the current status.

func (*OpStatusTracker) IsEnd

func (trk *OpStatusTracker) IsEnd() bool

IsEnd checks whether the current status is an end status.

func (*OpStatusTracker) ReachTime

func (trk *OpStatusTracker) ReachTime() time.Time

ReachTime returns the reach time of current status.

func (*OpStatusTracker) ReachTimeOf

func (trk *OpStatusTracker) ReachTimeOf(s OpStatus) time.Time

ReachTimeOf returns the time when reached given status. If didn't reached the given status, return zero.

func (*OpStatusTracker) Status

func (trk *OpStatusTracker) Status() OpStatus

Status returns current status.

func (*OpStatusTracker) String

func (trk *OpStatusTracker) String() string

String implements fmt.Stringer.

func (*OpStatusTracker) To

func (trk *OpStatusTracker) To(dst OpStatus) bool

To transfer the current status to dst if this transition is valid, returns whether transferred.

type OpStep

type OpStep interface {
	fmt.Stringer
	ConfVerChanged(res *core.CachedResource) uint64
	IsFinish(res *core.CachedResource) bool
	CheckSafety(res *core.CachedResource) error
	Influence(opInfluence OpInfluence, res *core.CachedResource)
}

OpStep describes the basic scheduling steps that can not be subdivided.

type Operator

type Operator struct {
	Counters         []prometheus.Counter
	FinishedCounters []prometheus.Counter
	AdditionalInfos  map[string]string
	// contains filtered or unexported fields
}

Operator contains execution steps generated by scheduler.

func CreateAddPeerOperator

func CreateAddPeerOperator(desc string, cluster opt.Cluster, res *core.CachedResource, peer metapb.Peer, kind OpKind) (*Operator, error)

CreateAddPeerOperator creates an operator that adds a new peer.

func CreateForceTransferLeaderOperator

func CreateForceTransferLeaderOperator(desc string, cluster opt.Cluster, res *core.CachedResource, sourceContainerID uint64, targetContainerID uint64, kind OpKind) (*Operator, error)

CreateForceTransferLeaderOperator creates an operator that transfers the leader from a source container to a target container forcible.

func CreateLeaveJointStateOperator

func CreateLeaveJointStateOperator(desc string, cluster opt.Cluster, origin *core.CachedResource) (*Operator, error)

CreateLeaveJointStateOperator creates an operator that let resource leave joint state.

func CreateMergeResourceOperator

func CreateMergeResourceOperator(desc string, cluster opt.Cluster, source *core.CachedResource, target *core.CachedResource, kind OpKind) ([]*Operator, error)

CreateMergeResourceOperator creates an operator that merge two resource into one.

func CreateMoveLeaderOperator

func CreateMoveLeaderOperator(desc string, cluster opt.Cluster, res *core.CachedResource, kind OpKind, oldContainer uint64, peer metapb.Peer) (*Operator, error)

CreateMoveLeaderOperator creates an operator that replaces an old leader with a new leader.

func CreateMovePeerOperator

func CreateMovePeerOperator(desc string, cluster opt.Cluster, res *core.CachedResource, kind OpKind, oldContainer uint64, peer metapb.Peer) (*Operator, error)

CreateMovePeerOperator creates an operator that replaces an old peer with a new peer.

func CreateMoveResourceOperator

func CreateMoveResourceOperator(desc string, cluster opt.Cluster, res *core.CachedResource, kind OpKind, roles map[uint64]placement.PeerRoleType) (*Operator, error)

CreateMoveResourceOperator creates an operator that moves a resource to specified containers.

func CreatePromoteLearnerOperator

func CreatePromoteLearnerOperator(desc string, cluster opt.Cluster, res *core.CachedResource, peer metapb.Peer) (*Operator, error)

CreatePromoteLearnerOperator creates an operator that promotes a learner.

func CreateRemovePeerOperator

func CreateRemovePeerOperator(desc string, cluster opt.Cluster, kind OpKind, res *core.CachedResource, containerID uint64) (*Operator, error)

CreateRemovePeerOperator creates an operator that removes a peer from resource.

func CreateScatterResourceOperator

func CreateScatterResourceOperator(desc string, cluster opt.Cluster, origin *core.CachedResource, targetPeers map[uint64]metapb.Peer, targetLeader uint64) (*Operator, error)

CreateScatterResourceOperator creates an operator that scatters the specified resource.

func CreateSplitResourceOperator

func CreateSplitResourceOperator(desc string, res *core.CachedResource, kind OpKind, policy metapb.CheckPolicy, keys [][]byte) (*Operator, error)

CreateSplitResourceOperator creates an operator that splits a resource.

func CreateTransferLeaderOperator

func CreateTransferLeaderOperator(desc string, cluster opt.Cluster, res *core.CachedResource, sourceContainerID uint64, targetContainerID uint64, kind OpKind) (*Operator, error)

CreateTransferLeaderOperator creates an operator that transfers the leader from a source container to a target container.

func NewOperator

func NewOperator(desc, brief string, resID uint64, resEpoch metapb.ResourceEpoch, kind OpKind, steps ...OpStep) *Operator

NewOperator creates a new operator.

func (*Operator) AttachKind

func (o *Operator) AttachKind(kind OpKind)

AttachKind attaches an operator kind for the operator.

func (*Operator) Cancel

func (o *Operator) Cancel() bool

Cancel marks the operator canceled.

func (*Operator) Check

func (o *Operator) Check(res *core.CachedResource) OpStep

Check checks if current step is finished, returns next step to take action. If operator is at an end status, check returns nil. It's safe to be called by multiple goroutine concurrently.

func (*Operator) CheckExpired

func (o *Operator) CheckExpired() bool

CheckExpired checks if the operator is expired, and update the status.

func (*Operator) CheckSuccess

func (o *Operator) CheckSuccess() bool

CheckSuccess checks if all steps are finished, and update the status.

func (*Operator) CheckTimeout

func (o *Operator) CheckTimeout() bool

CheckTimeout checks if the operator is timeout, and update the status.

func (*Operator) ConfVerChanged

func (o *Operator) ConfVerChanged(res *core.CachedResource) (total uint64)

ConfVerChanged returns the number of confver has consumed by steps

func (*Operator) Desc

func (o *Operator) Desc() string

Desc returns the operator's short description.

func (*Operator) ElapsedTime

func (o *Operator) ElapsedTime() time.Duration

ElapsedTime returns duration since it was created.

func (*Operator) GetAdditionalInfo

func (o *Operator) GetAdditionalInfo() string

GetAdditionalInfo returns additional info with string

func (*Operator) GetCreateTime

func (o *Operator) GetCreateTime() time.Time

GetCreateTime gets the create time of operator.

func (*Operator) GetPriorityLevel

func (o *Operator) GetPriorityLevel() core.PriorityLevel

GetPriorityLevel gets the priority level.

func (*Operator) GetReachTimeOf

func (o *Operator) GetReachTimeOf(st OpStatus) time.Time

GetReachTimeOf returns the time when operator reaches the given status.

func (*Operator) GetStartTime

func (o *Operator) GetStartTime() time.Time

GetStartTime gets the start time of operator.

func (*Operator) HasStarted

func (o *Operator) HasStarted() bool

HasStarted returns whether operator has started.

func (*Operator) History

func (o *Operator) History() []OpHistory

History transfers the operator's steps to operator histories.

func (*Operator) IsEnd

func (o *Operator) IsEnd() bool

IsEnd checks if the operator is at and end status.

func (*Operator) Kind

func (o *Operator) Kind() OpKind

Kind returns operator's kind.

func (*Operator) Len

func (o *Operator) Len() int

Len returns the operator's steps count.

func (*Operator) MarshalJSON

func (o *Operator) MarshalJSON() ([]byte, error)

MarshalJSON serializes custom types to JSON.

func (*Operator) Replace

func (o *Operator) Replace() bool

Replace marks the operator replaced.

func (*Operator) ResourceEpoch

func (o *Operator) ResourceEpoch() metapb.ResourceEpoch

ResourceEpoch returns the resource's epoch that is attached to the operator.

func (*Operator) ResourceID

func (o *Operator) ResourceID() uint64

ResourceID returns the resource that operator is targeted.

func (*Operator) RunningTime

func (o *Operator) RunningTime() time.Duration

RunningTime returns duration since it started.

func (*Operator) SetDesc

func (o *Operator) SetDesc(desc string)

SetDesc sets the description for the operator.

func (*Operator) SetPriorityLevel

func (o *Operator) SetPriorityLevel(level core.PriorityLevel)

SetPriorityLevel sets the priority level for operator.

func (*Operator) Start

func (o *Operator) Start() bool

Start sets the operator to STARTED status, returns whether succeeded.

func (*Operator) Status

func (o *Operator) Status() OpStatus

Status returns operator status.

func (*Operator) Step

func (o *Operator) Step(i int) OpStep

Step returns the i-th step.

func (*Operator) String

func (o *Operator) String() string

func (*Operator) TotalInfluence

func (o *Operator) TotalInfluence(opInfluence OpInfluence, res *core.CachedResource)

TotalInfluence calculates the container difference which whole operator steps make.

func (*Operator) UnfinishedInfluence

func (o *Operator) UnfinishedInfluence(opInfluence OpInfluence, res *core.CachedResource)

UnfinishedInfluence calculates the container difference which unfinished operator steps make.

type PromoteLearner

type PromoteLearner struct {
	ToContainer, PeerID uint64
}

PromoteLearner is an OpStep that promotes a resource learner peer to normal voter.

func (PromoteLearner) CheckSafety

func (pl PromoteLearner) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (PromoteLearner) ConfVerChanged

func (pl PromoteLearner) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (PromoteLearner) Influence

func (pl PromoteLearner) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (PromoteLearner) IsFinish

func (pl PromoteLearner) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (PromoteLearner) String

func (pl PromoteLearner) String() string

type RemovePeer

type RemovePeer struct {
	FromContainer, PeerID uint64
}

RemovePeer is an OpStep that removes a resource peer.

func (RemovePeer) CheckSafety

func (rp RemovePeer) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (RemovePeer) ConfVerChanged

func (rp RemovePeer) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (RemovePeer) Influence

func (rp RemovePeer) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (RemovePeer) IsFinish

func (rp RemovePeer) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (RemovePeer) String

func (rp RemovePeer) String() string

type SplitResource

type SplitResource struct {
	StartKey, EndKey []byte
	Policy           metapb.CheckPolicy
	SplitKeys        [][]byte
}

SplitResource is an OpStep that splits a resource.

func (SplitResource) CheckSafety

func (sr SplitResource) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (SplitResource) ConfVerChanged

func (sr SplitResource) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (SplitResource) Influence

func (sr SplitResource) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (SplitResource) IsFinish

func (sr SplitResource) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (SplitResource) String

func (sr SplitResource) String() string

type TransferLeader

type TransferLeader struct {
	FromContainer, ToContainer uint64
}

TransferLeader is an OpStep that transfers a resource's leader.

func (TransferLeader) CheckSafety

func (tl TransferLeader) CheckSafety(res *core.CachedResource) error

CheckSafety checks if the step meets the safety properties.

func (TransferLeader) ConfVerChanged

func (tl TransferLeader) ConfVerChanged(res *core.CachedResource) uint64

ConfVerChanged returns the delta value for version increased by this step.

func (TransferLeader) Influence

func (tl TransferLeader) Influence(opInfluence OpInfluence, res *core.CachedResource)

Influence calculates the container difference that current step makes.

func (TransferLeader) IsFinish

func (tl TransferLeader) IsFinish(res *core.CachedResource) bool

IsFinish checks if current step is finished.

func (TransferLeader) String

func (tl TransferLeader) String() string

Jump to

Keyboard shortcuts

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