Documentation ¶
Index ¶
- type LeaderLease
- type Member
- func (m *Member) CampaignLeader(lease *LeaderLease, leaseTimeout int64) error
- func (m *Member) CheckLeader(name string) (*pdpb.Member, int64, bool)
- func (m *Member) CheckPriority(ctx context.Context)
- func (m *Member) Close()
- func (m *Member) DeleteMemberLeaderPriority(id uint64) error
- func (m *Member) DisableLeader()
- func (m *Member) EnableLeader()
- func (m *Member) Etcd() *embed.Etcd
- func (m *Member) GetEtcdLeader() uint64
- func (m *Member) GetLeader() *pdpb.Member
- func (m *Member) GetLeaderID() uint64
- func (m *Member) GetLeaderPath() string
- func (m *Member) GetMemberLeaderPriority(id uint64) (int, error)
- func (m *Member) ID() uint64
- func (m *Member) IsLeader() bool
- func (m *Member) LeaderTxn(cs ...clientv3.Cmp) clientv3.Txn
- func (m *Member) Member() *pdpb.Member
- func (m *Member) MemberInfo(cfg *config.Config, name string, rootPath string)
- func (m *Member) MemberValue() string
- func (m *Member) MoveEtcdLeader(ctx context.Context, old, new uint64) error
- func (m *Member) ResignLeader(ctx context.Context, from string, nextLeader string) error
- func (m *Member) SetMemberLeaderPriority(id uint64, priority int) error
- func (m *Member) WatchLeader(serverCtx context.Context, leader *pdpb.Member, revision int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LeaderLease ¶
LeaderLease is used for renewing leadership of PD server.
func NewLeaderLease ¶
func NewLeaderLease(client *clientv3.Client) *LeaderLease
NewLeaderLease creates a lease.
func (*LeaderLease) Grant ¶
func (l *LeaderLease) Grant(leaseTimeout int64) error
Grant uses `lease.Grant` to initialize the lease and expireTime.
func (*LeaderLease) IsExpired ¶
func (l *LeaderLease) IsExpired() bool
IsExpired checks if the lease is expired. If it returns true, current PD server should step down and try to re-elect again.
func (*LeaderLease) KeepAlive ¶
func (l *LeaderLease) KeepAlive(ctx context.Context)
KeepAlive auto renews the lease and update expireTime.
type Member ¶
type Member struct {
// contains filtered or unexported fields
}
Member is used for the election related logic.
func (*Member) CampaignLeader ¶
func (m *Member) CampaignLeader(lease *LeaderLease, leaseTimeout int64) error
CampaignLeader is used to campaign the leader.
func (*Member) CheckLeader ¶
CheckLeader checks returns true if it is needed to check later.
func (*Member) CheckPriority ¶
CheckPriority if the leader will be moved according to the priority.
func (*Member) DeleteMemberLeaderPriority ¶
DeleteMemberLeaderPriority removes a member's priority config.
func (*Member) DisableLeader ¶
func (m *Member) DisableLeader()
DisableLeader reset the leader value.
func (*Member) EnableLeader ¶
func (m *Member) EnableLeader()
EnableLeader sets the member to leader.
func (*Member) GetEtcdLeader ¶
GetEtcdLeader returns the etcd leader ID.
func (*Member) GetLeaderID ¶
GetLeaderID returns current leader's member ID.
func (*Member) GetLeaderPath ¶
GetLeaderPath returns the path of the leader.
func (*Member) GetMemberLeaderPriority ¶
GetMemberLeaderPriority loads a member's priority to be elected as the etcd leader.
func (*Member) LeaderTxn ¶
LeaderTxn returns txn() with a leader comparison to guarantee that the transaction can be executed only if the server is leader.
func (*Member) MemberInfo ¶
MemberInfo initializes the member info.
func (*Member) MemberValue ¶
MemberValue returns the member value.
func (*Member) MoveEtcdLeader ¶
MoveEtcdLeader tries to transfer etcd leader.
func (*Member) ResignLeader ¶
ResignLeader resigns current PD's leadership. If nextLeader is empty, all other pd-servers can campaign.
func (*Member) SetMemberLeaderPriority ¶
SetMemberLeaderPriority saves a member's priority to be elected as the etcd leader.