Documentation
¶
Index ¶
- Variables
- func GetNextVersion() int32
- type ApplicationState
- type ArrivalWindow
- func (p *ArrivalWindow) Add(value float64)
- func (p *ArrivalWindow) Clear()
- func (p *ArrivalWindow) Mean() float64
- func (p *ArrivalWindow) P(t float64) float64
- func (p *ArrivalWindow) Phi(tnow int64) float64
- func (p *ArrivalWindow) Stdev() float64
- func (p *ArrivalWindow) Sum() float64
- func (p *ArrivalWindow) SumOfDeviations() float64
- func (p *ArrivalWindow) Variance() float64
- type ByDigest
- type EndPointState
- func (e *EndPointState) AddApplicationState(key string, appState *ApplicationState)
- func (e *EndPointState) GetApplicationState(key string) *ApplicationState
- func (e *EndPointState) GetHeartBeatState() *HeartBeatState
- func (e *EndPointState) IsAlive() bool
- func (e *EndPointState) SetAlive(live bool)
- func (e *EndPointState) SetGossiper(g bool)
- func (e *EndPointState) SetHeartBeatState(hbState *HeartBeatState)
- func (e *EndPointState) UpdateTimestamp()
- type FailureDetector
- type GossipDigest
- type GossipDigestAck2Args
- type GossipDigestAck2Reply
- type GossipDigestAckArgs
- type GossipDigestAckReply
- type GossipDigestSynArgs
- type GossipDigestSynReply
- type Gossiper
- func (g *Gossiper) AddApplicationState(key string, appState *ApplicationState)
- func (g *Gossiper) Convict(endpoint network.EndPoint)
- func (g *Gossiper) GetEndPointStateForEndPoint(ep network.EndPoint) *EndPointState
- func (g *Gossiper) OnGossipDigestAck(args *GossipDigestAckArgs, reply *GossipDigestAckReply) error
- func (g *Gossiper) OnGossipDigestAck2(args *GossipDigestAck2Args, reply *GossipDigestAck2Reply) error
- func (g *Gossiper) OnGossipDigestSyn(args *GossipDigestSynArgs, reply *GossipDigestSynReply) error
- func (g *Gossiper) Register(subscriber IEndPointStateChangeSubscriber)
- func (g *Gossiper) RunTimerTask()
- func (g *Gossiper) Start(generation int)
- func (g *Gossiper) Suspect(endpoint network.EndPoint)
- type HeartBeatState
- type IEndPointStateChangeSubscriber
- type IFailureDetectionEventListener
- type IFailureDetector
Constants ¶
This section is empty.
Variables ¶
var ( // GIntervalInMillis is the time period for // gossiper to gossip GIntervalInMillis = 1000 )
var Version int32 = 0
Version is a unique version number for any state that is generated by the local node
Functions ¶
Types ¶
type ApplicationState ¶
type ApplicationState struct {
// contains filtered or unexported fields
}
ApplicationState is the state associated with a particular node which an application wants to make available to the rest of the nodes in the cluster. Whenever a piece of state needs to be disseminated to the rest of cluster, wrap the state in an instance of ApplicationState and add it to the Gossiper. e.g. if we want to disseminate load information for node A, do the following:
loadState := ApplicationState{<load string>}
gms.GetGossiper().AddAppState("LOAD STATE", loadState)
func NewApplicationState ¶
func NewApplicationState(state string, version int) *ApplicationState
NewApplicationState ...
func NewApplicationStateS ¶
func NewApplicationStateS(state string) *ApplicationState
NewApplicationStateS ...
func (*ApplicationState) GetStateVersion ¶
func (p *ApplicationState) GetStateVersion() int
GetStateVersion ...
type ArrivalWindow ¶
type ArrivalWindow struct {
// contains filtered or unexported fields
}
ArrivalWindow ...
func (*ArrivalWindow) SumOfDeviations ¶
func (p *ArrivalWindow) SumOfDeviations() float64
SumOfDeviations ...
type EndPointState ¶
type EndPointState struct {
// contains filtered or unexported fields
}
EndPointState contains the HeartBeatState and ApplicationState.
func NewEndPointState ¶
func NewEndPointState(hbState *HeartBeatState) *EndPointState
NewEndPointState creates a new endpoint state
func (*EndPointState) AddApplicationState ¶
func (e *EndPointState) AddApplicationState(key string, appState *ApplicationState)
AddApplicationState ...
func (*EndPointState) GetApplicationState ¶
func (e *EndPointState) GetApplicationState(key string) *ApplicationState
GetApplicationState ...
func (*EndPointState) GetHeartBeatState ¶
func (e *EndPointState) GetHeartBeatState() *HeartBeatState
GetHeartBeatState return hbState
func (*EndPointState) IsAlive ¶
func (e *EndPointState) IsAlive() bool
IsAlive return liveiness state of this endpoint.
func (*EndPointState) SetAlive ¶
func (e *EndPointState) SetAlive(live bool)
SetAlive sets liveiness of the endpoint state
func (*EndPointState) SetGossiper ¶
func (e *EndPointState) SetGossiper(g bool)
SetGossiper sets whether it is a gossiper
func (*EndPointState) SetHeartBeatState ¶
func (e *EndPointState) SetHeartBeatState(hbState *HeartBeatState)
SetHeartBeatState ...
func (*EndPointState) UpdateTimestamp ¶
func (e *EndPointState) UpdateTimestamp()
UpdateTimestamp ...
type FailureDetector ¶
type FailureDetector struct {
// contains filtered or unexported fields
}
FailureDetector implements IFailureDetector
func (*FailureDetector) IsAlive ¶
func (f *FailureDetector) IsAlive(ep network.EndPoint) bool
IsAlive check whether the endpoint is up.
func (*FailureDetector) RegisterEventListener ¶
func (f *FailureDetector) RegisterEventListener(listener IFailureDetectionEventListener)
RegisterEventListener registers event listener for fd
func (*FailureDetector) UnregisterEventListener ¶
func (f *FailureDetector) UnregisterEventListener(listener IFailureDetectionEventListener)
UnregisterEventListener ...
type GossipDigest ¶
type GossipDigest struct {
// contains filtered or unexported fields
}
GossipDigest contains information about a specified list of EndPoints and the largest version of the state they have generated as known by the local endpoint.
func NewGossipDigest ¶
func NewGossipDigest(endPoint network.EndPoint, generation, maxVersion int) *GossipDigest
NewGossipDigest creates a new gossip digest
type GossipDigestAck2Args ¶
type GossipDigestAck2Args struct {
From network.EndPoint
ClusterID string
// contains filtered or unexported fields
}
GossipDigestAck2Args ...
type GossipDigestAckArgs ¶
type GossipDigestAckArgs struct {
From network.EndPoint
ClusterID string
GDigest []*GossipDigest
// contains filtered or unexported fields
}
GossipDigestAckArgs ...
type GossipDigestSynArgs ¶
type GossipDigestSynArgs struct {
From network.EndPoint
ClusterID string
GDigest []*GossipDigest
}
GossipDigestSynArgs ...
type Gossiper ¶
type Gossiper struct {
MaxGossipPacketSize int
GossipStage string
JoinVerbHandler string
GossipDigestSynVerb string
GossipDigestAckVerb string
GossipDigestAck2Verb string
// contains filtered or unexported fields
}
Gossiper is responsible for Gossiping information for the local endpoint. It maintains the list of live and dead endpoints. It will periodically (every 1 sec.) chooses a random node and initiates a round of Gossip with it. A round of Gossip involves 3 rounds of messaging: If A wants to initiate a round of Gossip with B:
- A -> B using GossipDigestSynMessage.
- B -> A using GossipDigestAckMessage.
- A -> B using GossipDigestAck2Message.
When this module heads from one of the above messages, it will update the FailureDetector with the liveness information.
func (*Gossiper) AddApplicationState ¶
func (g *Gossiper) AddApplicationState(key string, appState *ApplicationState)
AddApplicationState ...
func (*Gossiper) Convict ¶
Convict implements IFailureDetectionEventListener interface it is invoked by the Failure Detector when it convicts an end point
func (*Gossiper) GetEndPointStateForEndPoint ¶
func (g *Gossiper) GetEndPointStateForEndPoint(ep network.EndPoint) *EndPointState
GetEndPointStateForEndPoint returns state for given endpoint.
func (*Gossiper) OnGossipDigestAck ¶
func (g *Gossiper) OnGossipDigestAck(args *GossipDigestAckArgs, reply *GossipDigestAckReply) error
OnGossipDigestAck is an rpc
func (*Gossiper) OnGossipDigestAck2 ¶
func (g *Gossiper) OnGossipDigestAck2(args *GossipDigestAck2Args, reply *GossipDigestAck2Reply) error
OnGossipDigestAck2 is an rpc
func (*Gossiper) OnGossipDigestSyn ¶
func (g *Gossiper) OnGossipDigestSyn(args *GossipDigestSynArgs, reply *GossipDigestSynReply) error
OnGossipDigestSyn is an rpc
func (*Gossiper) Register ¶
func (g *Gossiper) Register(subscriber IEndPointStateChangeSubscriber)
Register register end point state change subscriber
func (*Gossiper) RunTimerTask ¶
func (g *Gossiper) RunTimerTask()
RunTimerTask starts the periodic task for a gossiper
type HeartBeatState ¶
type HeartBeatState struct {
// contains filtered or unexported fields
}
HeartBeatState associated with any given endpoint.
func NewHeartBeatState ¶
func NewHeartBeatState(generation, heartBeat int) *HeartBeatState
NewHeartBeatState creates a new hbState with given generation and hearBeat. verison defaults to 0.
func (*HeartBeatState) GetHeartBeat ¶
func (h *HeartBeatState) GetHeartBeat() int32
GetHeartBeat returns heartbeat
func (*HeartBeatState) GetVersion ¶
func (h *HeartBeatState) GetVersion() int32
GetVersion returns version
func (*HeartBeatState) UpdateHeartBeat ¶
func (h *HeartBeatState) UpdateHeartBeat()
UpdateHeartBeat increments generation and atomically increments version
type IEndPointStateChangeSubscriber ¶
type IEndPointStateChangeSubscriber interface {
OnChange(endpoint network.EndPoint, epState *EndPointState)
}
IEndPointStateChangeSubscriber provides an interface for endpoint state change subscribers
type IFailureDetectionEventListener ¶
type IFailureDetectionEventListener interface {
// convict the specified endpoint
Convict(ep network.EndPoint)
// suspect the specified endpoint
Suspect(ep network.EndPoint)
}
IFailureDetectionEventListener provides an interface for fd event listener
type IFailureDetector ¶
type IFailureDetector interface {
IsAlive(ep network.EndPoint) bool
RegisterEventListener(listener IFailureDetectionEventListener)
UnregisterEventListener(listener IFailureDetectionEventListener)
// contains filtered or unexported methods
}
IFailureDetector provides an interface that can query liveness information of a node in the cluster.
func GetFailureDetector ¶
func GetFailureDetector() IFailureDetector
GetFailureDetector will create a new instance of FailureDetector if not exists