add some logging
parent
06dea4830d
commit
b796d227f1
|
@ -80,7 +80,7 @@ func Sender(p Peers) func(msgs []raftpb.Message) {
|
|||
// TODO: unknown peer id.. what do we do? I
|
||||
// don't think his should ever happen, need to
|
||||
// look into this further.
|
||||
elog.TODO()
|
||||
log.Println("etcdhttp: no addr for %d", m.To)
|
||||
break
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ func Sender(p Peers) func(msgs []raftpb.Message) {
|
|||
// of messages out at a time.
|
||||
data, err := m.Marshal()
|
||||
if err != nil {
|
||||
elog.TODO()
|
||||
log.Println("etcdhttp: dropping message:", err)
|
||||
break // drop bad message
|
||||
}
|
||||
if httpPost(url, data) {
|
||||
|
@ -177,14 +177,15 @@ func (h Handler) serveKeys(ctx context.Context, w http.ResponseWriter, r *http.R
|
|||
func (h Handler) serveRaft(ctx context.Context, w http.ResponseWriter, r *http.Request) {
|
||||
b, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
elog.TODO()
|
||||
log.Println("etcdhttp: error reading raft message:", err)
|
||||
}
|
||||
var m raftpb.Message
|
||||
if err := m.Unmarshal(b); err != nil {
|
||||
elog.TODO()
|
||||
log.Println("etcdhttp: error unmarshaling raft message:", err)
|
||||
}
|
||||
log.Printf("etcdhttp: raft recv message: %+v", m)
|
||||
if err := h.Server.Node.Step(ctx, m); err != nil {
|
||||
elog.TODO()
|
||||
log.Println("etcdhttp: error stepping raft messages:", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package raft
|
||||
|
||||
import (
|
||||
"code.google.com/p/go.net/context"
|
||||
|
||||
pb "github.com/coreos/etcd/raft/raftpb"
|
||||
)
|
||||
|
||||
|
@ -12,7 +10,7 @@ func saveStateToDisk(st pb.State) {}
|
|||
func saveToDisk(ents []pb.Entry) {}
|
||||
|
||||
func Example_Node() {
|
||||
n := Start(context.Background(), 0, nil)
|
||||
n := Start(0, nil)
|
||||
|
||||
// stuff to n happens in other goroutines
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package raft
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"code.google.com/p/go.net/context"
|
||||
pb "github.com/coreos/etcd/raft/raftpb"
|
||||
|
@ -71,11 +72,13 @@ func (n *Node) run(r *raft) {
|
|||
var prev Ready
|
||||
for {
|
||||
if r.hasLeader() {
|
||||
log.Printf("raft: found leader %#x - unblocking proposals", r.lead)
|
||||
propc = n.propc
|
||||
} else {
|
||||
// We cannot accept proposals because we don't know who
|
||||
// to send them to, so we'll apply back-pressure and
|
||||
// block senders.
|
||||
log.Println("raft: no leader - blocking proposals")
|
||||
propc = nil
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ func TestNode(t *testing.T) {
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
n := Start(ctx, 1, []int64{1})
|
||||
n := Start(1, []int64{1})
|
||||
ch := make(chan Ready)
|
||||
go func() {
|
||||
for {
|
||||
|
|
Loading…
Reference in New Issue