Documentation ¶
Overview ¶
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
- type CPUShares
- type MegaBytes
- 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 )
Variables ¶
This section is empty.
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 MatchesAll ¶
func MatchesAll(res *mesos.Resource, ps ...ResourcePredicate) bool
MatchesAll returns true if the given resource matches all given predicates ps.
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.
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.
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 ¶
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 ¶
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.