owner

package
v1.1.0-beta.0...-801e555 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ManagerSessionTTL = 60

ManagerSessionTTL is the etcd session's TTL in seconds. It's exported for testing.

Functions

func GetOwnerKeyInfo

func GetOwnerKeyInfo(
	ctx, logCtx context.Context,
	etcdCli *clientv3.Client,
	etcdKey, id string,
) (string, int64, error)

GetOwnerKeyInfo gets the owner key and current revision.

func WatchOwnerForTest

func WatchOwnerForTest(ctx context.Context, m Manager, etcdSession *concurrency.Session, key string, createRevison int64) error

WatchOwnerForTest watches the ownerKey. This function is used to test watchOwner().

Types

type DDLOwnerChecker

type DDLOwnerChecker interface {
	// IsOwner returns whether the ownerManager is the owner.
	IsOwner() bool
}

DDLOwnerChecker is used to check whether tidb is owner.

type Listener

type Listener interface {
	OnBecomeOwner()
	OnRetireOwner()
}

Listener is used to listen the ownerManager's owner state.

type Manager

type Manager interface {
	// ID returns the ID of the manager.
	ID() string
	// IsOwner returns whether the ownerManager is the owner.
	IsOwner() bool
	// RetireOwner make the manager to be a not owner. It's exported for testing.
	RetireOwner()
	// GetOwnerID gets the owner ID.
	GetOwnerID(ctx context.Context) (string, error)
	// SetOwnerOpValue updates the owner op value.
	SetOwnerOpValue(ctx context.Context, op OpType) error
	// CampaignOwner campaigns the owner.
	CampaignOwner(...int) error
	// ResignOwner lets the owner start a new election.
	ResignOwner(ctx context.Context) error
	// Cancel cancels this etcd ownerManager.
	Cancel()
	// RequireOwner requires the ownerManager is owner.
	RequireOwner(ctx context.Context) error
	// CampaignCancel cancels one etcd campaign
	CampaignCancel()
	// SetListener sets the listener, set before CampaignOwner.
	SetListener(listener Listener)
}

Manager is used to campaign the owner and manage the owner information.

func NewMockManager

func NewMockManager(ctx context.Context, id string, store kv.Storage, ownerKey string) Manager

NewMockManager creates a new mock Manager.

func NewOwnerManager

func NewOwnerManager(ctx context.Context, etcdCli *clientv3.Client, prompt, id, key string) Manager

NewOwnerManager creates a new Manager.

type OpType

type OpType byte

OpType is the owner key value operation type.

const (
	OpNone               OpType = 0
	OpSyncUpgradingState OpType = 1
)

List operation of types.

func GetOwnerOpValue

func GetOwnerOpValue(ctx context.Context, etcdCli *clientv3.Client, ownerPath, logPrefix string) (OpType, error)

GetOwnerOpValue gets the owner op value.

func (OpType) IsSyncedUpgradingState

func (ot OpType) IsSyncedUpgradingState() bool

IsSyncedUpgradingState represents whether the upgrading state is synchronized.

func (OpType) String

func (ot OpType) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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