Add ReportUnreachable and ReportSnapshot to MultiNode.

Add ReportSnapshot requirement to doc.go.
release-2.1
Ben Darnell 2015-03-05 12:39:52 -05:00
parent 6b9b695167
commit 725c411346
2 changed files with 28 additions and 1 deletions

View File

@ -35,7 +35,8 @@ previously-persisted entries with Index >= i must be discarded.
2. Send all Messages to the nodes named in the To field. It is important that
no messages be sent until after the latest HardState has been persisted to disk,
and all Entries written by any previous Ready batch (Messages may be sent while
entries from the same batch are being persisted).
entries from the same batch are being persisted). If any Message has type MsgSnap,
call Node.ReportSnapshot() after it has been sent (these messages may be large).
3. Apply Snapshot (if any) and CommittedEntries to the state machine.
If any committed Entry has Type EntryConfChange, call Node.ApplyConfChange()

View File

@ -38,6 +38,10 @@ type MultiNode interface {
Advance(map[uint64]Ready)
// Status returns the current status of the given group.
Status(group uint64) Status
// Report reports the given node is not reachable for the last send.
ReportUnreachable(id, groupID uint64)
// ReportSnapshot reports the stutus of the sent snapshot.
ReportSnapshot(id, groupID uint64, status SnapshotStatus)
// Stop performs any necessary termination of the MultiNode.
Stop()
}
@ -447,3 +451,25 @@ func (mn *multiNode) Status(group uint64) Status {
mn.status <- ms
return <-ms.ch
}
func (mn *multiNode) ReportUnreachable(id, groupID uint64) {
select {
case mn.recvc <- multiMessage{
group: groupID,
msg: pb.Message{Type: pb.MsgUnreachable, From: id},
}:
case <-mn.done:
}
}
func (mn *multiNode) ReportSnapshot(id, groupID uint64, status SnapshotStatus) {
rej := status == SnapshotFailure
select {
case mn.recvc <- multiMessage{
group: groupID,
msg: pb.Message{Type: pb.MsgSnapStatus, From: id, Reject: rej},
}:
case <-mn.done:
}
}