plugins

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: 9 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TaskType    resmgr.TaskType
	UseHostPool bool
}

Config contains strategy plugin configurations.

type Host

type Host interface {
	// Returns the free resources on this host.
	GetAvailableResources() (res scalar.Resources, ports uint64)

	// Returns the mimir group representing the host lease or offer.
	ToMimirGroup() *placement.Group
}

Host is the interface that the host offers or leases must satisfy in order to be used by the placement strategy.

type PlacementNeeds

type PlacementNeeds struct {
	// The minimum available resources for each host.
	Resources scalar.Resources

	// The minimum number of ports that each host needs.
	Ports uint64

	// IsRevocable returns whether or not the host filter is for
	// revocable resources.
	Revocable bool

	// The minimum number of FDs that each host needs.
	FDs uint32

	// The maximum number of hosts required.
	MaxHosts uint32

	// A map from task/pod ID to preferred hostname.
	HostHints map[string]string

	// TODO: Constraint
	Constraint interface{}

	// TODO: RankingHint
	RankHint interface{}
}

PlacementNeeds is the struct that is needed to construct API calls to HostManager to acquire host offers/leases.

func (PlacementNeeds) ToMapKey

func (needs PlacementNeeds) ToMapKey() string

ToMapKey returns a stringified version of the placement needs. It zeroes out HostHints first to make sure

type Strategy

type Strategy interface {
	// GetTaskPlacements takes a list of assignments without any assigned offers and
	// will assign offers to the task in each assignment. This assignment is
	// returned as a map from task index to host index.
	// So for instance: map[int]int{2: 3} means that assignments[2] should
	// be assigned to hosts[3].
	// Tasks that could not be placed should map to an index of -1.
	GetTaskPlacements(tasks []Task, hosts []Host) map[int]int

	// GroupTasksByPlacementNeeds will take a list of assignments and group them into groups that
	// should use the same host filter to acquire offers from the host manager.
	// Returns a list of TasksByPlacementNeedss, which group the tasks that share the same
	// placement needs.
	GroupTasksByPlacementNeeds(tasks []Task) []*TasksByPlacementNeeds

	// ConcurrencySafe returns true iff the strategy is concurrency safe. If
	// the strategy is concurrency safe then it is safe for multiple
	// go-routines to run the GetTaskPlacements method concurrently, else only one
	// go-routine is allowed to run the GetTaskPlacements method at a time.
	ConcurrencySafe() bool
}

Strategy is a placment strategy that will do all the placement logic of assigning tasks to offers.

type Task

type Task interface {
	// Returns the Peloton ID of the task.
	PelotonID() string

	// Tries to fit the task on the host resources passed in as arguments.
	// Returns as last argument whether or not that operation succeeded.
	// Also returns the new resources after this task was fitted onto the host.
	// NOTE: The resources returned are same as the ones passed in if the "fit"
	// failed.
	Fits(resLeft scalar.Resources, portsLeft uint64) (scalar.Resources, uint64, bool)

	// Sets the placement failure reason for this task.
	SetPlacementFailure(string)

	// Returns the mimir entity representing this task.
	// TODO: Remove this, it should definitely not be here.
	ToMimirEntity() *placement.Entity

	// Returns whether or not this task should be spread on hosts, instead of packed.
	// TODO: Remove this, it should definitely not be here.
	NeedsSpread() bool

	// Returns the preferred hostname for this task.
	PreferredHost() string

	// A task inherently has its own PlacementNeeds.
	GetPlacementNeeds() PlacementNeeds

	// Returns the resource manager v0 task.
	// NOTE: This was done to get the host reservation feature working. We
	// should figure out a way to avoid having to do this.
	GetResmgrTaskV0() *resmgr.Task
}

Task is the interface that the Strategy takes in and tries to place on Hosts.

type TasksByPlacementNeeds

type TasksByPlacementNeeds struct {
	PlacementNeeds PlacementNeeds
	Tasks          []int
}

TasksByPlacementNeeds is a group of a list of tasks that have the same PlacementNeeds.

func GroupByPlacementNeeds

func GroupByPlacementNeeds(tasks []Task, config *Config) []*TasksByPlacementNeeds

GroupByPlacementNeeds groups the given tasks into a list of TasksByPlacementNeeds.

Directories

Path Synopsis
lib
Package mimir provides the two main types 'group' and 'entity', and fast algorithms to place the entities on the given groups while satisfying the requirements of the entities.
Package mimir provides the two main types 'group' and 'entity', and fast algorithms to place the entities on the given groups while satisfying the requirements of the entities.
lib/generation
Package generation provides builders to easily build groups, entities and their resource and affinity requirements and placement orderings.
Package generation provides builders to easily build groups, entities and their resource and affinity requirements and placement orderings.
lib/model
Package model contains all the data container types needed to model your physical and logical infrastructure through the concept of a group and all your tasks, processes or containers through the concept of an entity.
Package model contains all the data container types needed to model your physical and logical infrastructure through the concept of a group and all your tasks, processes or containers through the concept of an entity.
v0
v1

Jump to

Keyboard shortcuts

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