Skip to content

Commit

Permalink
roachpb: idiomatically name ReplicaType variants
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
tbg committed Aug 26, 2019
1 parent 38b60e6 commit 371e289
Show file tree
Hide file tree
Showing 21 changed files with 283 additions and 278 deletions.
12 changes: 6 additions & 6 deletions c-deps/libroach/protos/roachpb/metadata.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/kv/dist_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func TestSendRPCOrder(t *testing.T) {
if err := g.AddInfoProto(gossip.MakeNodeIDKey(roachpb.NodeID(i)), nd, time.Hour); err != nil {
t.Fatal(err)
}
descriptor.AddReplica(roachpb.NodeID(i), roachpb.StoreID(i), roachpb.ReplicaType_VoterFull)
descriptor.AddReplica(roachpb.NodeID(i), roachpb.StoreID(i), roachpb.VOTER_FULL)
}

// Stub to be changed in each test case.
Expand Down Expand Up @@ -1429,7 +1429,7 @@ func TestSendRPCRangeNotFoundError(t *testing.T) {
t.Fatal(err)
}

descriptor.AddReplica(roachpb.NodeID(i), roachpb.StoreID(i), roachpb.ReplicaType_VoterFull)
descriptor.AddReplica(roachpb.NodeID(i), roachpb.StoreID(i), roachpb.VOTER_FULL)
}
descDB := mockRangeDescriptorDBForDescs(
testMetaRangeDescriptor,
Expand Down
14 changes: 7 additions & 7 deletions pkg/roachpb/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1400,19 +1400,19 @@ func confChangeImpl(

var changeType raftpb.ConfChangeType
switch rDesc.GetType() {
case ReplicaType_VoterFull:
case VOTER_FULL:
// We're adding a new voter.
changeType = raftpb.ConfChangeAddNode
case ReplicaType_VoterIncoming:
case VOTER_INCOMING:
// We're adding a voter, but will transition into a joint config
// first.
changeType = raftpb.ConfChangeAddNode
case ReplicaType_Learner:
case LEARNER:
// We're adding a new learner. Note that we're guaranteed by
// virtue of the upstream ChangeReplicas txn that this learner
// is not currently a voter. If we wanted to support that (i.e.
// demotions) we'd need to introduce a new
// ReplicaType_VoterDemoting for that purpose.
// replica type VOTER_DEMOTING for that purpose.
changeType = raftpb.ConfChangeAddLearnerNode
default:
return nil, errors.Errorf("can't add replica in state %v", rDesc.GetType())
Expand All @@ -1425,13 +1425,13 @@ func confChangeImpl(

for _, rDesc := range removed {
switch rDesc.GetType() {
case ReplicaType_VoterOutgoing:
case VOTER_OUTGOING:
// If a voter is removed through joint consensus, it will
// be turned into an outgoing voter first.
if err := checkExists(rDesc); err != nil {
return nil, err
}
case ReplicaType_VoterFull, ReplicaType_Learner:
case VOTER_FULL, LEARNER:
// A learner or full voter can't be in the desc after.
if err := checkNotExists(rDesc); err != nil {
return nil, err
Expand All @@ -1452,7 +1452,7 @@ func confChangeImpl(
var enteringJoint bool
for _, rDesc := range replicas {
switch rDesc.GetType() {
case ReplicaType_VoterIncoming, ReplicaType_VoterOutgoing:
case VOTER_INCOMING, VOTER_OUTGOING:
enteringJoint = true
default:
}
Expand Down
48 changes: 24 additions & 24 deletions pkg/roachpb/data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/roachpb/data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ enum ReplicaChangeType {
// methods return the replicas being added and removed, respectively. If more than
// one change is specified (i.e. len(Added())+len(Removed()) exceeds one), this
// initiates an atomic replication change in which the "removed" replicas are
// of type ReplicaType_VoterOutgoing. This joint configuration is left via another
// of type VOTER_OUTGOING. This joint configuration is left via another
// ChangeReplicasTrigger which does not specify any additions nor removals.
message ChangeReplicasTrigger {
option (gogoproto.equal) = true;
Expand Down
Loading

0 comments on commit 371e289

Please sign in to comment.