import "github.com/andy2046/gopie/pkg/drf"
Package drf implements Dominant Resource Fairness.
- Constants
- Variables
- type DRF
- func New(clusterResource map[Typ]float64, clusterNodes ...*Node) (DRF, error)
- func (drf DRF) AddNode(n *Node)
- func (drf DRF) Consumed() map[Typ]float64
- func (drf DRF) NextTask() error
- func (drf DRF) RemoveNode(n *Node)
- func (drf DRF) Resource() map[Typ]float64
- func (drf DRF) UpdateResource(delta map[Typ]float64)
- type Node
- type Typ
const (
// CPU resource.
CPU = Typ("CPU")
// MEMORY resource.
MEMORY = Typ("MEMORY")
)
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{}
)
type DRF struct {
// contains filtered or unexported fields
}
DRF represents a DRF Cluster.
func New(clusterResource map[Typ]float64, clusterNodes ...*Node) (DRF, error)
New create a DRF Cluster.
func (drf DRF) AddNode(n *Node)
AddNode add new Node to DRF Cluster.
func (drf DRF) Consumed() map[Typ]float64
Consumed return all the consumed resource by cluster.
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 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 struct {
// contains filtered or unexported fields
}
Node represents a Cluster Node.
func NewNode(demand ...map[Typ]float64) *Node
NewNode create a Cluster Node.
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 string
Typ represents resource type.
Generated by godoc2md