scalar

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 8 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZeroResource = &Resources{
	CPU:    float64(0),
	GPU:    float64(0),
	DISK:   float64(0),
	MEMORY: float64(0),
}

ZeroResource represents the minimum Value of a resource

Functions

This section is empty.

Types

type Allocation

type Allocation struct {
	Value map[AllocationType]*Resources
}

Allocation is the container to track allocation across different dimensions

func GetGangAllocation

func GetGangAllocation(gang *resmgrsvc.Gang) *Allocation

GetGangAllocation returns the allocation across different dimensions of all tasks in a gang

func GetTaskAllocation

func GetTaskAllocation(rmTask *resmgr.Task) *Allocation

GetTaskAllocation returns the allocation across different dimensions of a task

func NewAllocation

func NewAllocation() *Allocation

NewAllocation returns a new Allocation

func (*Allocation) Add

func (a *Allocation) Add(other *Allocation) *Allocation

Add adds one allocation to another

func (*Allocation) GetByType

func (a *Allocation) GetByType(allocationType AllocationType) *Resources

GetByType returns the allocation by type

func (*Allocation) Subtract

func (a *Allocation) Subtract(other *Allocation) *Allocation

Subtract subtracts one allocation to another

type AllocationType

type AllocationType int

AllocationType represents the different allocation dimensions the resource pool can track for admission control

const (
	// NonPreemptibleAllocation tracks allocation for non-preemptible tasks
	NonPreemptibleAllocation AllocationType = iota + 1
	// PreemptibleAllocation tracks allocation for preemptible tasks
	PreemptibleAllocation
	// ControllerAllocation tracks allocation for controller tasks
	ControllerAllocation
	// TotalAllocation tracks the allocation of all tasks(
	// including NonPreemptibleAllocation,PreemptibleAllocation and ControllerAllocation)
	TotalAllocation
	// SlackAllocation track allocation for tasks launched using slack resources.
	SlackAllocation
	// NonSlackAllocation track allocation for non-revocable tasks.
	NonSlackAllocation
)

type Resources

type Resources struct {
	CPU    float64
	MEMORY float64
	DISK   float64
	GPU    float64
}

Resources is a non-thread safe helper struct holding recognized resources.

func ConvertToResmgrResource

func ConvertToResmgrResource(resource *task.ResourceConfig) *Resources

ConvertToResmgrResource converts task resource config to scalar.Resources

func GetGangResources

func GetGangResources(gang *resmgrsvc.Gang) *Resources

GetGangResources aggregates gang resources to resmgr resources

func Min

func Min(r1, r2 *Resources) *Resources

Min Gets the minimum value for each resource type

func (*Resources) Add

func (r *Resources) Add(other *Resources) *Resources

Add atomically add another scalar resources onto current one.

func (*Resources) Clone

func (r *Resources) Clone() *Resources

Clone creates the new new object of the resources and copies the values to the new object and return the new object

func (*Resources) Copy

func (r *Resources) Copy(other *Resources)

Copy copies the values from the passed resource object to the calling object

func (*Resources) Equal

func (r *Resources) Equal(other *Resources) bool

Equal determines current Resources is equal to the other one.

func (*Resources) Get

func (r *Resources) Get(kind string) float64

Get returns the kind of resource

func (*Resources) GetCPU

func (r *Resources) GetCPU() float64

GetCPU returns the CPU resource

func (*Resources) GetDisk

func (r *Resources) GetDisk() float64

GetDisk returns the disk resource

func (*Resources) GetGPU

func (r *Resources) GetGPU() float64

GetGPU returns the GPU resource

func (*Resources) GetMem

func (r *Resources) GetMem() float64

GetMem returns the memory resource

func (*Resources) LessThanOrEqual

func (r *Resources) LessThanOrEqual(other *Resources) bool

LessThanOrEqual determines current Resources is less than or equal the other one.

func (*Resources) Set

func (r *Resources) Set(kind string, value float64)

Set sets the kind of resource with the Value

func (*Resources) String

func (r *Resources) String() string

func (*Resources) Subtract

func (r *Resources) Subtract(other *Resources) *Resources

Subtract another scalar resources from current one and return a new copy of result.

Jump to

Keyboard shortcuts

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