models

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: 2 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignPorts

func AssignPorts(
	offer Offer,
	tasks []Task,
) []uint64

AssignPorts selects available ports from the offer and returns them.

func ToPluginTasks

func ToPluginTasks(tasks []Task) []plugins.Task

ToPluginTasks transforms an array of tasks into an array of placement strategy plugin tasks.

Types

type Offer

type Offer interface {
	plugins.Host

	// Returns the ID of the offer (Offer ID or Lease ID)
	ID() string

	// Returns the hostname of the offer.
	Hostname() string

	// Returns the agent ID that this offer is for.
	AgentID() string

	// Returns the available port ranges for this offer.
	AvailablePortRanges() map[*PortRange]struct{}
}

Offer is the interface that represents a Host Offer in v0, or a Host Lease in v1alpha API.

type PortRange

type PortRange struct {
	Begin uint64
	End   uint64
}

PortRange represents a modifiable closed-open port range [Begin:End[ used when assigning ports to tasks.

func NewPortRange

func NewPortRange(begin, end uint64) *PortRange

NewPortRange creates a new modifiable port range from a Mesos value range. Both the begin and end ports are part of the port range.

func (*PortRange) NumPorts

func (portRange *PortRange) NumPorts() uint64

NumPorts returns the number of available ports in the range.

func (*PortRange) TakePorts

func (portRange *PortRange) TakePorts(numPorts uint64) []uint64

TakePorts will take the number of ports from the range or as many as available if more ports are requested than are in the range.

type Task

type Task interface {
	plugins.Task

	// This ID is either the mesos task id or the k8s pod name.
	OrchestrationID() string

	// Returns true if the task is past its placement deadline.
	IsPastDeadline(time.Time) bool

	// Increments the number of placement rounds that we have
	// tried to place this task for.
	IncRounds()

	// IsPastMaxRounds returns true if the task has been through
	// too many placement rounds.
	IsPastMaxRounds() bool

	// Returns true if the task is ready for host reservation.
	IsReadyForHostReservation() bool

	// Returns true if the task should run on revocable resources.
	IsRevocable() bool

	// Sets the matching offer for this task.
	SetPlacement(Offer)

	// Returns the offer that this tasked was matched with.
	GetPlacement() Offer

	// Returns the reason for the placement failure.
	GetPlacementFailure() string
}

Task is the interface that represents a resource manager task. This is meant to wrap around the resource manager protos so we can keep the same logic for v0 and v1alpha API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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