Documentation ¶
Index ¶
- Variables
- func AcquireDistributedLock(ctx context.Context, cli *clientv3.Client, key string, ttlInSec int) (release func(), err error)
- func GetOwnerKeyInfo(ctx, logCtx context.Context, etcdCli *clientv3.Client, etcdKey, id string) (string, int64, error)
- func WatchOwnerForTest(ctx context.Context, m Manager, etcdSession *concurrency.Session, key string, ...) error
- type DDLOwnerChecker
- type Listener
- type Manager
- type OpType
Constants ¶
This section is empty.
Variables ¶
var ManagerSessionTTL = 60
ManagerSessionTTL is the etcd session's TTL in seconds. It's exported for testing.
Functions ¶
func AcquireDistributedLock ¶
func AcquireDistributedLock( ctx context.Context, cli *clientv3.Client, key string, ttlInSec int, ) (release func(), err error)
AcquireDistributedLock creates a mutex with ETCD client, and returns a mutex release function.
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 ¶
NewMockManager creates a new mock Manager.
type OpType ¶
type OpType byte
OpType is the owner key value operation type.
func GetOwnerOpValue ¶
func GetOwnerOpValue(ctx context.Context, etcdCli *clientv3.Client, ownerPath, logPrefix string) (OpType, error)
GetOwnerOpValue gets the owner op value.
func (OpType) IsSyncedUpgradingState ¶
IsSyncedUpgradingState represents whether the upgrading state is synchronized.