resources

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: GPL-3.0 Imports: 3 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapping

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

Mapping representation between the GUIDs and resources combinations. THREAD SAFE, because it is not expected to dynamic mapping of resources.

func NewResourcesMap

func NewResourcesMap(cpuPartitionsPerc []ResourcePartition, ramPartitionsPerc []ResourcePartition) *Mapping

Creates a new resource map given the CPUs and RAM partitions and the respective GUID distributions.

func (*Mapping) FirstGUID

func (rm *Mapping) FirstGUID(resources Resources) *guid.GUID

Returns the first GUID that represents the given resources.

func (*Mapping) HigherRandGUID

func (rm *Mapping) HigherRandGUID(currentGUID guid.GUID, targetResources Resources) (*guid.GUID, error)

Returns a random GUID in the next range of resources. First it tries the GUIDs that represent the SAME cpus and MORE ram. Second it tries the GUIDs that represent the MORE cpus and SAME ram. Lastly it will try the GUIDs that represent the MORE cpus and MORE ram.

func (*Mapping) LowerRandGUID

func (rm *Mapping) LowerRandGUID(currentGUID guid.GUID, targetResources Resources) (*guid.GUID, error)

Returns a random GUID in the previous range of resources. First it tries the GUIDs that represent the SAME cpus and LESS ram. Second it tries the GUIDs that represent the LESS cpus and SAME ram. Lastly it will try the GUIDs that represent the LESS cpus and LESS ram.

func (*Mapping) LowestResources

func (rm *Mapping) LowestResources() *Resources

Obtain the lowest resource combination available.

func (*Mapping) RandGUID

func (rm *Mapping) RandGUID(targetResources Resources) (*guid.GUID, error)

Returns a random GUID in the range of the respective "fittest" target resource combination.

func (*Mapping) ResourcesByGUID

func (rm *Mapping) ResourcesByGUID(resGUID guid.GUID) (*Resources, error)

Returns the resources combination that maps to the given GUID.

func (*Mapping) String

func (rm *Mapping) String() (res string)

Prints the resource map into the log.

type ResourcePartition

type ResourcePartition struct {
	Value      int
	Percentage int
}

Partition of a given resource through a percentage.

func GetCpuCoresPartitions

func GetCpuCoresPartitions(cpuCoresPartitions []configuration.CPUCoresPartition) []ResourcePartition

func GetRamPartitions

func GetRamPartitions(ramPartitions []configuration.RAMPartition) []ResourcePartition

type Resources

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

Representation of the resources that a user can ask for a container to have available.

func NewResources

func NewResources(cpus int, ram int) *Resources

Create a new resource combination object.

func (*Resources) Add

func (r *Resources) Add(resources Resources)

Adds a given combination of resources to the receiver.

func (*Resources) AddCPU

func (r *Resources) AddCPU(cpus int)

Adds a given number of cpus to the resources.

func (*Resources) AddRAM

func (r *Resources) AddRAM(ram int)

Adds a given amount of ram to the resources.

func (*Resources) CPUs

func (r *Resources) CPUs() int

func (*Resources) Contains

func (r *Resources) Contains(contained Resources) bool

Returns true if the given resources are contained inside the receiver.

func (*Resources) Copy

func (r *Resources) Copy() *Resources

Returns a object that is a exact copy of the receiver.

func (*Resources) Equals

func (r *Resources) Equals(resources Resources) bool

Returns true if the given resource combination is equal to the receiver.

func (*Resources) IsValid

func (r *Resources) IsValid() bool

Return true if all resources are greater than 0

func (*Resources) IsZero

func (r *Resources) IsZero() bool

Return true if the resources are zero, false otherwise.

func (*Resources) RAM

func (r *Resources) RAM() int

func (*Resources) SetCPUs

func (r *Resources) SetCPUs(cpu int)

func (*Resources) SetRAM

func (r *Resources) SetRAM(ram int)

func (*Resources) SetTo

func (r *Resources) SetTo(resources Resources)

Set the resources into a specific combination of resources.

func (*Resources) SetZero

func (r *Resources) SetZero()

Set the resources to zero.

func (*Resources) String

func (r *Resources) String() string

Stringify the receiver resources object.

func (*Resources) Sub

func (r *Resources) Sub(resources Resources)

Subtract a given combination of resources to the receiver.

Jump to

Keyboard shortcuts

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