topology

package
v0.0.0-...-a92cdc1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTaskHeap

func NewTaskHeap() taskHeap

Types

type Container

type Container interface {
	Add(id string, data Data)
	Has(id string) bool
	Find(id string) Data
	Pop(id string) Data
	Transfer(when uint64, id string, data Data, consequence func(time uint64) []event.Event) []event.Event
	SetNetwork(network network.Network)
	SetDatabase(db Database)
}

Container is an interface to model storage for data

type Data

type Data interface {
	Id() string
	Size() uint64
}

type DataCenter

type DataCenter interface {
	Enqueue(rt RunningTask)
	Dequeue(now uint64, calling *Node) []event.Event
	JobCapacity(cost int) int
	JobAvailability(cost int) int
	ExpectedEndings() []uint64
	Host(task RunningTask) (*Node, bool)
	Equal(otherDc DataCenter) bool
	Container() Container
	AddContainer(container Container)
	NumNodes() int
	Nodes() []*Node
	Id() string

	// this function meant for testing
	Get(n int) *Node
}

type Database

type Database interface {
	// Location should return a list of location ids for a file with given id
	Location(fileId string) []string

	// Record will update the database to store that the file with given id can be found at the given location
	Record(fileId, locationId string)
}

Database is an interface to model information about file storage

type FifoDataCenter

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

func (*FifoDataCenter) AddContainer

func (dc *FifoDataCenter) AddContainer(container Container)

func (FifoDataCenter) Container

func (dc FifoDataCenter) Container() Container

func (*FifoDataCenter) Dequeue

func (dc *FifoDataCenter) Dequeue(now uint64, calling *Node) []event.Event

func (*FifoDataCenter) Enqueue

func (dc *FifoDataCenter) Enqueue(rt RunningTask)

func (FifoDataCenter) Equal

func (dc FifoDataCenter) Equal(otherDc DataCenter) bool

Compares two DataCenters. They are equal if they have the same amount of nodes and all nodes have the same free capacity.

func (FifoDataCenter) ExpectedEndings

func (dc FifoDataCenter) ExpectedEndings() []uint64

Returns the expected ending times for all tasks currently hosted in dc.

func (FifoDataCenter) Get

func (dc FifoDataCenter) Get(n int) *Node

Returns a pointer to the corresponding node. This is meant only to be used in tests.

func (*FifoDataCenter) Host

func (dc *FifoDataCenter) Host(task RunningTask) (*Node, bool)

func (FifoDataCenter) Id

func (dc FifoDataCenter) Id() string

func (FifoDataCenter) JobAvailability

func (dc FifoDataCenter) JobAvailability(cost int) (free int)

Returns how many jobs requiring *cost* CPU slots a data center can currently host given available free space.

func (FifoDataCenter) JobCapacity

func (dc FifoDataCenter) JobCapacity(cost int) int

Returns how many jobs requiring *cost* CPU slots a data center can host at most.

func (*FifoDataCenter) Nodes

func (dc *FifoDataCenter) Nodes() []*Node

func (*FifoDataCenter) NumNodes

func (dc *FifoDataCenter) NumNodes() int

type Node

type Node struct {
	Location int
	// contains filtered or unexported fields
}

func NewNode

func NewNode(capacity int, location int) *Node

func (*Node) Free

func (n *Node) Free(cpus int)

func (*Node) Host

func (n *Node) Host(task RunningTask) bool

func (*Node) Process

func (n *Node) Process() []event.Event

func (*Node) QueueLen

func (n *Node) QueueLen() int

func (*Node) Time

func (n *Node) Time() uint64

type RunningTask

type RunningTask interface {
	End() uint64
	Cpus() int
	SetStart(start uint64)
	SetWhere(where int)
	Process() []event.Event
}

type Topology

type Topology struct {
	DataCenters []DataCenter
	Speeds      [][]uint64
}

func LoadFifo

func LoadFifo(topoInfo io.Reader, nw network.Network) (*Topology, error)

func NewFifo

func NewFifo(capacity [][2]int, speeds [][]uint64, nw network.Network) (*Topology, error)

NewFifo creates a new topology using FIFO scheduling in all data centers. capacity holds the number of computers and number of cores in each computer speed holds the bandwidth between datacenters nw is the network that will be used to connect the data centers

func (Topology) Equal

func (topo Topology) Equal(other Topology) bool

Jump to

Keyboard shortcuts

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