From 6cb7f2d9e9463804dc82447d3bd04eb1314a61b9 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 8 Dec 2014 14:37:39 -0800 Subject: [PATCH] raft: print out log when creating a newraft --- raft/raft.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/raft/raft.go b/raft/raft.go index 8531df47b..d6f019e3f 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -22,6 +22,7 @@ import ( "log" "math/rand" "sort" + "strings" pb "github.com/coreos/etcd/raft/raftpb" ) @@ -165,6 +166,14 @@ func newRaft(id uint64, peers []uint64, election, heartbeat int, storage Storage r.loadState(hs) } r.becomeFollower(r.Term, None) + + nodesStrs := make([]string, 0) + for _, n := range r.nodes() { + nodesStrs = append(nodesStrs, fmt.Sprintf("%x", n)) + } + + fmt.Printf("raft: newRaft %x [peers: [%s], term: %d, commit: %d, lastindex: %d, lastterm: %d]", + r.id, strings.Join(nodesStrs, ","), r.Term, r.raftLog.committed, r.raftLog.lastIndex(), r.raftLog.lastTerm()) return r }