Skip to content

Commit

Permalink
etcdserver: rename MemberId() to MemberID() to address var-naming
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Valdes <[email protected]>
  • Loading branch information
ivanvc committed Mar 19, 2024
1 parent c613b78 commit 14523bd
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 126 deletions.
2 changes: 1 addition & 1 deletion server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {

e.cfg.logger.Info(
"now serving peer/client/metrics",
zap.String("local-member-id", e.Server.MemberId().String()),
zap.String("local-member-id", e.Server.MemberID().String()),
zap.Strings("initial-advertise-peer-urls", e.cfg.getAdvertisePeerUrls()),
zap.Strings("listen-peer-urls", e.cfg.getListenPeerUrls()),
zap.Strings("advertise-client-urls", e.cfg.getAdvertiseClientUrls()),
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *serverVersionAdapter) GetDowngradeInfo() *serverversion.DowngradeInfo {
}

func (s *serverVersionAdapter) GetMembersVersions() map[string]*version.Versions {
return getMembersVersions(s.lg, s.cluster, s.MemberId(), s.peerRt, s.Cfg.ReqTimeout())
return getMembersVersions(s.lg, s.cluster, s.MemberID(), s.peerRt, s.Cfg.ReqTimeout())
}

func (s *serverVersionAdapter) GetStorageVersion() *semver.Version {
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/api/v3rpc/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type header struct {
func newHeader(s *etcdserver.EtcdServer) header {
return header{
clusterID: int64(s.Cluster().ID()),
memberID: int64(s.MemberId()),
memberID: int64(s.MemberID()),
sg: s,
rev: func() int64 { return s.KV().Rev() },
}
Expand Down
4 changes: 2 additions & 2 deletions server/etcdserver/api/v3rpc/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
return nil, rpctypes.ErrGRPCNotCapable
}

if s.IsMemberExist(s.MemberId()) && s.IsLearner() && !isRPCSupportedForLearner(req) {
if s.IsMemberExist(s.MemberID()) && s.IsLearner() && !isRPCSupportedForLearner(req) {
return nil, rpctypes.ErrGRPCNotSupportedForLearner
}

Expand Down Expand Up @@ -218,7 +218,7 @@ func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor
return rpctypes.ErrGRPCNotCapable
}

if s.IsMemberExist(s.MemberId()) && s.IsLearner() && info.FullMethod != snapshotMethod { // learner does not support stream RPC except Snapshot
if s.IsMemberExist(s.MemberID()) && s.IsLearner() && info.FullMethod != snapshotMethod { // learner does not support stream RPC except Snapshot
return rpctypes.ErrGRPCNotSupportedForLearner
}

Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/api/v3rpc/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (
}

func (ms *maintenanceServer) MoveLeader(ctx context.Context, tr *pb.MoveLeaderRequest) (*pb.MoveLeaderResponse, error) {
if ms.rg.MemberId() != ms.rg.Leader() {
if ms.rg.MemberID() != ms.rg.Leader() {
return nil, rpctypes.ErrGRPCNotLeader
}

Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/api/v3rpc/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (cs *ClusterServer) MemberPromote(ctx context.Context, r *pb.MemberPromoteR
}

func (cs *ClusterServer) header() *pb.ResponseHeader {
return &pb.ResponseHeader{ClusterId: uint64(cs.cluster.ID()), MemberId: uint64(cs.server.MemberId()), RaftTerm: cs.server.Term()}
return &pb.ResponseHeader{ClusterId: uint64(cs.cluster.ID()), MemberId: uint64(cs.server.MemberID()), RaftTerm: cs.server.Term()}
}

func membersToProtoMembers(membs []*membership.Member) []*pb.Member {
Expand Down
4 changes: 2 additions & 2 deletions server/etcdserver/api/v3rpc/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (qa *quotaAlarmer) check(ctx context.Context, r any) error {
func NewQuotaKVServer(s *etcdserver.EtcdServer) pb.KVServer {
return &quotaKVServer{
NewKVServer(s),
quotaAlarmer{newBackendQuota(s, "kv"), s, s.MemberId()},
quotaAlarmer{newBackendQuota(s, "kv"), s, s.MemberID()},
}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ func (s *quotaLeaseServer) LeaseGrant(ctx context.Context, cr *pb.LeaseGrantRequ
func NewQuotaLeaseServer(s *etcdserver.EtcdServer) pb.LeaseServer {
return &quotaLeaseServer{
NewLeaseServer(s),
quotaAlarmer{newBackendQuota(s, "lease"), s, s.MemberId()},
quotaAlarmer{newBackendQuota(s, "lease"), s, s.MemberID()},
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/api/v3rpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewWatchServer(s *etcdserver.EtcdServer) pb.WatchServer {
lg: s.Cfg.Logger,

clusterID: int64(s.Cluster().ID()),
memberID: int64(s.MemberId()),
memberID: int64(s.MemberID()),

maxRequestBytes: int(s.Cfg.MaxRequestBytes + grpcOverheadBytes),

Expand Down
4 changes: 2 additions & 2 deletions server/etcdserver/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (

// RaftStatusGetter represents etcd server and Raft progress.
type RaftStatusGetter interface {
MemberId() types.ID
MemberID() types.ID
Leader() types.ID
CommittedIndex() uint64
AppliedIndex() uint64
Expand Down Expand Up @@ -484,7 +484,7 @@ func (a *quotaApplierV3) LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantRes
func (a *applierV3backend) newHeader() *pb.ResponseHeader {
return &pb.ResponseHeader{
ClusterId: uint64(a.cluster.ID()),
MemberId: uint64(a.raftStatus.MemberId()),
MemberId: uint64(a.raftStatus.MemberID()),
Revision: a.kv.Rev(),
RaftTerm: a.raftStatus.Term(),
}
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/apply/apply_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func dummyApplyFunc(_ context.Context, _ *pb.InternalRaftRequest) *Result {

type fakeRaftStatusGetter struct{}

func (*fakeRaftStatusGetter) MemberId() types.ID {
func (*fakeRaftStatusGetter) MemberID() types.ID {
return 0
}
func (*fakeRaftStatusGetter) Leader() types.ID {
Expand Down
28 changes: 14 additions & 14 deletions server/etcdserver/corrupt.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type corruptionChecker struct {
type Hasher interface {
mvcc.HashStorage
ReqTimeout() time.Duration
MemberId() types.ID
MemberID() types.ID
PeerHashByRev(int64) []*peerHashKVResp
LinearizableReadNotify(context.Context) error
TriggerCorruptAlarm(types.ID)
Expand Down Expand Up @@ -89,21 +89,21 @@ func (h hasherAdapter) TriggerCorruptAlarm(memberID types.ID) {
func (cm *corruptionChecker) InitialCheck() error {
cm.lg.Info(
"starting initial corruption check",
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
zap.Duration("timeout", cm.hasher.ReqTimeout()),
)

h, _, err := cm.hasher.HashByRev(0)
if err != nil {
return fmt.Errorf("%s failed to fetch hash (%v)", cm.hasher.MemberId(), err)
return fmt.Errorf("%s failed to fetch hash (%v)", cm.hasher.MemberID(), err)
}
peers := cm.hasher.PeerHashByRev(h.Revision)
mismatch := 0
for _, p := range peers {
if p.resp != nil {
peerID := types.ID(p.resp.Header.MemberId)
fields := []zap.Field{
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
zap.Int64("local-member-revision", h.Revision),
zap.Int64("local-member-compact-revision", h.CompactRevision),
zap.Uint32("local-member-hash", h.Hash),
Expand Down Expand Up @@ -131,7 +131,7 @@ func (cm *corruptionChecker) InitialCheck() error {
case rpctypes.ErrFutureRev:
cm.lg.Warn(
"cannot fetch hash from slow remote peer",
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
zap.Int64("local-member-revision", h.Revision),
zap.Int64("local-member-compact-revision", h.CompactRevision),
zap.Uint32("local-member-hash", h.Hash),
Expand All @@ -142,7 +142,7 @@ func (cm *corruptionChecker) InitialCheck() error {
case rpctypes.ErrCompacted:
cm.lg.Warn(
"cannot fetch hash from remote peer; local member is behind",
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
zap.Int64("local-member-revision", h.Revision),
zap.Int64("local-member-compact-revision", h.CompactRevision),
zap.Uint32("local-member-hash", h.Hash),
Expand All @@ -153,7 +153,7 @@ func (cm *corruptionChecker) InitialCheck() error {
case rpctypes.ErrClusterIdMismatch:
cm.lg.Warn(
"cluster ID mismatch",
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
zap.Int64("local-member-revision", h.Revision),
zap.Int64("local-member-compact-revision", h.CompactRevision),
zap.Uint32("local-member-hash", h.Hash),
Expand All @@ -165,12 +165,12 @@ func (cm *corruptionChecker) InitialCheck() error {
}
}
if mismatch > 0 {
return fmt.Errorf("%s found data inconsistency with peers", cm.hasher.MemberId())
return fmt.Errorf("%s found data inconsistency with peers", cm.hasher.MemberID())
}

cm.lg.Info(
"initial corruption checking passed; no corruption",
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
)
return nil
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func (cm *corruptionChecker) PeriodicCheck() error {
zap.Int64("compact-revision-2", h2.CompactRevision),
zap.Uint32("hash-2", h2.Hash),
)
mismatch(cm.hasher.MemberId())
mismatch(cm.hasher.MemberID())
}

checkedCount := 0
Expand Down Expand Up @@ -275,7 +275,7 @@ func (cm *corruptionChecker) PeriodicCheck() error {
// method still passes without raising alarm.
func (cm *corruptionChecker) CompactHashCheck() {
cm.lg.Info("starting compact hash check",
zap.String("local-member-id", cm.hasher.MemberId().String()),
zap.String("local-member-id", cm.hasher.MemberID().String()),
zap.Duration("timeout", cm.hasher.ReqTimeout()),
)
hashes := cm.uncheckedRevisions()
Expand All @@ -300,7 +300,7 @@ func (cm *corruptionChecker) CompactHashCheck() {
// true: successfully checked hash on whole cluster or raised alarms, so no need to check next hash
// false: skipped some members, so need to check next hash
func (cm *corruptionChecker) checkPeerHashes(leaderHash mvcc.KeyValueHash, peers []*peerHashKVResp) bool {
leaderID := cm.hasher.MemberId()
leaderID := cm.hasher.MemberID()
hash2members := map[uint32]types.IDSlice{leaderHash.Hash: {leaderID}}

peersChecked := 0
Expand Down Expand Up @@ -459,7 +459,7 @@ func (s *EtcdServer) getPeerHashKVs(rev int64) []*peerHashKVResp {
members := s.cluster.Members()
peers := make([]peerInfo, 0, len(members))
for _, m := range members {
if m.ID == s.MemberId() {
if m.ID == s.MemberID() {
continue
}
peers = append(peers, peerInfo{id: m.ID, eps: m.PeerURLs})
Expand Down Expand Up @@ -493,7 +493,7 @@ func (s *EtcdServer) getPeerHashKVs(rev int64) []*peerHashKVResp {
}
lg.Warn(
"failed hash kv request",
zap.String("local-member-id", s.MemberId().String()),
zap.String("local-member-id", s.MemberID().String()),
zap.Int64("requested-revision", rev),
zap.String("remote-peer-endpoint", ep),
zap.Error(lastErr),
Expand Down
Loading

0 comments on commit 14523bd

Please sign in to comment.