simulation

package
Version: v0.0.0-...-4f9c864 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2017 License: Apache-2.0 Imports: 17 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
	// contains filtered or unexported fields
}

Network provides access to a test gossip network of nodes.

func NewNetwork

func NewNetwork(stopper *stop.Stopper, nodeCount int, createResolvers bool) *Network

NewNetwork creates nodeCount gossip nodes.

func (*Network) CreateNode

func (n *Network) CreateNode() (*Node, error)

CreateNode creates a simulation node and starts an RPC server for it.

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

func (n *Network) Start()

Start starts all gossip nodes. TODO(spencer): make all methods in Network return errors instead of fatal logging.

func (*Network) StartNode

func (n *Network) StartNode(node *Node) error

StartNode initializes a gossip instance for the simulation node and starts it.

type Node

type Node struct {
	Gossip   *gossip.Gossip
	Server   *grpc.Server
	Listener net.Listener
	Registry *metric.Registry
}

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

func (*Node) Addr

func (n *Node) Addr() net.Addr

Addr returns the address of the connected listener.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL