Browse Source

raft: pendingConf -> configuring

Blake Mizerany 11 years ago
parent
commit
5abdfda06a
2 changed files with 12 additions and 12 deletions
  1. 8 8
      raft2/raft.go
  2. 4 4
      raft2/raft_test.go

+ 8 - 8
raft2/raft.go

@@ -130,7 +130,7 @@ type raft struct {
 	lead int64
 	lead int64
 
 
 	// pending reconfiguration
 	// pending reconfiguration
-	pendingConf bool
+	configuring bool
 
 
 	// promotable indicates whether state machine could be promoted.
 	// promotable indicates whether state machine could be promoted.
 	// New machine has to wait until it has been added to the cluster, or it
 	// New machine has to wait until it has been added to the cluster, or it
@@ -288,7 +288,7 @@ func (r *raft) becomeFollower(term int64, lead int64) {
 	r.reset(term)
 	r.reset(term)
 	r.lead = lead
 	r.lead = lead
 	r.state = stateFollower
 	r.state = stateFollower
-	r.pendingConf = false
+	r.configuring = false
 }
 }
 
 
 func (r *raft) becomeCandidate() {
 func (r *raft) becomeCandidate() {
@@ -312,7 +312,7 @@ func (r *raft) becomeLeader() {
 
 
 	for _, e := range r.raftLog.entries(r.raftLog.committed + 1) {
 	for _, e := range r.raftLog.entries(r.raftLog.committed + 1) {
 		if e.isConfig() {
 		if e.isConfig() {
-			r.pendingConf = true
+			r.configuring = true
 		}
 		}
 	}
 	}
 
 
@@ -380,7 +380,7 @@ func (r *raft) handleSnapshot(m Message) {
 
 
 func (r *raft) addNode(id int64) {
 func (r *raft) addNode(id int64) {
 	r.addIns(id, 0, r.raftLog.lastIndex()+1)
 	r.addIns(id, 0, r.raftLog.lastIndex()+1)
-	r.pendingConf = false
+	r.configuring = false
 	if id == r.id {
 	if id == r.id {
 		r.promotable = true
 		r.promotable = true
 	}
 	}
@@ -388,7 +388,7 @@ func (r *raft) addNode(id int64) {
 
 
 func (r *raft) removeNode(id int64) {
 func (r *raft) removeNode(id int64) {
 	r.deleteIns(id)
 	r.deleteIns(id)
-	r.pendingConf = false
+	r.configuring = false
 }
 }
 
 
 type stepFunc func(r *raft, m Message)
 type stepFunc func(r *raft, m Message)
@@ -403,10 +403,10 @@ func stepLeader(r *raft, m Message) {
 		}
 		}
 		e := m.Entries[0]
 		e := m.Entries[0]
 		if e.isConfig() {
 		if e.isConfig() {
-			if r.pendingConf {
+			if r.configuring {
 				panic("pending conf")
 				panic("pending conf")
 			}
 			}
-			r.pendingConf = true
+			r.configuring = true
 		}
 		}
 		r.appendEntry(e)
 		r.appendEntry(e)
 		r.bcastAppend()
 		r.bcastAppend()
@@ -494,7 +494,7 @@ func (r *raft) restore(s Snapshot) bool {
 			r.addIns(n, 0, r.raftLog.lastIndex()+1)
 			r.addIns(n, 0, r.raftLog.lastIndex()+1)
 		}
 		}
 	}
 	}
-	r.pendingConf = false
+	r.configuring = false
 	return true
 	return true
 }
 }
 
 

+ 4 - 4
raft2/raft_test.go

@@ -621,8 +621,8 @@ func TestConf(t *testing.T) {
 	if sm.raftLog.lastIndex() != 2 {
 	if sm.raftLog.lastIndex() != 2 {
 		t.Errorf("lastindex = %d, want %d", sm.raftLog.lastIndex(), 1)
 		t.Errorf("lastindex = %d, want %d", sm.raftLog.lastIndex(), 1)
 	}
 	}
-	if !sm.pendingConf {
-		t.Errorf("pendingConf = %v, want %v", sm.pendingConf, true)
+	if !sm.configuring {
+		t.Errorf("pendingConf = %v, want %v", sm.configuring, true)
 	}
 	}
 	if sm.raftLog.ents[2].Type != AddNode {
 	if sm.raftLog.ents[2].Type != AddNode {
 		t.Errorf("type = %d, want %d", sm.raftLog.ents[1].Type, AddNode)
 		t.Errorf("type = %d, want %d", sm.raftLog.ents[1].Type, AddNode)
@@ -659,8 +659,8 @@ func TestConfChangeLeader(t *testing.T) {
 		sm.becomeCandidate()
 		sm.becomeCandidate()
 		sm.becomeLeader()
 		sm.becomeLeader()
 
 
-		if sm.pendingConf != tt.wPending {
-			t.Errorf("#%d: pendingConf = %v, want %v", i, sm.pendingConf, tt.wPending)
+		if sm.configuring != tt.wPending {
+			t.Errorf("#%d: pendingConf = %v, want %v", i, sm.configuring, tt.wPending)
 		}
 		}
 	}
 	}
 }
 }