leaderselectionpolicy

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlacklistLeaderPolicy

type BlacklistLeaderPolicy struct {
	Membership *trantorpbtypes.Membership
	Suspected  map[t.NodeID]tt.EpochNr
}

BlacklistLeaderPolicy represents the state of the blacklist leader selection policy.

func BlacklistLeaderPolicyFromBytes

func BlacklistLeaderPolicyFromBytes(data []byte) (*BlacklistLeaderPolicy, error)

func NewBlackListLeaderPolicy

func NewBlackListLeaderPolicy(membership *trantorpbtypes.Membership) *BlacklistLeaderPolicy

func (*BlacklistLeaderPolicy) Bytes

func (l *BlacklistLeaderPolicy) Bytes() ([]byte, error)

func (*BlacklistLeaderPolicy) Leaders

func (l *BlacklistLeaderPolicy) Leaders() []t.NodeID

Leaders returns a list of least recently suspected leaders that cumulatively have a strong quorum of the voting power.

func (*BlacklistLeaderPolicy) Reconfigure

Reconfigure informs the leader selection policy about a change in the membership.

func (*BlacklistLeaderPolicy) Suspect

func (l *BlacklistLeaderPolicy) Suspect(e tt.EpochNr, node t.NodeID)

Suspect adds a new suspect to the list of suspects, or updates its epoch where it was suspected to the given epoch if this one is more recent than the one it already has.

type LeaderPolicyType

type LeaderPolicyType uint64
const (
	Simple LeaderPolicyType = iota
	Blacklist
)

type LeaderSelectionPolicy

type LeaderSelectionPolicy interface {

	// Leaders returns the (ordered) list of leaders based on the given epoch e and on the state of this policy object.
	Leaders() []t.NodeID

	// Suspect updates the state of the policy object by announcing it that node `node` has been suspected in epoch `e`.
	Suspect(e tt.EpochNr, node t.NodeID)

	// Reconfigure returns a new LeaderSelectionPolicy based on the state of the current one,
	// but using a new membership.
	Reconfigure(membership *trantorpbtypes.Membership) LeaderSelectionPolicy

	Bytes() ([]byte, error)
}

A LeaderSelectionPolicy implements the algorithm for selecting a set of leaders in each ISS epoch. In a nutshell, it gathers information about suspected leaders in the past epochs and uses it to calculate the set of leaders for future epochs. Its state can be updated using Suspect() and the leader set for an epoch is queried using Leaders(). A leader set policy must be deterministic, i.e., calling Leaders() after the same sequence of Suspect() invocations always returns the same set of leaders at every Node.

func LeaderPolicyFromBytes

func LeaderPolicyFromBytes(bytes []byte) (LeaderSelectionPolicy, error)

type SimpleLeaderPolicy

type SimpleLeaderPolicy struct {
	Membership []t.NodeID
}

The SimpleLeaderPolicy is a trivial leader selection policy. It must be initialized with a set of node IDs and always returns that full set as leaders, regardless of which nodes have been suspected. In other words, each node is leader each epoch with this policy.

func NewSimpleLeaderPolicy

func NewSimpleLeaderPolicy(membership *trantorpbtypes.Membership) *SimpleLeaderPolicy

func SimpleLeaderPolicyFromBytes

func SimpleLeaderPolicyFromBytes(data []byte) (*SimpleLeaderPolicy, error)

func (*SimpleLeaderPolicy) Bytes

func (simple *SimpleLeaderPolicy) Bytes() ([]byte, error)

func (*SimpleLeaderPolicy) Leaders

func (simple *SimpleLeaderPolicy) Leaders() []t.NodeID

Leaders always returns the whole membership for the SimpleLeaderPolicy. All nodes are always leaders.

func (*SimpleLeaderPolicy) Reconfigure

func (simple *SimpleLeaderPolicy) Reconfigure(membership *trantorpbtypes.Membership) LeaderSelectionPolicy

Reconfigure informs the leader selection policy about a change in the membership.

func (*SimpleLeaderPolicy) Suspect

func (simple *SimpleLeaderPolicy) Suspect(_ tt.EpochNr, _ t.NodeID)

Suspect does nothing for the SimpleLeaderPolicy.

Jump to

Keyboard shortcuts

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