operator

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExpireTime         = 15 * time.Second
	NoopEpoch   uint64 = 0
	NoopShardID uint64 = 0
)

Variables

This section is empty.

Functions

func IsEndStatus

func IsEndStatus(s OpStatus) bool

IsEndStatus checks whether s is an end status.

func OpStatusToString

func OpStatusToString(s OpStatus) string

OpStatusToString converts Status to string.

Types

type AddDnReplica

type AddDnReplica struct {
	StoreID            string
	ShardID, ReplicaID uint64
}

func (AddDnReplica) IsFinish

func (a AddDnReplica) IsFinish(_ pb.LogState, state pb.DNState) bool

func (AddDnReplica) String

func (a AddDnReplica) String() string

type AddLogService

type AddLogService struct {
	Target string

	StoreID   string
	ShardID   uint64
	ReplicaID uint64
	Epoch     uint64
}

func (AddLogService) IsFinish

func (a AddLogService) IsFinish(state pb.LogState, _ pb.DNState) bool

func (AddLogService) String

func (a AddLogService) String() string

type Builder

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

Builder is used to create operators. Usage:

op, err := NewBuilder(desc, cluster, shard).
            RemovePeer(store1).
            AddPeer(peer1).
            Build(kind)

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

func NewBuilder

func NewBuilder(desc string, shardInfo logservice.LogShardInfo) *Builder

NewBuilder creates a Builder.

func (*Builder) AddPeer

func (b *Builder) AddPeer(uuid string, peer uint64) *Builder

AddPeer records an add Peer operation in Builder.

func (*Builder) Build

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

Build creates the Operator.

func (*Builder) RemovePeer

func (b *Builder) RemovePeer(uuid string) *Builder

RemovePeer records a remove peer operation in Builder.

type Controller

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

Controller is used to manage operators.

func NewController

func NewController() *Controller

func (*Controller) Dispatch

func (c *Controller) Dispatch(ops []*Operator, logState pb.LogState, dnState pb.DNState) (commands []pb.ScheduleCommand)

func (*Controller) GetAddingReplicas

func (c *Controller) GetAddingReplicas() map[uint64][]uint64

func (*Controller) GetOperators

func (c *Controller) GetOperators(shardID uint64) []*Operator

GetOperators gets operators from the given shard.

func (*Controller) GetRemovingReplicas

func (c *Controller) GetRemovingReplicas() map[uint64][]uint64

func (*Controller) RemoveFinishedOperator

func (c *Controller) RemoveFinishedOperator(logState pb.LogState, dnState pb.DNState)

func (*Controller) RemoveOperator

func (c *Controller) RemoveOperator(op *Operator) bool

RemoveOperator removes an operator from the operators.

type OpStatus

type OpStatus = uint32

OpStatus represents the status of an Operator.

const (

	// STARTED and not finished. Next status: { SUCCESS, CANCELED, EXPIRED}.
	STARTED OpStatus = iota

	// SUCCESS Finished successfully
	SUCCESS

	// CANCELED due to some reason
	CANCELED

	// EXPIRED waiting for too long
	EXPIRED
)

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) 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

	IsFinish(state pb.LogState, dnState pb.DNState) bool
}

type Operator

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

Operator contains execution steps generated by scheduler.

func CreateAddReplica

func CreateAddReplica(uuid util.StoreID, shardInfo logservice.LogShardInfo, replicaID uint64) (*Operator, error)

func CreateRemoveReplica

func CreateRemoveReplica(uuid util.StoreID, shardInfo logservice.LogShardInfo) (*Operator, error)

func CreateStartReplica

func CreateStartReplica(brief string, uuid util.StoreID, shardID, replicaID uint64) *Operator

func CreateStopReplica

func CreateStopReplica(brief string, uuid util.StoreID, shardID uint64) *Operator

func NewOperator

func NewOperator(brief string, shardID uint64, epoch uint64, steps ...OpStep) *Operator

NewOperator creates a new operator.

func (*Operator) Cancel

func (o *Operator) Cancel() bool

Cancel marks the operator canceled.

func (*Operator) Check

func (o *Operator) Check(logState pb.LogState, dnState pb.DNState) OpStep

func (*Operator) CheckExpired

func (o *Operator) CheckExpired() bool

CheckExpired checks if the operator is timeout, 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) 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) IsEnd

func (o *Operator) IsEnd() bool

IsEnd checks if the operator is at and end status.

func (*Operator) OpSteps

func (o *Operator) OpSteps() []OpStep

OpSteps returns operator steps.

func (*Operator) SetStatus added in v0.5.1

func (o *Operator) SetStatus(status OpStatus)

SetStatus only used for tests.

func (*Operator) ShardID

func (o *Operator) ShardID() uint64

ShardID returns shard ID.

func (*Operator) Status

func (o *Operator) Status() OpStatus

Status returns operator status.

type RemoveDnReplica

type RemoveDnReplica struct {
	StoreID            string
	ShardID, ReplicaID uint64
}

func (RemoveDnReplica) IsFinish

func (a RemoveDnReplica) IsFinish(_ pb.LogState, state pb.DNState) bool

func (RemoveDnReplica) String

func (a RemoveDnReplica) String() string

type RemoveLogService

type RemoveLogService struct {
	Target string

	StoreID   string
	ShardID   uint64
	ReplicaID uint64
	Epoch     uint64
}

func (RemoveLogService) IsFinish

func (a RemoveLogService) IsFinish(state pb.LogState, _ pb.DNState) bool

func (RemoveLogService) String

func (a RemoveLogService) String() string

type StartLogService

type StartLogService struct {
	StoreID            string
	ShardID, ReplicaID uint64
}

func (StartLogService) IsFinish

func (a StartLogService) IsFinish(state pb.LogState, _ pb.DNState) bool

func (StartLogService) String

func (a StartLogService) String() string

type StopDnStore

type StopDnStore struct {
	StoreID string
}

StopDnStore corresponds to dn store shutdown command.

func (StopDnStore) IsFinish

func (a StopDnStore) IsFinish(_ pb.LogState, state pb.DNState) bool

func (StopDnStore) String

func (a StopDnStore) String() string

type StopLogService

type StopLogService struct {
	StoreID string
	ShardID uint64
}

func (StopLogService) IsFinish

func (a StopLogService) IsFinish(state pb.LogState, _ pb.DNState) bool

func (StopLogService) String

func (a StopLogService) String() string

type StopLogStore

type StopLogStore struct {
	StoreID string
}

StopLogStore corresponds to log store shutdown command.

func (StopLogStore) IsFinish

func (a StopLogStore) IsFinish(state pb.LogState, _ pb.DNState) bool

func (StopLogStore) String

func (a StopLogStore) String() string

Jump to

Keyboard shortcuts

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