models_v0

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: 12 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignmentsToPluginsTasks

func AssignmentsToPluginsTasks(assignments []*Assignment) []plugins.Task

AssignmentsToPluginsTasks converts a slice of assignments into a slice of tasks for plugin use.

func AssignmentsToTasks

func AssignmentsToTasks(assignments []*Assignment) []models.Task

AssignmentsToTasks converts a slice of assignments into a slice of Tasks.

func HostOffersToOffers

func HostOffersToOffers(offers []*HostOffers) []models.Offer

HostOffersToOffers converts a slice of HostOffers into a slice of Offers.

Types

type Assignment

type Assignment struct {
	Task  *TaskV0      `json:"task"`
	Offer models.Offer `json:"host"`

	PlacementFailure string
}

Assignment represents the assignment of a task to a host. One host can be used in multiple assignments.

func NewAssignment

func NewAssignment(task *TaskV0) *Assignment

NewAssignment will create a new empty assignment from a task.

func (*Assignment) Fits

func (a *Assignment) Fits(
	resLeft scalar.Resources,
	portsLeft uint64,
) (scalar.Resources, uint64, bool)

Fits returns true if the given resources fit in the assignment.

func (*Assignment) GetPlacement

func (a *Assignment) GetPlacement() models.Offer

GetPlacement returns the matching offer of this task.

func (*Assignment) GetPlacementFailure

func (a *Assignment) GetPlacementFailure() string

GetPlacementFailure returns the reason why the assignment was unsuccessful

func (*Assignment) GetPlacementNeeds

func (a *Assignment) GetPlacementNeeds() plugins.PlacementNeeds

GetPlacementNeeds returns the placement needs of this task.

func (*Assignment) GetResmgrTaskV0

func (a *Assignment) GetResmgrTaskV0() *resmgr.Task

GetResmgrTaskV0 returns the resource manager task for this assignment.

func (*Assignment) GetTask

func (a *Assignment) GetTask() *TaskV0

GetTask returns the task of the assignment.

func (*Assignment) IncRounds

func (a *Assignment) IncRounds()

IncRounds increments the internal count of placement rounds.

func (*Assignment) IsPastDeadline

func (a *Assignment) IsPastDeadline(now time.Time) bool

IsPastDeadline returns true if the task is past its placement deadline. Additionally, if the task has a preferred host and is past its host placement deadline, it will also return true.

func (*Assignment) IsPastMaxRounds

func (a *Assignment) IsPastMaxRounds() bool

IsPastMaxRounds returns true if the task has been through too many placement rounds.

func (*Assignment) IsReadyForHostReservation

func (a *Assignment) IsReadyForHostReservation() bool

IsReadyForHostReservation returns true if this task is ready for host reservation.

func (*Assignment) IsRevocable

func (a *Assignment) IsRevocable() bool

IsRevocable returns true if the task should run on revocable resources.

func (*Assignment) NeedsSpread

func (a *Assignment) NeedsSpread() bool

NeedsSpread returns whether this task was asked to be spread onto the hosts in its gang.

func (*Assignment) OrchestrationID

func (a *Assignment) OrchestrationID() string

OrchestrationID returns the mesos task ID or pod name.

func (*Assignment) PelotonID

func (a *Assignment) PelotonID() string

PelotonID returns the peloton id of the task that the assignment represents.

func (*Assignment) PreferredHost

func (a *Assignment) PreferredHost() string

PreferredHost returns the host preference for this task.

func (*Assignment) SetPlacement

func (a *Assignment) SetPlacement(offer models.Offer)

SetPlacement sets the matching offer of this task.

func (*Assignment) SetPlacementFailure

func (a *Assignment) SetPlacementFailure(failureReason string)

SetPlacementFailure sets the reason for the failed assignment

func (*Assignment) SetTask

func (a *Assignment) SetTask(task *TaskV0)

SetTask sets the task in the assignment to the given task.

func (*Assignment) ToMimirEntity

func (a *Assignment) ToMimirEntity() *placement.Entity

ToMimirEntity converts the assignment into a mimir entity.

type Host

type Host struct {

	// host info from host manager
	Host *hostsvc.HostInfo `json:"hostinfo"`
	// tasks running on the host.
	Tasks []*resmgr.Task `json:"tasks"`
	// contains filtered or unexported fields
}

Host represents a Peloton hostinfo from hostmanager and the tasks running on it.

func NewHosts

func NewHosts(hostInfo *hostsvc.HostInfo, tasks []*resmgr.Task) *Host

NewHosts will create a placement host from a host manager host and all the resource manager tasks on it.

func (*Host) GetHost

func (h *Host) GetHost() *hostsvc.HostInfo

GetHost returns the host info of the host.

func (*Host) GetTasks

func (h *Host) GetTasks() []*resmgr.Task

GetTasks returns the tasks of the host.

type HostOffers

type HostOffers struct {
	// host offer of the host.
	Offer *hostsvc.HostOffer `json:"offer"`
	// tasks running on the host.
	Tasks []*resmgr.Task `json:"tasks"`
	// Claimed is the time when the host was acquired from the host manager.
	Claimed time.Time `json:"claimed"`
	// contains filtered or unexported fields
}

HostOffers represents a Peloton host and the tasks running on it and a Mimir placement group also be obtained from it.

func NewHostOffers

func NewHostOffers(hostOffer *hostsvc.HostOffer, tasks []*resmgr.Task, claimed time.Time) *HostOffers

NewHostOffers will create a placement host from a host manager host and all the resource manager tasks on it.

func (*HostOffers) Age

func (host *HostOffers) Age(now time.Time) time.Duration

Age will return the age of the host, which is the time since it was dequeued from the host manager.

func (*HostOffers) AgentID

func (host *HostOffers) AgentID() string

AgentID returns the AgentID of this offer.

func (*HostOffers) AvailablePortRanges

func (host *HostOffers) AvailablePortRanges() map[*models.PortRange]struct{}

AvailablePortRanges returns the available port ranges.

func (*HostOffers) Data

func (host *HostOffers) Data() interface{}

Data will return the data transfer object of the host.

func (*HostOffers) GetAvailablePortCount

func (host *HostOffers) GetAvailablePortCount() uint64

GetAvailablePortCount returns the total number of ports available in this host's offers.

func (*HostOffers) GetAvailableResources

func (host *HostOffers) GetAvailableResources() (scalar.Resources, uint64)

GetAvailableResources returns the available resources of this host offer.

func (*HostOffers) GetOffer

func (host *HostOffers) GetOffer() *hostsvc.HostOffer

GetOffer returns the host offer of the host.

func (*HostOffers) GetTasks

func (host *HostOffers) GetTasks() []*resmgr.Task

GetTasks returns the tasks of the host.

func (*HostOffers) Hostname

func (host *HostOffers) Hostname() string

Hostname returns the hostname that this offer belongs to.

func (*HostOffers) ID

func (host *HostOffers) ID() string

ID returns the ID of the offer.

func (*HostOffers) SetData

func (host *HostOffers) SetData(data interface{})

SetData will set the data transfer object on the host.

func (*HostOffers) ToMimirGroup

func (o *HostOffers) ToMimirGroup() *placement.Group

ToMimirGroup converts the HostOffers object into a mimir group.

type TaskV0

type TaskV0 struct {
	Gang *resmgrsvc.Gang `json:"gang"`
	Task *resmgr.Task    `json:"task"`
	// Deadline when the task should successfully placed or have failed to do so.
	Deadline time.Time `json:"deadline"`
	// MaxRounds is the maximal number of successful placement Rounds.
	MaxRounds int `json:"max_rounds"`
	// Rounds is the current number of successful placement Rounds.
	Rounds int `json:"rounds"`
	// PlacementDeadline when the task should successfully placed
	// on the desired host or have failed to do so.
	PlacementDeadline time.Time `json:"placement_deadline"`
	// contains filtered or unexported fields
}

TaskV0 represents a Placement task, a Mimir placement entity can also be obtained from it.

func NewTask

func NewTask(
	gang *resmgrsvc.Gang,
	task *resmgr.Task,
	deadline time.Time,
	placementDeadline time.Time,
	maxRounds int) *TaskV0

NewTask will create a new placement task from a resource manager task, and the gang it belongs to.

func (*TaskV0) Data

func (task *TaskV0) Data() interface{}

Data will return the data transfer object of the task.

func (*TaskV0) GetDeadline

func (task *TaskV0) GetDeadline() time.Time

GetDeadline returns the deadline of the task.

func (*TaskV0) GetGang

func (task *TaskV0) GetGang() *resmgrsvc.Gang

GetGang returns the resource manager gang of the task.

func (*TaskV0) GetMaxRounds

func (task *TaskV0) GetMaxRounds() int

GetMaxRounds returns the max rounds of the task.

func (*TaskV0) GetRounds

func (task *TaskV0) GetRounds() int

GetRounds returns the rounds of the task.

func (*TaskV0) GetTask

func (task *TaskV0) GetTask() *resmgr.Task

GetTask returns the resource manager task of the task.

func (*TaskV0) IncRounds

func (task *TaskV0) IncRounds()

IncRounds will increment the number of placement rounds that the task have been through.

func (*TaskV0) PastDeadline

func (task *TaskV0) PastDeadline(now time.Time) bool

PastDeadline will return true iff the deadline for the gang has passed.

func (*TaskV0) PastDesiredHostPlacementDeadline

func (task *TaskV0) PastDesiredHostPlacementDeadline(now time.Time) bool

PastDesiredHostPlacementDeadline returns true iff the deadline for placing the task onto its desired host has passed.

func (*TaskV0) PastMaxRounds

func (task *TaskV0) PastMaxRounds() bool

PastMaxRounds returns true iff the task has gone through its maximal number of placement rounds.

func (*TaskV0) SetData

func (task *TaskV0) SetData(data interface{})

SetData will set the data transfer object on the task.

func (*TaskV0) SetDeadline

func (task *TaskV0) SetDeadline(deadline time.Time)

SetDeadline sets the deadline of the task.

func (*TaskV0) SetGang

func (task *TaskV0) SetGang(gang *resmgrsvc.Gang)

SetGang sets the resource manager gang of the task.

func (*TaskV0) SetMaxRounds

func (task *TaskV0) SetMaxRounds(maxRounds int)

SetMaxRounds sets the max rounds of the task.

func (*TaskV0) SetRounds

func (task *TaskV0) SetRounds(rounds int)

SetRounds sets the rounds of the task.

func (*TaskV0) SetTask

func (task *TaskV0) SetTask(resmgrTask *resmgr.Task)

SetTask sets the resource manager task of the task.

Jump to

Keyboard shortcuts

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