mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: prune unnecessary logging - fixes #15
This commit is contained in:
parent
f911196e5f
commit
c19932c9ba
@ -121,7 +121,7 @@ func (n *Node) Step(m Message) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if n.ClusterId() != none && m.ClusterId != none && m.ClusterId != n.ClusterId() {
|
if n.ClusterId() != none && m.ClusterId != none && m.ClusterId != n.ClusterId() {
|
||||||
log.Printf("denied a message from node %d, cluster %d. accept cluster: %d\n", m.From, m.ClusterId, n.ClusterId())
|
log.Printf("deny message from=%d cluster=%d", m.From, m.ClusterId)
|
||||||
n.sm.send(Message{To: m.From, ClusterId: n.ClusterId(), Type: msgDenied})
|
n.sm.send(Message{To: m.From, ClusterId: n.ClusterId(), Type: msgDenied})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ func (n *Node) Next() []Entry {
|
|||||||
case AddNode:
|
case AddNode:
|
||||||
c := new(Config)
|
c := new(Config)
|
||||||
if err := json.Unmarshal(ents[i].Data, c); err != nil {
|
if err := json.Unmarshal(ents[i].Data, c); err != nil {
|
||||||
log.Println(err)
|
log.Printf("raft: err=%q", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
n.sm.addNode(c.NodeId)
|
n.sm.addNode(c.NodeId)
|
||||||
@ -180,7 +180,7 @@ func (n *Node) Next() []Entry {
|
|||||||
case RemoveNode:
|
case RemoveNode:
|
||||||
c := new(Config)
|
c := new(Config)
|
||||||
if err := json.Unmarshal(ents[i].Data, c); err != nil {
|
if err := json.Unmarshal(ents[i].Data, c); err != nil {
|
||||||
log.Println(err)
|
log.Printf("raft: err=%q", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
n.sm.removeNode(c.NodeId)
|
n.sm.removeNode(c.NodeId)
|
||||||
|
@ -3,7 +3,6 @@ package raft
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sort"
|
"sort"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
@ -201,7 +200,6 @@ func (sm *stateMachine) send(m Message) {
|
|||||||
m.ClusterId = sm.clusterId
|
m.ClusterId = sm.clusterId
|
||||||
m.From = sm.id
|
m.From = sm.id
|
||||||
m.Term = sm.term.Get()
|
m.Term = sm.term.Get()
|
||||||
log.Printf("raft.send msg %v\n", m)
|
|
||||||
sm.msgs = append(sm.msgs, m)
|
sm.msgs = append(sm.msgs, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,11 +340,6 @@ func (sm *stateMachine) Msgs() []Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sm *stateMachine) Step(m Message) (ok bool) {
|
func (sm *stateMachine) Step(m Message) (ok bool) {
|
||||||
log.Printf("raft.step beforeState %v\n", sm)
|
|
||||||
log.Printf("raft.step beforeLog %v\n", sm.raftLog)
|
|
||||||
defer log.Printf("raft.step afterLog %v\n", sm.raftLog)
|
|
||||||
defer log.Printf("raft.step afterState %v\n", sm)
|
|
||||||
log.Printf("raft.step msg %v\n", m)
|
|
||||||
if m.Type == msgHup {
|
if m.Type == msgHup {
|
||||||
sm.becomeCandidate()
|
sm.becomeCandidate()
|
||||||
if sm.q() == sm.poll(sm.id, true) {
|
if sm.q() == sm.poll(sm.id, true) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user