gms

package
v0.0.0-...-25c693f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GIntervalInMillis is the time period for
	// gossiper to gossip
	GIntervalInMillis = 1000
)
View Source
var Version int32 = 0

Version is a unique version number for any state that is generated by the local node

Functions

func GetNextVersion

func GetNextVersion() int32

GetNextVersion get the next version

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) GetState

func (p *ApplicationState) GetState() string

GetState ...

func (*ApplicationState) GetStateVersion

func (p *ApplicationState) GetStateVersion() int

GetStateVersion ...

type ArrivalWindow

type ArrivalWindow struct {
	// contains filtered or unexported fields
}

ArrivalWindow ...

func NewArrivalWindow

func NewArrivalWindow(size int) *ArrivalWindow

NewArrivalWindow ...

func (*ArrivalWindow) Add

func (p *ArrivalWindow) Add(value float64)

Add ...

func (*ArrivalWindow) Clear

func (p *ArrivalWindow) Clear()

Clear ...

func (*ArrivalWindow) Mean

func (p *ArrivalWindow) Mean() float64

Mean ...

func (*ArrivalWindow) P

func (p *ArrivalWindow) P(t float64) float64

P ...

func (*ArrivalWindow) Phi

func (p *ArrivalWindow) Phi(tnow int64) float64

Phi ...

func (*ArrivalWindow) Stdev

func (p *ArrivalWindow) Stdev() float64

Stdev ...

func (*ArrivalWindow) Sum

func (p *ArrivalWindow) Sum() float64

Sum ...

func (*ArrivalWindow) SumOfDeviations

func (p *ArrivalWindow) SumOfDeviations() float64

SumOfDeviations ...

func (*ArrivalWindow) Variance

func (p *ArrivalWindow) Variance() float64

Variance ...

type ByDigest

type ByDigest []*GossipDigest

ByDigest ...

func (ByDigest) Len

func (p ByDigest) Len() int

Len ...

func (ByDigest) Less

func (p ByDigest) Less(i, j int) bool

Less ...

func (ByDigest) Swap

func (p ByDigest) Swap(i, j int)

Swap ...

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 GossipDigestAck2Reply

type GossipDigestAck2Reply struct{}

GossipDigestAck2Reply ...

type GossipDigestAckArgs

type GossipDigestAckArgs struct {
	From      network.EndPoint
	ClusterID string
	GDigest   []*GossipDigest
	// contains filtered or unexported fields
}

GossipDigestAckArgs ...

type GossipDigestAckReply

type GossipDigestAckReply struct{}

GossipDigestAckReply ...

type GossipDigestSynArgs

type GossipDigestSynArgs struct {
	From      network.EndPoint
	ClusterID string
	GDigest   []*GossipDigest
}

GossipDigestSynArgs ...

type GossipDigestSynReply

type GossipDigestSynReply struct{}

GossipDigestSynReply ...

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:

  1. A -> B using GossipDigestSynMessage.
  2. B -> A using GossipDigestAckMessage.
  3. A -> B using GossipDigestAck2Message.

When this module heads from one of the above messages, it will update the FailureDetector with the liveness information.

func GetGossiper

func GetGossiper() *Gossiper

GetGossiper creates a new Gossiper if not exists

func NewGossiper

func NewGossiper() *Gossiper

NewGossiper creates a new Gossiper

func (*Gossiper) AddApplicationState

func (g *Gossiper) AddApplicationState(key string, appState *ApplicationState)

AddApplicationState ...

func (*Gossiper) Convict

func (g *Gossiper) Convict(endpoint network.EndPoint)

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

func (*Gossiper) Start

func (g *Gossiper) Start(generation int)

Start will start gossiper on control port

func (*Gossiper) Suspect

func (g *Gossiper) Suspect(endpoint network.EndPoint)

Suspect implements IFailureDetectionEventListener interface it is invoked by the Failure Detector when it suspects an end point

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL