Rename EtcdServer.Id with EtcdServer.MemberId.

It was misleading and error prone vs. ClusterId.
This commit is contained in:
Piotr Tabor
2022-04-03 20:08:30 +02:00
parent f348134edd
commit 651de5a057
17 changed files with 97 additions and 97 deletions

View File

@ -352,7 +352,7 @@ func (c *Cluster) RemoveMember(t testutil.TB, cc *clientv3.Client, id uint64) er
}
newMembers := make([]*Member, 0)
for _, m := range c.Members {
if uint64(m.Server.ID()) != id {
if uint64(m.Server.MemberId()) != id {
newMembers = append(newMembers, m)
} else {
m.Client.Close()
@ -363,7 +363,7 @@ func (c *Cluster) RemoveMember(t testutil.TB, cc *clientv3.Client, id uint64) er
// TODO: remove connection write timeout by selecting on http response closeNotifier
// blocking on https://github.com/golang/go/issues/9524
case <-time.After(time.Second + time.Duration(ElectionTicks)*TickDuration + time.Second + rafthttp.ConnWriteTimeout):
t.Fatalf("failed to remove member %s in time", m.Server.ID())
t.Fatalf("failed to remove member %s in time", m.Server.MemberId())
}
}
}
@ -436,7 +436,7 @@ func (c *Cluster) waitMembersForLeader(ctx context.Context, t testutil.TB, membs
possibleLead := make(map[uint64]bool)
var lead uint64
for _, m := range membs {
possibleLead[uint64(m.Server.ID())] = true
possibleLead[uint64(m.Server.MemberId())] = true
}
cc, err := c.ClusterClient()
if err != nil {
@ -470,7 +470,7 @@ func (c *Cluster) waitMembersForLeader(ctx context.Context, t testutil.TB, membs
}
for i, m := range membs {
if uint64(m.Server.ID()) == lead {
if uint64(m.Server.MemberId()) == lead {
t.Logf("waitMembersForLeader found leader. Member: %v lead: %x", i, lead)
return i
}
@ -841,7 +841,7 @@ func (m *Member) ElectionTimeout() time.Duration {
return time.Duration(m.Server.Cfg.ElectionTicks*int(m.Server.Cfg.TickMs)) * time.Millisecond
}
func (m *Member) ID() types.ID { return m.Server.ID() }
func (m *Member) ID() types.ID { return m.Server.MemberId() }
// NewClientV3 creates a new grpc client connection to the member
func NewClientV3(m *Member) (*clientv3.Client, error) {
@ -1307,18 +1307,18 @@ func (m *Member) Metric(metricName string, expectLabels ...string) (string, erro
// InjectPartition drops connections from m to others, vice versa.
func (m *Member) InjectPartition(t testutil.TB, others ...*Member) {
for _, other := range others {
m.Server.CutPeer(other.Server.ID())
other.Server.CutPeer(m.Server.ID())
t.Logf("network partition injected between: %v <-> %v", m.Server.ID(), other.Server.ID())
m.Server.CutPeer(other.Server.MemberId())
other.Server.CutPeer(m.Server.MemberId())
t.Logf("network partition injected between: %v <-> %v", m.Server.MemberId(), other.Server.MemberId())
}
}
// RecoverPartition recovers connections from m to others, vice versa.
func (m *Member) RecoverPartition(t testutil.TB, others ...*Member) {
for _, other := range others {
m.Server.MendPeer(other.Server.ID())
other.Server.MendPeer(m.Server.ID())
t.Logf("network partition between: %v <-> %v", m.Server.ID(), other.Server.ID())
m.Server.MendPeer(other.Server.MemberId())
other.Server.MendPeer(m.Server.MemberId())
t.Logf("network partition between: %v <-> %v", m.Server.MemberId(), other.Server.MemberId())
}
}