mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

A peer might be removed during a network partiton. When it comes back it will not have received any of the log entries that would have notified it of its removal and go onto propose a vote. This will disrupt the cluster and the cluster should give the machine feedback that it is no longer a member. The term of a denied vote is MaxUint64. The notification of the removal is a raft event. These two modification are quick heck. In reaction to this notification the machine should shutdown. In this case the shutdown just moves it towards becoming a standby server.
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package raft
|
|
|
|
const (
|
|
StateChangeEventType = "stateChange"
|
|
LeaderChangeEventType = "leaderChange"
|
|
TermChangeEventType = "termChange"
|
|
CommitEventType = "commit"
|
|
AddPeerEventType = "addPeer"
|
|
RemovePeerEventType = "removePeer"
|
|
RemovedEventType = "removed"
|
|
|
|
HeartbeatIntervalEventType = "heartbeatInterval"
|
|
ElectionTimeoutThresholdEventType = "electionTimeoutThreshold"
|
|
|
|
HeartbeatEventType = "heartbeat"
|
|
)
|
|
|
|
// Event represents an action that occurred within the Raft library.
|
|
// Listeners can subscribe to event types by using the Server.AddEventListener() function.
|
|
type Event interface {
|
|
Type() string
|
|
Source() interface{}
|
|
Value() interface{}
|
|
PrevValue() interface{}
|
|
}
|
|
|
|
// event is the concrete implementation of the Event interface.
|
|
type event struct {
|
|
typ string
|
|
source interface{}
|
|
value interface{}
|
|
prevValue interface{}
|
|
}
|
|
|
|
// newEvent creates a new event.
|
|
func newEvent(typ string, value interface{}, prevValue interface{}) *event {
|
|
return &event{
|
|
typ: typ,
|
|
value: value,
|
|
prevValue: prevValue,
|
|
}
|
|
}
|
|
|
|
// Type returns the type of event that occurred.
|
|
func (e *event) Type() string {
|
|
return e.typ
|
|
}
|
|
|
|
// Source returns the object that dispatched the event.
|
|
func (e *event) Source() interface{} {
|
|
return e.source
|
|
}
|
|
|
|
// Value returns the current value associated with the event, if applicable.
|
|
func (e *event) Value() interface{} {
|
|
return e.value
|
|
}
|
|
|
|
// PrevValue returns the previous value associated with the event, if applicable.
|
|
func (e *event) PrevValue() interface{} {
|
|
return e.prevValue
|
|
}
|