routing

package
v0.0.0-...-06d07da Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

This is a simple example of routing to showcase distributed graph processing in Beehive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallRouting

func InstallRouting(timeout time.Duration)

InstallRouting installs the routing application on bh.DefaultHive. timeout is the duration between each epoc of routing advertisements.

func InstallRoutingOnHive

func InstallRoutingOnHive(h bh.Hive, timeout time.Duration)

InstallRoutingOnHive install the routing application

Types

type Advertisement Path

Advertisement is a single route advertisement.

type Discovery

type Discovery Edge

Discovery is a message emitted when an edge between two nodes is discovered.

type Edge

type Edge struct {
	From Node
	To   Node
}

Edge represents a driected edge between two nodes.

type Edges

type Edges []Edge

Edges is an alias for a slice of edges.

func (Edges) Contains

func (s Edges) Contains(edge Edge) bool

Contains returns whether the edges contain edge.

type Node

type Node struct {
	ID      string // ID of this node.
	Endhost bool   // Whether it is an end-host (important dst for routing).
}

Node represents a vertex in the graph.

func (Node) Key

func (n Node) Key() string

Key returns the beehive key representing this node.

func (Node) String

func (n Node) String() string

type Path

type Path []Node

Path represents a directed path between two nodes.

func (Path) Append

func (p Path) Append(n ...Node) (Path, error)

Append creates a copy of the path, appends n to the path, and returns that copy. It will not directly modify the path. It returns error if the resulting path is an invalid path.

func (Path) Equal

func (p Path) Equal(thatp Path) bool

Equal checks the equality of paths.

func (Path) From

func (p Path) From() (Node, error)

From returns the source node of the path.

func (Path) Len

func (p Path) Len() int

Len returns the length of the path.

func (Path) Prepend

func (p Path) Prepend(n ...Node) (Path, error)

Prepend creates a copy of the path, prepends n to the path, and returns that copy. It will not directly modify the path. It returns error if the resulting path is an invalid path.

func (Path) To

func (p Path) To() (Node, error)

To returns the destination node of the path.

func (Path) Valid

func (p Path) Valid() bool

Valid returns true if the path is a valid path. It checks the length of the path and also detects if the path has a loop.

type PathByLen

type PathByLen []Path

PathByLen is used to sort a []Path based on the length of paths. It implements sort.Interface for []Path.

func (PathByLen) Len

func (r PathByLen) Len() int

func (PathByLen) Less

func (r PathByLen) Less(i, j int) bool

func (PathByLen) Swap

func (r PathByLen) Swap(i, j int)

type Route

type Route struct {
	To      Node
	Paths   []Path // Paths is sorted based on Path.Len().
	Updates []Path // The new routes that may be used for advertisement.
}

Route is a collection of paths towards a desintation node.

func (*Route) AddPath

func (r *Route) AddPath(p Path) error

AddPath adds a path to this route.

func (Route) Contains

func (r Route) Contains(path Path) bool

Contains returns whether route already contains path.

func (Route) IsShortestPath

func (r Route) IsShortestPath(path Path) bool

IsShortestPath returns whether path is a shortest path.

func (Route) KShortestPaths

func (r Route) KShortestPaths(k int) []Path

KShortestPaths returns the k shortest paths in this route. If k is larger than the number of paths we have, we return all the paths.

func (*Route) RemovePath

func (r *Route) RemovePath(p Path) error

RemovePath removes a path from this route.

func (Route) ShortestPaths

func (r Route) ShortestPaths() []Path

ShortestPaths returns all the paths of shortest length in this route.

type Router

type Router struct{}

Router is the main handler of the routing application.

func (Router) Map

func (r Router) Map(msg bh.Msg, ctx bh.MapContext) bh.MappedCells

Rcv maps Discovery based on its destination node and Advertisement messages based on their source node.

func (Router) Rcv

func (r Router) Rcv(msg bh.Msg, ctx bh.RcvContext) error

Rcv handles both Discovery and Advertisement messages.

type RoutingTable

type RoutingTable map[Node]Route

Routing table represents the route for each destination node.

type Timeout

type Timeout struct{}

Timeout is a message emitted when the router should advertise new routes to its neighbors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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