resources

package
v1.4.10-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package resources contains the Mesos scheduler specific resource functions

Index

Constants

View Source
const (
	DefaultDefaultContainerCPULimit = CPUShares(0.25) // CPUs allocated for pods without CPU limit
	DefaultDefaultContainerMemLimit = MegaBytes(64.0) // memory allocated for pods without memory limit
	MinimumContainerCPU             = CPUShares(0.01) // minimum CPUs allowed by Mesos
	MinimumContainerMem             = MegaBytes(32.0) // minimum memory allowed by Mesos
)

Variables

This section is empty.

Functions

func CanonicalRole

func CanonicalRole(name string) string

CanonicalRole returns a "*" if the given role is empty else the role itself

func Filter

func Filter(res []*mesos.Resource, ps ...ResourcePredicate) []*mesos.Resource

Filter filters the given slice of resources and returns a slice of resources matching all given predicates.

func ForeachPortsRange

func ForeachPortsRange(rs []*mesos.Resource, roles []string, f func(begin, end uint64, role string))

ForeachPortsRange calls f for each resource that matches the given roles in the order of the given roles.

func IsScalar

func IsScalar(r *mesos.Resource) bool

IsScalar returns true if the given resource is a scalar type.

func MatchesAll

func MatchesAll(res *mesos.Resource, ps ...ResourcePredicate) bool

MatchesAll returns true if the given resource matches all given predicates ps.

func NewPorts

func NewPorts(role string, ports ...uint64) *mesos.Resource

func NewRanges

func NewRanges(ports []uint64) *mesos.Value_Ranges

NewRanges generates port ranges from the given list of ports. (naive implementation)

func PortRanges

func PortRanges(Ports []Port) []*mesos.Resource

PortRanges creates a range resource for the spec ports.

func StringPtrTo

func StringPtrTo(s string) *string

StringPtrTo returns a pointer to the given string or nil if it is empty string.

func Sum

func Sum(res []*mesos.Resource) float64

Types

type ByRolesSorter

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

ByRolesSorter sorts resources according to the ordering of roles.

func ByRoles

func ByRoles(roles ...string) *ByRolesSorter

ByRoles returns a ByRolesSorter with the given roles.

func (*ByRolesSorter) Sort

func (sorter *ByRolesSorter) Sort(resources []*mesos.Resource) []*mesos.Resource

sort sorts the given resources according to the order of roles in the ByRolesSorter and returns the sorted resources.

type CPUShares

type CPUShares float64

func LimitPodCPU

func LimitPodCPU(pod *api.Pod, defaultLimit CPUShares) (request, limit CPUShares, modified bool, err error)

LimitPodCPU sets default CPU requests and limits of each container that does not limit its CPU resource yet. LimitPodCPU returns the new request, limit and whether the pod was modified.

func LimitedCPUForPod

func LimitedCPUForPod(pod *api.Pod, defaultLimit CPUShares) (request, limit CPUShares, modified bool, err error)

LimitedCPUForPod computes the limits from the spec plus the default CPU limit difference for unlimited containers

func NewCPUShares

func NewCPUShares(q resource.Quantity) CPUShares

func (CPUShares) Quantity

func (f CPUShares) Quantity() *resource.Quantity

func (*CPUShares) Set

func (f *CPUShares) Set(s string) error

func (CPUShares) String

func (f CPUShares) String() string

func (CPUShares) Type

func (f CPUShares) Type() string

type MegaBytes

type MegaBytes float64

func LimitPodMem

func LimitPodMem(pod *api.Pod, defaultLimit MegaBytes) (request, limit MegaBytes, modified bool, err error)

LimitPodMem sets default memory requests and limits of each container that does not limit its memory resource yet. LimitPodMem returns the new request, limit and whether the pod was modified.

func LimitedMemForPod

func LimitedMemForPod(pod *api.Pod, defaultLimit MegaBytes) (request, limit MegaBytes, modified bool, err error)

LimitedMemForPod computes the limits from the spec plus the default memory limit difference for unlimited containers

func NewMegaBytes

func NewMegaBytes(q resource.Quantity) MegaBytes

func (MegaBytes) Quantity

func (f MegaBytes) Quantity() *resource.Quantity

func (*MegaBytes) Set

func (f *MegaBytes) Set(s string) error

func (MegaBytes) String

func (f MegaBytes) String() string

func (MegaBytes) Type

func (f MegaBytes) Type() string

type Port

type Port struct {
	Port uint64
	Role string
}

type ResourcePredicate

type ResourcePredicate func(*mesos.Resource) bool

ResourcePredicate is a predicate function on *mesos.Resource structs.

func HasName

func HasName(name string) ResourcePredicate

HasName returns a ResourcePredicate which returns true if the given resource has the given name.

type ResourcePredicates

type ResourcePredicates []ResourcePredicate

ResourcePredicate is a predicate function on *mesos.Resource structs.

func (ResourcePredicates) Filter

func (ps ResourcePredicates) Filter(res []*mesos.Resource) []*mesos.Resource

Filter filters the given slice of resources and returns a slice of resources matching all given predicates.

func (ResourcePredicates) MatchesAll

func (ps ResourcePredicates) MatchesAll(res *mesos.Resource) bool

MatchesAll returns true if the given resource matches all given predicates ps.

Jump to

Keyboard shortcuts

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