member

package
v3.1.0-rc Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LeaderLease

type LeaderLease struct {
	ID clientv3.LeaseID
	// contains filtered or unexported fields
}

LeaderLease is used for renewing leadership of PD server.

func NewLeaderLease

func NewLeaderLease(client *clientv3.Client) *LeaderLease

NewLeaderLease creates a lease.

func (*LeaderLease) Close

func (l *LeaderLease) Close() error

Close releases the 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 NewMember

func NewMember(etcd *embed.Etcd, client *clientv3.Client, id uint64) *Member

NewMember create a new Member.

func (*Member) CampaignLeader

func (m *Member) CampaignLeader(lease *LeaderLease, leaseTimeout int64) error

CampaignLeader is used to campaign the leader.

func (*Member) CheckLeader

func (m *Member) CheckLeader(name string) (*pdpb.Member, int64, bool)

CheckLeader checks returns true if it is needed to check later.

func (*Member) CheckPriority

func (m *Member) CheckPriority(ctx context.Context)

CheckPriority if the leader will be moved according to the priority.

func (*Member) Close

func (m *Member) Close()

Close gracefully shuts down all servers/listeners.

func (*Member) DeleteMemberLeaderPriority

func (m *Member) DeleteMemberLeaderPriority(id uint64) error

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

func (m *Member) Etcd() *embed.Etcd

Etcd returns etcd related information.

func (*Member) GetEtcdLeader

func (m *Member) GetEtcdLeader() uint64

GetEtcdLeader returns the etcd leader ID.

func (*Member) GetLeader

func (m *Member) GetLeader() *pdpb.Member

GetLeader returns current leader of PD cluster.

func (*Member) GetLeaderID

func (m *Member) GetLeaderID() uint64

GetLeaderID returns current leader's member ID.

func (*Member) GetLeaderPath

func (m *Member) GetLeaderPath() string

GetLeaderPath returns the path of the leader.

func (*Member) GetMemberLeaderPriority

func (m *Member) GetMemberLeaderPriority(id uint64) (int, error)

GetMemberLeaderPriority loads a member's priority to be elected as the etcd leader.

func (*Member) ID

func (m *Member) ID() uint64

ID returns the unique etcd ID for this server in etcd cluster.

func (*Member) IsLeader

func (m *Member) IsLeader() bool

IsLeader returns whether the server is leader or not.

func (*Member) LeaderTxn

func (m *Member) LeaderTxn(cs ...clientv3.Cmp) clientv3.Txn

LeaderTxn returns txn() with a leader comparison to guarantee that the transaction can be executed only if the server is leader.

func (*Member) Member

func (m *Member) Member() *pdpb.Member

Member returns the member.

func (*Member) MemberInfo

func (m *Member) MemberInfo(cfg *config.Config, name string, rootPath string)

MemberInfo initializes the member info.

func (*Member) MemberValue

func (m *Member) MemberValue() string

MemberValue returns the member value.

func (*Member) MoveEtcdLeader

func (m *Member) MoveEtcdLeader(ctx context.Context, old, new uint64) error

MoveEtcdLeader tries to transfer etcd leader.

func (*Member) ResignLeader

func (m *Member) ResignLeader(ctx context.Context, from string, nextLeader string) error

ResignLeader resigns current PD's leadership. If nextLeader is empty, all other pd-servers can campaign.

func (*Member) SetMemberLeaderPriority

func (m *Member) SetMemberLeaderPriority(id uint64, priority int) error

SetMemberLeaderPriority saves a member's priority to be elected as the etcd leader.

func (*Member) WatchLeader

func (m *Member) WatchLeader(serverCtx context.Context, leader *pdpb.Member, revision int64)

WatchLeader is used to watch the changes of the leader.

Jump to

Keyboard shortcuts

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