distance

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// ZeroDistance denotes the same resource.
	ZeroDistance = 0

	// InfiniteDistance denotes inifinite distance.
	InfiniteDistance = ^uint16(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string]*entity

Map parses a yaml config containing a nested entity tree topology, describing distances between resources. A typical entity tree contains a collection of datacenter entities at the top layer, nested with collections of entities depicting racks at the next layer, followed by hosts. However, the number of levels can be arbitrary. See dist_test.go for additional examples.

func New

func New(path string, log bark.Logger) (m Map, err error)

New loads the distance map from the config file.

func (Map) FindDistance

func (m Map) FindDistance(sourceResource, targetResource string) (forwardDistance, reverseDistance uint16, err error)

FindDistance finds the forward and reverse distances.

func (Map) FindResources

func (m Map) FindResources(poolResources, sourceResources []string, targetType string, count int, minDistance, maxDistance uint16) (targetResources []string, err error)

FindResources finds a set of target resources of specified type with distance satisfying [minDistance, maxDistance) from each of the sources as well as between each target.

Jump to

Keyboard shortcuts

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