Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateClusterAndAssignIDs(local *Membership, existing *Membership) error
- type Member
- type MembersByID
- type MembersByPeerURLs
- type Membership
- func (c *Membership) AddMemberAndPersistence(member *Member)
- func (c *Membership) GetMemberFromStore(ID uint64) *Member
- func (c *Membership) GetSelfMemberID() types.ID
- func (c *Membership) IsIDInMembership(id types.ID) bool
- func (c *Membership) IsIDRemoved(id types.ID) bool
- func (c *Membership) IsMemberIDExistsInStore(ID uint64) bool
- func (c *Membership) Member(id types.ID) *Member
- func (c *Membership) MemberByName(name string) *Member
- func (c *Membership) MemberCount() int
- func (c *Membership) MemberIDs() []types.ID
- func (c *Membership) Members() []*Member
- func (c *Membership) PersistenceMeta()
- func (c *Membership) Print()
- func (c *Membership) RemoveMemberAndPersistence(id types.ID)
- func (c *Membership) RemovedIDs() []types.ID
- func (c *Membership) UpdateMemberAndPersistence(member *Member)
- func (c *Membership) ValidateConfigurationChange(cc raftpb.ConfChange) error
- type MembershipMembers
- type MembershipMeta
- type MembershipStore
- func (s *MembershipStore) AddMember(member *Member, groupName string)
- func (s *MembershipStore) DeleteMember(id types.ID, groupName string)
- func (s *MembershipStore) GetMembers(groupName string) *MembershipMembers
- func (s *MembershipStore) GetMeta(groupName string) *MembershipMeta
- func (s *MembershipStore) SaveMeta(meta *MembershipMeta, groupName string)
- func (s *MembershipStore) UpdateMember(member *Member, groupName string)
- type MembershipVersion
Constants ¶
const ( MembersKeyPrefix = "membership_membersKeyPrefix" MetaKeyPrefix = "membership_metaKeyPrefix" )
Variables ¶
Functions ¶
func ValidateClusterAndAssignIDs ¶
func ValidateClusterAndAssignIDs(local *Membership, existing *Membership) error
ValidateClusterAndAssignIDs validates the local cluster by matching the PeerURLs with the existing cluster. If the validation succeeds, it assigns the IDs from the existing cluster to the local cluster. If the validation fails, an error will be returned.
Types ¶
type Member ¶
type Member struct { // Member ID, which generate by urls, raft group name and time(if exists) ID types.ID `json:"id"` // VDL server name Name string `json:"name,omitempty"` // peer urls PeerURLs []string `json:"peerURLs"` }
type MembersByID ¶
type MembersByID []*Member
MembersByID implements sort by ID interface
func (MembersByID) Len ¶
func (ms MembersByID) Len() int
func (MembersByID) Less ¶
func (ms MembersByID) Less(i, j int) bool
func (MembersByID) Swap ¶
func (ms MembersByID) Swap(i, j int)
type MembersByPeerURLs ¶
type MembersByPeerURLs []*Member
MembersByPeerURLs implements sort by peer urls interface
func (MembersByPeerURLs) Len ¶
func (ms MembersByPeerURLs) Len() int
func (MembersByPeerURLs) Less ¶
func (ms MembersByPeerURLs) Less(i, j int) bool
func (MembersByPeerURLs) Swap ¶
func (ms MembersByPeerURLs) Swap(i, j int)
type Membership ¶
type Membership struct { MembershipMeta MembershipMembers // raft group name RaftGroupName string `json:"-"` //vdl server name ServerName string `json:"-"` // guards the fields below sync.Mutex // contains filtered or unexported fields }
func NewMembershipFromInitialPeerURLsMap ¶
func NewMembershipFromInitialPeerURLsMap(initialPeerURLsMap types.URLsMap, raftGroupName string, vdlServerName string, stableStore stablestore.StableStore) (*Membership, error)
use for start a new Raft Group it will use InitialPeerURLs on configuration NOTICE: it just load the InitialPeerURLs and put into memory struct, but didn't persistent
func NewMembershipFromStore ¶
func NewMembershipFromStore(raftGroupName string, stableStore stablestore.StableStore, vdlServerName string) *Membership
func (*Membership) AddMemberAndPersistence ¶
func (c *Membership) AddMemberAndPersistence(member *Member)
AddMember adds a new Member into the cluster, and saves the given member's raftAttributes into the store. The given member should have empty attributes. A Member with a matching id must not exist.
func (*Membership) GetMemberFromStore ¶
func (c *Membership) GetMemberFromStore(ID uint64) *Member
func (*Membership) GetSelfMemberID ¶
func (c *Membership) GetSelfMemberID() types.ID
func (*Membership) IsIDInMembership ¶
func (c *Membership) IsIDInMembership(id types.ID) bool
func (*Membership) IsIDRemoved ¶
func (c *Membership) IsIDRemoved(id types.ID) bool
func (*Membership) IsMemberIDExistsInStore ¶
func (c *Membership) IsMemberIDExistsInStore(ID uint64) bool
check whether ID exists in store(after apply)
func (*Membership) MemberByName ¶
func (c *Membership) MemberByName(name string) *Member
MemberByName returns a Member with the given name if exists. If more than one member has the given name, it will panic.
func (*Membership) MemberCount ¶
func (c *Membership) MemberCount() int
func (*Membership) MemberIDs ¶
func (c *Membership) MemberIDs() []types.ID
func (*Membership) Members ¶
func (c *Membership) Members() []*Member
func (*Membership) PersistenceMeta ¶
func (c *Membership) PersistenceMeta()
func (*Membership) Print ¶
func (c *Membership) Print()
func (*Membership) RemoveMemberAndPersistence ¶
func (c *Membership) RemoveMemberAndPersistence(id types.ID)
RemoveMember removes a member from the store. The given id MUST exist, or the function panics.
func (*Membership) RemovedIDs ¶
func (c *Membership) RemovedIDs() []types.ID
func (*Membership) UpdateMemberAndPersistence ¶
func (c *Membership) UpdateMemberAndPersistence(member *Member)
func (*Membership) ValidateConfigurationChange ¶
func (c *Membership) ValidateConfigurationChange(cc raftpb.ConfChange) error
ValidateConfigurationChange takes a proposed ConfChange and ensures that it is still valid.
type MembershipMembers ¶
type MembershipMeta ¶
type MembershipMeta struct { // cluster ID // which generate by membersID which from initial-cluster when create new Raft Group // This ClusterID use to check whether the same cluster for cross-cluster-interaction ClusterID types.ID `json:"clusterID"` //version for membership Version MembershipVersion `json:"version"` //self memberid SelfMemberID types.ID `json:"name,omitempty"` }
type MembershipStore ¶
type MembershipStore struct { // guards the db sync.Mutex // contains filtered or unexported fields }
func NewMembershipStore ¶
func NewMembershipStore(stableStore stablestore.StableStore) *MembershipStore
func (*MembershipStore) AddMember ¶
func (s *MembershipStore) AddMember(member *Member, groupName string)
func (*MembershipStore) DeleteMember ¶
func (s *MembershipStore) DeleteMember(id types.ID, groupName string)
func (*MembershipStore) GetMembers ¶
func (s *MembershipStore) GetMembers(groupName string) *MembershipMembers
when no members in store, return nil
func (*MembershipStore) GetMeta ¶
func (s *MembershipStore) GetMeta(groupName string) *MembershipMeta
when no member meta in store, return nil
func (*MembershipStore) SaveMeta ¶
func (s *MembershipStore) SaveMeta(meta *MembershipMeta, groupName string)
func (*MembershipStore) UpdateMember ¶
func (s *MembershipStore) UpdateMember(member *Member, groupName string)