@@ -225,11 +225,21 @@ func (n *Node) SetPeer(pid uint64, addr string) {
225225 n .peers [pid ] = addr
226226}
227227
228- func (n * Node ) Send (m raftpb.Message ) {
229- x .AssertTruef (n .Id != m .To , "Sending message to itself" )
230- data , err := m .Marshal ()
228+ func (n * Node ) Send (msg raftpb.Message ) {
229+ x .AssertTruef (n .Id != msg .To , "Sending message to itself" )
230+ data , err := msg .Marshal ()
231231 x .Check (err )
232232
233+ if glog .V (2 ) {
234+ switch msg .Type {
235+ case raftpb .MsgHeartbeat , raftpb .MsgHeartbeatResp :
236+ case raftpb .MsgReadIndex , raftpb .MsgReadIndexResp :
237+ case raftpb .MsgApp , raftpb .MsgAppResp :
238+ case raftpb .MsgProp :
239+ default :
240+ glog .Infof ("RaftComm: [%#x] Sending message of type %s to %#x" , msg .From , msg .Type , msg .To )
241+ }
242+ }
233243 // As long as leadership is stable, any attempted Propose() calls should be reflected in the
234244 // next raft.Ready.Messages. Leaders will send MsgApps to the followers; followers will send
235245 // MsgProp to the leader. It is up to the transport layer to get those messages to their
@@ -243,7 +253,7 @@ func (n *Node) Send(m raftpb.Message) {
243253 // node. But, we shouldn't take the liberty to do that here. It would take us more time to
244254 // repropose these dropped messages anyway, than to block here a bit waiting for the messages
245255 // channel to clear out.
246- n .messages <- sendmsg {to : m .To , data : data }
256+ n .messages <- sendmsg {to : msg .To , data : data }
247257}
248258
249259func (n * Node ) Snapshot () (raftpb.Snapshot , error ) {
0 commit comments