diff --git a/raft/log.go b/raft/log.go index a3bf9a3d3..ccd6122d0 100644 --- a/raft/log.go +++ b/raft/log.go @@ -83,7 +83,7 @@ func (l *raftLog) maybeAppend(index, logTerm, committed uint64, ents ...pb.Entry switch { case ci == 0: case ci <= l.committed: - log.Panicf("conflict(%d) with committed entry [committed(%d)]", ci, l.committed) + log.Panicf("entry %d conflict with committed entry [committed(%d)]", ci, l.committed) default: l.append(ci-1, ents[ci-from:]...) } @@ -95,7 +95,7 @@ func (l *raftLog) maybeAppend(index, logTerm, committed uint64, ents ...pb.Entry func (l *raftLog) append(after uint64, ents ...pb.Entry) uint64 { if after < l.committed { - log.Panicf("after(%d) out of range [committed(%d)]", after, l.committed) + log.Panicf("after(%d) is out of range [committed(%d)]", after, l.committed) } if after < l.unstable { // The log is being truncated to before our current unstable @@ -289,17 +289,3 @@ func (l *raftLog) isOutOfBounds(i uint64) bool { } return false } - -func min(a, b uint64) uint64 { - if a > b { - return b - } - return a -} - -func max(a, b uint64) uint64 { - if a > b { - return a - } - return b -} diff --git a/raft/raft.go b/raft/raft.go index 3597b74fe..f64e14b60 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -100,13 +100,6 @@ func (pr *progress) String() string { return fmt.Sprintf("n=%d m=%d", pr.next, pr.match) } -// uint64Slice implements sort interface -type uint64Slice []uint64 - -func (p uint64Slice) Len() int { return len(p) } -func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] } -func (p uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } - type raft struct { pb.HardState @@ -452,9 +445,7 @@ func (r *raft) handleSnapshot(m pb.Message) { } } -func (r *raft) resetPendingConf() { - r.pendingConf = false -} +func (r *raft) resetPendingConf() { r.pendingConf = false } func (r *raft) addNode(id uint64) { r.setProgress(id, 0, r.raftLog.lastIndex()+1) diff --git a/raft/storage.go b/raft/storage.go index 4d7bd7842..14d3fa3ec 100644 --- a/raft/storage.go +++ b/raft/storage.go @@ -158,7 +158,7 @@ func (ms *MemoryStorage) Compact(i uint64, cs *pb.ConfState, data []byte) error return ErrCompacted } if i > offset+uint64(len(ms.ents))-1 { - log.Panicf("compact %d out of bound lastindex(%d)", i, offset+uint64(len(ms.ents))-1) + log.Panicf("compact %d is out of bound lastindex(%d)", i, offset+uint64(len(ms.ents))-1) } i -= offset ents := make([]pb.Entry, 1, 1+uint64(len(ms.ents))-i) diff --git a/raft/util.go b/raft/util.go index d97707796..95af25f3a 100644 --- a/raft/util.go +++ b/raft/util.go @@ -23,6 +23,27 @@ import ( pb "github.com/coreos/etcd/raft/raftpb" ) +// uint64Slice implements sort interface +type uint64Slice []uint64 + +func (p uint64Slice) Len() int { return len(p) } +func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] } +func (p uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +func min(a, b uint64) uint64 { + if a > b { + return b + } + return a +} + +func max(a, b uint64) uint64 { + if a > b { + return a + } + return b +} + // DescribeMessage returns a concise human-readable description of a // Message for debugging. func DescribeMessage(m pb.Message) string {