etcd: go.etcd.io/etcd/etcdserver/api/membership Index | Files

package membership

import "go.etcd.io/etcd/etcdserver/api/membership"

Package membership describes individual etcd members and clusters of members.

Index

Package Files

cluster.go doc.go errors.go member.go metrics.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 (
    ClusterVersionMetrics = prometheus.NewGaugeVec(prometheus.GaugeOpts{
        Namespace: "etcd",
        Subsystem: "cluster",
        Name:      "version",
        Help:      "Which version is running. 1 for 'cluster_version' label with current cluster version",
    },
        []string{"cluster_version"})
)
var (
    StoreMembersPrefix = path.Join(storePrefix, "members")
)

func MemberAttributesStorePath Uses

func MemberAttributesStorePath(id types.ID) string

func MemberStoreKey Uses

func MemberStoreKey(id types.ID) string

func MustParseMemberIDFromKey Uses

func MustParseMemberIDFromKey(key string) types.ID

func RemovedMemberStoreKey Uses

func RemovedMemberStoreKey(id types.ID) string

func StoreClusterVersionKey Uses

func StoreClusterVersionKey() string

func ValidateClusterAndAssignIDs Uses

func ValidateClusterAndAssignIDs(lg *zap.Logger, 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 Uses

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

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

type Member Uses

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

func NewMember Uses

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 Uses

func (m *Member) Clone() *Member

func (*Member) IsStarted Uses

func (m *Member) IsStarted() bool

func (*Member) PickPeerURL Uses

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 Uses

type MembersByID []*Member

MembersByID implements sort by ID interface

func (MembersByID) Len Uses

func (ms MembersByID) Len() int

func (MembersByID) Less Uses

func (ms MembersByID) Less(i, j int) bool

func (MembersByID) Swap Uses

func (ms MembersByID) Swap(i, j int)

type MembersByPeerURLs Uses

type MembersByPeerURLs []*Member

MembersByPeerURLs implements sort by peer urls interface

func (MembersByPeerURLs) Len Uses

func (ms MembersByPeerURLs) Len() int

func (MembersByPeerURLs) Less Uses

func (ms MembersByPeerURLs) Less(i, j int) bool

func (MembersByPeerURLs) Swap Uses

func (ms MembersByPeerURLs) Swap(i, j int)

type RaftAttributes Uses

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

RaftAttributes represents the raft related attributes of an etcd member.

type RaftCluster Uses

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

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

func NewCluster Uses

func NewCluster(lg *zap.Logger, token string) *RaftCluster

func NewClusterFromMembers Uses

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

func NewClusterFromURLsMap Uses

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

func (*RaftCluster) AddMember Uses

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 Uses

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 Uses

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

func (*RaftCluster) IsIDRemoved Uses

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

func (*RaftCluster) IsReadyToAddNewMember Uses

func (c *RaftCluster) IsReadyToAddNewMember() bool

func (*RaftCluster) IsReadyToRemoveMember Uses

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

func (*RaftCluster) Member Uses

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

func (*RaftCluster) MemberByName Uses

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 Uses

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

func (*RaftCluster) Members Uses

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

func (*RaftCluster) PeerURLs Uses

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 Uses

func (c *RaftCluster) Recover(onSet func(*zap.Logger, *semver.Version))

func (*RaftCluster) RemoveMember Uses

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 Uses

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

func (*RaftCluster) SetID Uses

func (c *RaftCluster) SetID(localID, cid types.ID)

func (*RaftCluster) SetStore Uses

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

func (*RaftCluster) SetVersion Uses

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

func (*RaftCluster) String Uses

func (c *RaftCluster) String() string

func (*RaftCluster) UpdateAttributes Uses

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

func (*RaftCluster) UpdateRaftAttributes Uses

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

func (*RaftCluster) ValidateConfigurationChange Uses

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

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

func (*RaftCluster) Version Uses

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

Package membership imports 25 packages (graph) and is imported by 64 packages. Updated 2018-12-12. Refresh now. Tools for package owners.