simulation

package
v0.0.0-...-89685a9 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2016 License: Apache-2.0 Imports: 12 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 {
	Nodes   []*Node
	Stopper *stop.Stopper
}

Network provides access to a test gossip network of nodes.

func NewNetwork

func NewNetwork(nodeCount int) *Network

NewNetwork creates nodeCount gossip nodes.

func (*Network) GetNodeFromAddr

func (n *Network) GetNodeFromAddr(addr string) (*Node, bool)

GetNodeFromAddr returns the simulation node associated with provided network address, or nil if there is no such node.

func (*Network) GetNodeFromID

func (n *Network) GetNodeFromID(nodeID roachpb.NodeID) (*Node, bool)

GetNodeFromID returns the simulation node associated with provided node ID, or nil if there is no such node.

func (*Network) InfosReceived

func (n *Network) InfosReceived() int

InfosReceived returns the total count of infos received from all nodes in the network.

func (*Network) InfosSent

func (n *Network) InfosSent() int

InfosSent returns the total count of infos sent from all nodes in the network.

func (*Network) IsNetworkConnected

func (n *Network) IsNetworkConnected() bool

IsNetworkConnected returns true if the network is fully connected with no partitions (i.e. every node knows every other node's network address).

func (*Network) RunUntilFullyConnected

func (n *Network) RunUntilFullyConnected() int

RunUntilFullyConnected blocks until the gossip network has received gossip from every other node in the network. It returns the gossip cycle at which the network became fully connected.

func (*Network) SimulateNetwork

func (n *Network) SimulateNetwork(simCallback func(cycle int, network *Network) bool)

SimulateNetwork runs until the simCallback returns false.

At each cycle, every node gossips a key equal to its address (unique) with the cycle as the value. The received cycle value can be used to determine the aging of information between any two nodes in the network.

At each cycle of the simulation, node 0 gossips the sentinel.

The simulation callback receives the cycle and the network as arguments.

func (*Network) Stop

func (n *Network) Stop()

Stop all servers and gossip nodes.

type Node

type Node struct {
	Gossip *gossip.Gossip
	Server *rpc.Server
	Addr   net.Addr
}

Node represents a node used in a Network. It includes information about the node's gossip instance, network address, and underlying server.

Jump to

Keyboard shortcuts

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