drf

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package drf implements Dominant Resource Fairness.

Index

Constants

View Source
const (
	// CPU resource.
	CPU = Typ("CPU")

	// MEMORY resource.
	MEMORY = Typ("MEMORY")
)

Variables

View Source
var (
	// ErrResourceSaturated when there is not enough resource to run next task.
	ErrResourceSaturated = fmt.Errorf("Fatal: resource has been saturated")

	// ErrEmptyResource when cluster resource is empty.
	ErrEmptyResource = fmt.Errorf("Fatal: empty cluster resource")

	// ErrEmptyNodes when cluster nodes is empty.
	ErrEmptyNodes = fmt.Errorf("Fatal: empty cluster nodes")

	// EmptyDRF is empty DRF.
	EmptyDRF = DRF{}
)

Functions

This section is empty.

Types

type DRF

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

DRF represents a DRF Cluster.

func New

func New(clusterResource map[Typ]float64, clusterNodes ...*Node) (DRF, error)

New create a DRF Cluster.

func (DRF) AddNode

func (drf DRF) AddNode(n *Node)

AddNode add new Node to DRF Cluster.

func (DRF) Consumed

func (drf DRF) Consumed() map[Typ]float64

Consumed return all the consumed resource by cluster.

func (DRF) NextTask

func (drf DRF) NextTask() error

NextTask run next task with lowest dominant share.

func (DRF) RemoveNode

func (drf DRF) RemoveNode(n *Node)

RemoveNode remove Node from DRF Cluster.

func (DRF) Resource

func (drf DRF) Resource() map[Typ]float64

Resource return all the cluster resource.

func (DRF) UpdateResource

func (drf DRF) UpdateResource(delta map[Typ]float64)

UpdateResource add delta to Cluster Resource.

type Node

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

Node represents a Cluster Node.

func NewNode

func NewNode(demand ...map[Typ]float64) *Node

NewNode create a Cluster Node.

func (*Node) Allocated

func (n *Node) Allocated() map[Typ]float64

Allocated return all the allocated resource for node.

func (*Node) UpdateDemand

func (n *Node) UpdateDemand(delta map[Typ]float64)

UpdateDemand add delta to existing demand.

type Typ

type Typ string

Typ represents resource type.

Jump to

Keyboard shortcuts

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