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: 79

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterMesosResources

func FilterMesosResources(rs []*mesos.Resource, filter func(*mesos.Resource) bool) (
	matched []*mesos.Resource, unmatched []*mesos.Resource)

FilterMesosResources separates Mesos resources slice into matched and unmatched ones.

func FilterRevocableMesosResources

func FilterRevocableMesosResources(rs []*mesos.Resource) (
	revocable []*mesos.Resource, nonRevocable []*mesos.Resource)

FilterRevocableMesosResources separates revocable resources and non-revocable resources

func FromOfferToMesosResources

func FromOfferToMesosResources(offer *mesos.Offer) []*mesos.Resource

FromOfferToMesosResources returns list of resources from a single offer

func FromOffersMapToMesosResources

func FromOffersMapToMesosResources(offerMap map[string]*mesos.Offer) []*mesos.Resource

FromOffersMapToMesosResources returns list of resources from a offerMap

func HasResourceType

func HasResourceType(agentRes, reqRes Resources, resourceType string) bool

HasResourceType validates requested resource type is present agent resource type.

func ToPelotonResources

func ToPelotonResources(rs Resources) *peloton.Resources

ToPelotonResources creates a new instance of `peloton.Resources` from `Resources`

Types

type AtomicResources

type AtomicResources struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

AtomicResources is a wrapper around `Resources` provide thread safety.

func (*AtomicResources) Get

func (a *AtomicResources) Get() Resources

Get returns a copy of current value.

func (*AtomicResources) Set

func (a *AtomicResources) Set(r Resources)

Set sets value to r.

type Resources

type Resources struct {
	CPU  float64
	Mem  float64
	Disk float64
	GPU  float64
}

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

func FromMesosResource

func FromMesosResource(resource *mesos.Resource) (r Resources)

FromMesosResource returns the scalar Resources from a single Mesos resource object.

func FromMesosResources

func FromMesosResources(resources []*mesos.Resource) (r Resources)

FromMesosResources returns the scalar Resources from a list of Mesos resource objects.

func FromOffer

func FromOffer(offer *mesos.Offer) Resources

FromOffer returns the scalar Resources from an offer.

func FromOfferMap

func FromOfferMap(offerMap map[string]*mesos.Offer) (r Resources)

FromOfferMap returns the scalar Resources from given id to offer map.

func FromOffers

func FromOffers(offers []*mesos.Offer) (r Resources)

FromOffers returns the scalar Resources from given offers

func FromPelotonResources

func FromPelotonResources(rp *peloton.Resources) (r Resources)

FromResourceSpec creates a new instance of `Resources` from `peloton.Resources`

func FromPodSpec

func FromPodSpec(podspec *pbpod.PodSpec) (r Resources)

FromPodSpec creates a new instance of `Resources` from a `PodSpec`

func FromResourceConfig

func FromResourceConfig(rc *task.ResourceConfig) (r Resources)

FromResourceConfig creates a new instance of `Resources` from a `ResourceConfig`.

func FromResourceSpec

func FromResourceSpec(rc *pbpod.ResourceSpec) (r Resources)

FromResourceSpec creates a new instance of `Resources` from a `ResourceSpec`

func Minimum

func Minimum(r1, r2 Resources) (m Resources)

Minimum returns minimum amount of resources in each type.

func (Resources) Add

func (r Resources) Add(other Resources) Resources

Add atomically add another scalar resources onto current one.

func (Resources) Compare

func (r Resources) Compare(other Resources, cmpLess bool) bool

Compare method compares current Resources with the other one, return true if current Resources is strictly larger than or equal to / less than the other one (based on boolean cmpLess), false if not. Fields in the other one are ignore if they are 0.

func (Resources) Contains

func (r Resources) Contains(other Resources) bool

Contains determines whether current Resources is large enough to contain the other one.

func (Resources) Empty

func (r Resources) Empty() bool

Empty returns whether all fields are empty now.

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) HasGPU

func (r Resources) HasGPU() bool

HasGPU is a special condition to ensure exclusive protection for GPU.

func (Resources) NonEmptyFields

func (r Resources) NonEmptyFields() []string

NonEmptyFields returns corresponding Mesos resource names for fields which are not empty.

func (Resources) String

func (r Resources) String() string

String returns a formatted string for scalar resources

func (Resources) Subtract

func (r Resources) Subtract(other Resources) Resources

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

func (Resources) TrySubtract

func (r Resources) TrySubtract(other Resources) (Resources, bool)

TrySubtract attempts to subtract another scalar resources from current one , but returns false if other has more resources.

Jump to

Keyboard shortcuts

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