queue

package
v0.0.0-...-57dc925 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyQueue is returned from Pop.
	ErrEmptyQueue = errors.New("No pod queued")
	// ErrDifferentNames is returned from Update.
	ErrDifferentNames = errors.New("Original and new pods have different names")
)

Functions

func DefaultComparator

func DefaultComparator(pod0, pod1 *v1.Pod) bool

DefaultComparator returns true if pod0 has higher priority than pod1. If the priorities are equal, it compares the timestamps and returns true if pod0 is older than pod1.

Types

type Compare

type Compare = func(pod0, pod1 *v1.Pod) bool

Compare is a comparator function that returns true if pod0 has higher priority than pod1, or false otherwise.

type ErrNoMatchingPod

type ErrNoMatchingPod struct {
	// contains filtered or unexported fields
}

ErrNoMatchingPod is returned from Update.

func (*ErrNoMatchingPod) Error

func (e *ErrNoMatchingPod) Error() string

type FIFOQueue

type FIFOQueue struct {
	// contains filtered or unexported fields
}

FIFOQueue stores pods in a FIFO queue.

func NewFIFOQueue

func NewFIFOQueue() *FIFOQueue

NewFIFOQueue creates a new FIFOQueue.

func (*FIFOQueue) Delete

func (fifo *FIFOQueue) Delete(podNamespace, podName string) bool

func (*FIFOQueue) Front

func (fifo *FIFOQueue) Front() (*v1.Pod, error)

func (*FIFOQueue) Metrics

func (fifo *FIFOQueue) Metrics() Metrics

func (*FIFOQueue) NominatedPods

func (fifo *FIFOQueue) NominatedPods(nodeName string) []*v1.Pod

NominatedPods does nothing. FIFOQueue doesn't support preemption.

func (*FIFOQueue) Pop

func (fifo *FIFOQueue) Pop() (*v1.Pod, error)

func (*FIFOQueue) Push

func (fifo *FIFOQueue) Push(pod *v1.Pod) error

func (*FIFOQueue) RemoveNominatedNode

func (fifo *FIFOQueue) RemoveNominatedNode(pod *v1.Pod) error

RemoveNominatedNode does nothing. FIFOQueue doesn't support preemption.

func (*FIFOQueue) Update

func (fifo *FIFOQueue) Update(podNamespace, podName string, newPod *v1.Pod) error

func (*FIFOQueue) UpdateNominatedNode

func (fifo *FIFOQueue) UpdateNominatedNode(pod *v1.Pod, nodeName string) error

UpdateNominatedNode does nothing. FIFOQueue doesn't support preemption.

type Metrics

type Metrics struct {
	PendingPodsNum int
}

Metrics represents a metrics of a PodQueue at one time point.

type PodQueue

type PodQueue interface {
	// Push pushes the pod to the "end" of this PodQueue.
	Push(pod *v1.Pod) error

	// Pop pops the pod on the "front" of this PodQueue.
	// This method never blocks; Immediately returns ErrEmptyQueue if the queue is empty.
	Pop() (*v1.Pod, error)

	// Front refers (not pops) the pod on the "front" of this PodQueue.
	// This method never bocks; Immediately returns ErrEmptyQueue if the queue is empty.
	Front() (*v1.Pod, error)

	// Delete deletes the pod from this PodQueue.
	// Returns true if the pod is found, or false otherwise.
	Delete(podNamespace, podName string) bool

	// Update updates the pod to the newPod.
	// Returns ErrNoMatchingPod if an original pod is not found.
	// The original and new pods must have the same namespace/name; Otherwise ErrDifferentNames is
	// returned in the second field.
	Update(podNamespace, podName string, newPod *v1.Pod) error

	// NominatedPods returns a list of pods for which the node is nominated for scheduling.
	NominatedPods(nodeName string) []*v1.Pod

	// UpdateNominatedNode updates the node nomination for the pod.
	UpdateNominatedNode(pod *v1.Pod, nodeName string) error

	// RemoveNominatedNode removes the node nomination for the pod.
	RemoveNominatedNode(pod *v1.Pod) error

	// Metrics returns a metrics of this PodQueue.
	Metrics() Metrics
}

PodQueue defines the interface of pod queues.

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

PriorityQueue stores pods in a priority queue. The pods are sorted by their priority, which can be configured by users.

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

NewPriorityQueue creates a new PriorityQueue with DefaultComparator.

func NewPriorityQueueWithComparator

func NewPriorityQueueWithComparator(comparator Compare) *PriorityQueue

NewPriorityQueueWithComparator creates a new PriorityQueue with the given comparator.

func (*PriorityQueue) Delete

func (pq *PriorityQueue) Delete(podNamespace, podName string) bool

func (*PriorityQueue) Front

func (pq *PriorityQueue) Front() (*v1.Pod, error)

func (*PriorityQueue) Metrics

func (pq *PriorityQueue) Metrics() Metrics

func (*PriorityQueue) NominatedPods

func (pq *PriorityQueue) NominatedPods(nodeName string) []*v1.Pod

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() (*v1.Pod, error)

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(pod *v1.Pod) error

func (*PriorityQueue) RemoveNominatedNode

func (pq *PriorityQueue) RemoveNominatedNode(pod *v1.Pod) error

func (*PriorityQueue) Reorder

func (pq *PriorityQueue) Reorder(comparator Compare) *PriorityQueue

Reorder creates a new PriorityQueue with all pods stored in the original queue in the sorted order according to the given comparator.

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(podNamespace, podName string, newPod *v1.Pod) error

func (*PriorityQueue) UpdateNominatedNode

func (pq *PriorityQueue) UpdateNominatedNode(pod *v1.Pod, nodeName string) error

Jump to

Keyboard shortcuts

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