membership - ActiveState ActiveGo 1.8
...

Package membership

import "github.com/coreos/etcd/etcdserver/membership"
Overview
Index

Overview ▾

Package membership describes individual etcd members and clusters of members.

Index ▾

Variables
func MemberAttributesStorePath(id types.ID) string
func MemberStoreKey(id types.ID) string
func MustParseMemberIDFromKey(key string) types.ID
func RemovedMemberStoreKey(id types.ID) string
func StoreClusterVersionKey() string
func ValidateClusterAndAssignIDs(local *RaftCluster, existing *RaftCluster) error
type Attributes
type Member
    func NewMember(name string, peerURLs types.URLs, clusterName string, now *time.Time) *Member
    func (m *Member) Clone() *Member
    func (m *Member) IsStarted() bool
    func (m *Member) PickPeerURL() string
type MembersByID
    func (ms MembersByID) Len() int
    func (ms MembersByID) Less(i, j int) bool
    func (ms MembersByID) Swap(i, j int)
type MembersByPeerURLs
    func (ms MembersByPeerURLs) Len() int
    func (ms MembersByPeerURLs) Less(i, j int) bool
    func (ms MembersByPeerURLs) Swap(i, j int)
type RaftAttributes
type RaftCluster
    func NewCluster(token string) *RaftCluster
    func NewClusterFromMembers(token string, id types.ID, membs []*Member) *RaftCluster
    func NewClusterFromURLsMap(token string, urlsmap types.URLsMap) (*RaftCluster, error)
    func (c *RaftCluster) AddMember(m *Member)
    func (c *RaftCluster) ClientURLs() []string
    func (c *RaftCluster) ID() types.ID
    func (c *RaftCluster) IsIDRemoved(id types.ID) bool
    func (c *RaftCluster) IsReadyToAddNewMember() bool
    func (c *RaftCluster) IsReadyToRemoveMember(id uint64) bool
    func (c *RaftCluster) Member(id types.ID) *Member
    func (c *RaftCluster) MemberByName(name string) *Member
    func (c *RaftCluster) MemberIDs() []types.ID
    func (c *RaftCluster) Members() []*Member
    func (c *RaftCluster) PeerURLs() []string
    func (c *RaftCluster) Recover(onSet func(*semver.Version))
    func (c *RaftCluster) RemoveMember(id types.ID)
    func (c *RaftCluster) SetBackend(be backend.Backend)
    func (c *RaftCluster) SetID(id types.ID)
    func (c *RaftCluster) SetStore(st store.Store)
    func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*semver.Version))
    func (c *RaftCluster) String() string
    func (c *RaftCluster) UpdateAttributes(id types.ID, attr Attributes)
    func (c *RaftCluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes)
    func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error
    func (c *RaftCluster) Version() *semver.Version

Package files

cluster.go doc.go errors.go member.go store.go

Variables

var (
    ErrIDRemoved     = errors.New("membership: ID removed")
    ErrIDExists      = errors.New("membership: ID exists")
    ErrIDNotFound    = errors.New("membership: ID not found")
    ErrPeerURLexists = errors.New("membership: peerURL exists")
)
var (
    StoreMembersPrefix = path.Join(storePrefix, "members")
)

func MemberAttributesStorePath

func MemberAttributesStorePath(id types.ID) string

func MemberStoreKey

func MemberStoreKey(id types.ID) string

func MustParseMemberIDFromKey

func MustParseMemberIDFromKey(key string) types.ID

func RemovedMemberStoreKey

func RemovedMemberStoreKey(id types.ID) string

func StoreClusterVersionKey

func StoreClusterVersionKey() string

func ValidateClusterAndAssignIDs

func ValidateClusterAndAssignIDs(local *RaftCluster, existing *RaftCluster) 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.

type Attributes

Attributes represents all the non-raft related attributes of an etcd member.

type Attributes struct {
    Name       string   `json:"name,omitempty"`
    ClientURLs []string `json:"clientURLs,omitempty"`
}

type Member

type Member struct {
    ID types.ID `json:"id"`
    RaftAttributes
    Attributes
}

func NewMember

func NewMember(name string, peerURLs types.URLs, clusterName string, now *time.Time) *Member

NewMember creates a Member without an ID and generates one based on the cluster name, peer URLs, and time. This is used for bootstrapping/adding new member.

func (*Member) Clone

func (m *Member) Clone() *Member

func (*Member) IsStarted

func (m *Member) IsStarted() bool

func (*Member) PickPeerURL

func (m *Member) PickPeerURL() string

PickPeerURL chooses a random address from a given Member's PeerURLs. It will panic if there is no PeerURLs available in Member.

type MembersByID

MembersByID implements sort by ID interface

type MembersByID []*Member

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

MembersByPeerURLs implements sort by peer urls interface

type MembersByPeerURLs []*Member

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 RaftAttributes

RaftAttributes represents the raft related attributes of an etcd member.

type RaftAttributes struct {
    // PeerURLs is the list of peers in the raft cluster.
    // TODO(philips): ensure these are URLs
    PeerURLs []string `json:"peerURLs"`
}

type RaftCluster

RaftCluster is a list of Members that belong to the same raft cluster

type RaftCluster struct {
    sync.Mutex // guards the fields below
    // contains filtered or unexported fields
}

func NewCluster

func NewCluster(token string) *RaftCluster

func NewClusterFromMembers

func NewClusterFromMembers(token string, id types.ID, membs []*Member) *RaftCluster

func NewClusterFromURLsMap

func NewClusterFromURLsMap(token string, urlsmap types.URLsMap) (*RaftCluster, error)

func (*RaftCluster) AddMember

func (c *RaftCluster) AddMember(m *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 (*RaftCluster) ClientURLs

func (c *RaftCluster) ClientURLs() []string

ClientURLs returns a list of all client addresses. The returned list is sorted in ascending lexicographical order.

func (*RaftCluster) ID

func (c *RaftCluster) ID() types.ID

func (*RaftCluster) IsIDRemoved

func (c *RaftCluster) IsIDRemoved(id types.ID) bool

func (*RaftCluster) IsReadyToAddNewMember

func (c *RaftCluster) IsReadyToAddNewMember() bool

func (*RaftCluster) IsReadyToRemoveMember

func (c *RaftCluster) IsReadyToRemoveMember(id uint64) bool

func (*RaftCluster) Member

func (c *RaftCluster) Member(id types.ID) *Member

func (*RaftCluster) MemberByName

func (c *RaftCluster) 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 (*RaftCluster) MemberIDs

func (c *RaftCluster) MemberIDs() []types.ID

func (*RaftCluster) Members

func (c *RaftCluster) Members() []*Member

func (*RaftCluster) PeerURLs

func (c *RaftCluster) PeerURLs() []string

PeerURLs returns a list of all peer addresses. The returned list is sorted in ascending lexicographical order.

func (*RaftCluster) Recover

func (c *RaftCluster) Recover(onSet func(*semver.Version))

func (*RaftCluster) RemoveMember

func (c *RaftCluster) RemoveMember(id types.ID)

RemoveMember removes a member from the store. The given id MUST exist, or the function panics.

func (*RaftCluster) SetBackend

func (c *RaftCluster) SetBackend(be backend.Backend)

func (*RaftCluster) SetID

func (c *RaftCluster) SetID(id types.ID)

func (*RaftCluster) SetStore

func (c *RaftCluster) SetStore(st store.Store)

func (*RaftCluster) SetVersion

func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*semver.Version))

func (*RaftCluster) String

func (c *RaftCluster) String() string

func (*RaftCluster) UpdateAttributes

func (c *RaftCluster) UpdateAttributes(id types.ID, attr Attributes)

func (*RaftCluster) UpdateRaftAttributes

func (c *RaftCluster) UpdateRaftAttributes(id types.ID, raftAttr RaftAttributes)

func (*RaftCluster) ValidateConfigurationChange

func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error

ValidateConfigurationChange takes a proposed ConfChange and ensures that it is still valid.

func (*RaftCluster) Version

func (c *RaftCluster) Version() *semver.Version