liveness

package
v0.0.0-...-7c6133f Latest Latest
Warning

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

Go to latest
Published: May 30, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package liveness provides a failure detecter (Fd), leader detector (Ld) and heartbeat emitter (HbEm).

The failure detector algorithm is based on the eventually perfect failure detector algorithm described in the Introduction to Reliable and Secure Distributed Programming textbook.

The leader detector algorithm builds on the failure detector algorithm and is based on the monarchical eventual leader detection algorithm also described in the aforementioned textbook.

The heartbeat emitter algorithm emits heartbeats to the other replicas in the system based on a periodic timeout generated by a Ticker.

Index

Constants

View Source
const (
	Suspect fdEvent = false
	Restore fdEvent = true
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Fd

type Fd struct {
	Δ time.Duration
	// contains filtered or unexported fields
}

The state of the failure detector (Fd)

func NewFd

func NewFd(id grp.ID, gm grp.GroupManager, cfg config.Config,
	heartbeatChan <-chan grp.ID, stopCheckIn *sync.WaitGroup) *Fd

Construct a new failure detector

func (*Fd) IsSuspected

func (fd *Fd) IsSuspected(id grp.ID) bool

Is Id suspected

func (*Fd) ResendCurrentSuspected

func (fd *Fd) ResendCurrentSuspected()

Let the current replica know about all currently suspected replicas. Used by the Live Replacement module.

func (*Fd) SetAlive

func (fd *Fd) SetAlive(id grp.ID)

Set a replica to be considered alive by the failure detector

func (*Fd) Start

func (fd *Fd) Start()

Start running the failure detector, spawn a goroutine to handle incoming and outgoing messages.

func (*Fd) Stop

func (fd *Fd) Stop()

Stop the failure detector.

func (*Fd) SubscribeToFdMsgs

func (fd *Fd) SubscribeToFdMsgs(name string) <-chan FdMsg

If a module is interested in receiving Suspect and Restore events, this interest can be registered with this method. A name is needed to uniquely identify the subscription.

type FdMsg

type FdMsg struct {
	Event fdEvent
	ID    grp.ID
}

The type of message sent to other modules who are interested in receiving notifications about possible failures.

There are two types of events, as defined in the eventually perfect failure detector algorithm description: Suspect and Restore.

func (FdMsg) String

func (fdmsg FdMsg) String() string

Return a string representation of an FdMsg.

type HbEm

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

State associated with the heartbeat emitter module.

func NewHbEm

func NewHbEm(cfg config.Config, id grp.ID, rc <-chan bool,
	outB chan<- interface{}, stopCheckIn *sync.WaitGroup) *HbEm

Create a new heartbeat emitter (HbEm).

func (*HbEm) Start

func (hbem *HbEm) Start()

Start the heartbeat emitter, which periodically broadcasts Heartbeat messages onto the network to all replicas.

func (*HbEm) Stop

func (hbem *HbEm) Stop()

Stop the heartbeat emitter.

type Heartbeat

type Heartbeat struct {
	ID grp.ID
}

A Heartbeat message is used by replicas to indicate they are alive in periods when no other messages are sent.

type LeaderDetector

type LeaderDetector interface {
	Start()
	Stop()
	SubscribeToPaxosLdMsgs(name string) <-chan grp.ID
	SubscribeToReplacementLdMsgs(name string) <-chan grp.ID
	PaxosLeader() grp.ID
	ReplacementLeader() grp.ID
}

type MockLD

type MockLD struct{}

func NewMockLD

func NewMockLD() *MockLD

func (*MockLD) PaxosLeader

func (mld *MockLD) PaxosLeader() grp.ID

func (*MockLD) ReplacementLeader

func (mld *MockLD) ReplacementLeader() grp.ID

func (*MockLD) Start

func (mld *MockLD) Start()

func (*MockLD) Stop

func (mld *MockLD) Stop()

func (*MockLD) SubscribeToPaxosLdMsgs

func (mld *MockLD) SubscribeToPaxosLdMsgs(name string) <-chan grp.ID

func (*MockLD) SubscribeToReplacementLdMsgs

func (mld *MockLD) SubscribeToReplacementLdMsgs(name string) <-chan grp.ID

type MonarchicalLD

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

The state of the leader detector (Ld)

func NewMonarchicalLD

func NewMonarchicalLD(gm grp.GroupManager, fd *Fd, stopCheckIn *sync.WaitGroup) *MonarchicalLD

Construct a new leader detector.

func (*MonarchicalLD) PaxosLeader

func (mld *MonarchicalLD) PaxosLeader() grp.ID

Get the id of the replica considered as the Paxos leader.

func (*MonarchicalLD) ReplacementLeader

func (mld *MonarchicalLD) ReplacementLeader() grp.ID

Get the id of the replica considered as the replacement leader.

func (*MonarchicalLD) Start

func (mld *MonarchicalLD) Start()

Initialize the leader detector and spawn a goroutine handling messages. The leader detector subscribes to messages from the failure detector.

func (*MonarchicalLD) Stop

func (mld *MonarchicalLD) Stop()

Stop the leader detector.

func (*MonarchicalLD) SubscribeToPaxosLdMsgs

func (mld *MonarchicalLD) SubscribeToPaxosLdMsgs(name string) <-chan grp.ID

Modules may register interest in receiving notifications when a new leader is elected. A name is needed to uniquely identify the module who is interested. This method returns a channel where information about newly elected leaders can be read from.

func (*MonarchicalLD) SubscribeToReplacementLdMsgs

func (mld *MonarchicalLD) SubscribeToReplacementLdMsgs(name string) <-chan grp.ID

Modules may also register interest in receiving notifications when a new replacement leader is elected. This is used by the Live Replacement module.

type SuspectedRequest

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

Jump to

Keyboard shortcuts

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