network

package
v0.0.0-...-ecdf110 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Network

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

Network provides control over all transports of a cluster, injecting disconnections and failures.

func New

func New(logger hclog.Logger) *Network

New create a new network for controlling the underlying transports.

func (*Network) Add

func (n *Network) Add(id raft.ServerID, trans raft.Transport) raft.Transport

Add a new transport to the network. Returns a transport that wraps the given transport with instrumentation to inject disconnections and failures.

func (*Network) Address

func (n *Network) Address(id raft.ServerID) raft.ServerAddress

Address returns the address of the server with the given id.

func (*Network) ConnectAllServers

func (n *Network) ConnectAllServers(id raft.ServerID)

ConnectAllServers establishes full cluster connectivity after an election. The given ID is the one of the leader, which is already connected.

func (*Network) Deposing

func (n *Network) Deposing(id raft.ServerID)

Deposing disables connectivity from the transport of the server with the given ID to all its peers, allowing only append entries RPCs for peers that are lagging behind in terms of applied logs to be performed.

func (*Network) Disconnect

func (n *Network) Disconnect(id, follower raft.ServerID)

Disconnect disables connectivity from the transport of the leader server with the given ID to the peer with the given ID.

func (*Network) Electing

func (n *Network) Electing(id raft.ServerID)

Electing resets any leader-related state in the transport associated with given server ID (such as the track of logs appended by the peers), and it connects the transport to all its peers, enabling it to send them RPCs. It must be called whenever the server associated with this transport is about to transition to the leader state, and before any append entries RPC is made.

func (*Network) HasAppendedLogsFromTo

func (n *Network) HasAppendedLogsFromTo(id1, id2 raft.ServerID) bool

HasAppendedLogsFromTo returns true if at least one log entry has been appended by server with id1 to server with id2.

It is assumed that id1 is a leader that has just been elected and has been trying to append a noop log to all its followers.

func (*Network) PeerConnected

func (n *Network) PeerConnected(id, peer raft.ServerID) bool

PeerConnected returns whether the peer with the given server ID is connected with the transport of the server with the given ID.

func (*Network) Reconnect

func (n *Network) Reconnect(id, follower raft.ServerID)

Reconnect re-enables connectivity from the transport of the leader server with the given ID to the peer with the given ID.

func (*Network) ScheduleAppendFailure

func (n *Network) ScheduleAppendFailure(id raft.ServerID, command uint64) *event.Event

ScheduleAppendFailure will make all followers of the given leader server append the n'th log command sent by the leader, but they will fail to acknowledge the leader about it. Return an event that will fire when all of them have failed and will block them all until acknowledged.

func (*Network) ScheduleEnqueueFailure

func (n *Network) ScheduleEnqueueFailure(id raft.ServerID, command uint64) *event.Event

ScheduleEnqueueFailure will make all followers of the given server fail when the leader tries to append the n'th log command. Return an event that will fire when all of them have failed and will block them all until acknowledged.

Jump to

Keyboard shortcuts

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