package resources
import "k8s.io/kubernetes/contrib/mesos/pkg/scheduler/resources"
Package resources contains the Mesos scheduler specific resource functions
Index ¶
- Constants
- func CanonicalRole(name string) string
- func Filter(res []*mesos.Resource, ps ...ResourcePredicate) []*mesos.Resource
- func ForeachPortsRange(rs []*mesos.Resource, roles []string, f func(begin, end uint64, role string))
- func IsScalar(r *mesos.Resource) bool
- func MatchesAll(res *mesos.Resource, ps ...ResourcePredicate) bool
- func NewPorts(role string, ports ...uint64) *mesos.Resource
- func NewRanges(ports []uint64) *mesos.Value_Ranges
- func PortRanges(Ports []Port) []*mesos.Resource
- func StringPtrTo(s string) *string
- func Sum(res []*mesos.Resource) float64
- type ByRolesSorter
- func ByRoles(roles ...string) *ByRolesSorter
- func (sorter *ByRolesSorter) Sort(resources []*mesos.Resource) []*mesos.Resource
- type CPUShares
- func LimitPodCPU(pod *api.Pod, defaultLimit CPUShares) (request, limit CPUShares, modified bool, err error)
- func LimitedCPUForPod(pod *api.Pod, defaultLimit CPUShares) (request, limit CPUShares, modified bool, err error)
- func NewCPUShares(q resource.Quantity) CPUShares
- func (f CPUShares) Quantity() *resource.Quantity
- func (f *CPUShares) Set(s string) error
- func (f CPUShares) String() string
- func (f CPUShares) Type() string
- type MegaBytes
- func LimitPodMem(pod *api.Pod, defaultLimit MegaBytes) (request, limit MegaBytes, modified bool, err error)
- func LimitedMemForPod(pod *api.Pod, defaultLimit MegaBytes) (request, limit MegaBytes, modified bool, err error)
- func NewMegaBytes(q resource.Quantity) MegaBytes
- func (f MegaBytes) Quantity() *resource.Quantity
- func (f *MegaBytes) Set(s string) error
- func (f MegaBytes) String() string
- func (f MegaBytes) Type() string
- type Port
- type ResourcePredicate
- type ResourcePredicates
Constants ¶
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 )
Functions ¶
func CanonicalRole ¶
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 ¶
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 NewRanges ¶
func NewRanges(ports []uint64) *mesos.Value_Ranges
NewRanges generates port ranges from the given list of ports. (naive implementation)
func PortRanges ¶
PortRanges creates a range resource for the spec ports.
func StringPtrTo ¶
StringPtrTo returns a pointer to the given string or nil if it is empty string.
func Sum ¶
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 (CPUShares) Quantity ¶
func (*CPUShares) Set ¶
func (CPUShares) String ¶
func (CPUShares) Type ¶
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 (MegaBytes) Quantity ¶
func (*MegaBytes) Set ¶
func (MegaBytes) String ¶
func (MegaBytes) Type ¶
type Port ¶
type ResourcePredicate ¶
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.
Source Files ¶
doc.go resource.go resources.go types.go
- Version
- v1.4.1
- Published
- Oct 10, 2016
- Platform
- js/wasm
- Imports
- 6 packages
- Last checked
- 49 minutes ago –
Tools for package owners.