Back to godoc.org

Package hostcache

v0.0.0 (a69e935)
Latest Go to latest
Published: Oct 1, 2019 | License: Apache-2.0 | Module: github.com/uber/peloton

Index

Package Files

type HostCache

type HostCache interface {
	// AcquireLeases acquires leases on hosts that match the filter constraints.
	AcquireLeases(hostFilter *hostmgr.HostFilter) ([]*hostmgr.HostLease, map[string]uint32)

	// TerminateLease is called when the lease is not going to be used, and we
	// want to release the lock on the host.
	TerminateLease(hostname string, leaseID string) error

	// CompleteLease is called when launching pods on a host that has been
	// previously leased to the Placement engine.
	CompleteLease(hostname string, leaseID string, podToSpecMap map[string]*pbpod.PodSpec) error

	// GetClusterCapacity gets the total capacity and allocation of the cluster.
	GetClusterCapacity() (capacity, allocation hmscalar.Resources)

	// Start will start the goroutine that listens for host events.
	Start()

	// Stop will stop the host cache go routine that listens for host events.
	Stop()

	// GetSummaries returns a list of host summaries that the host cache is
	// managing.
	GetSummaries() (summaries []hostsummary.HostSummary)

	// HandlePodEvent is called by pod events manager on receiving a pod event.
	HandlePodEvent(event *scalar.PodEvent)

	// ResetExpiredHeldHostSummaries resets the status of each hostSummary if
	// the helds have expired and returns the hostnames which got reset.
	ResetExpiredHeldHostSummaries(now time.Time) []string

	// GetHostHeldForPod returns the host that is held for the pod.
	GetHostHeldForPod(podID *peloton.PodID) string

	// HoldForPods holds the host for the pods specified.
	HoldForPods(hostname string, podIDs []*peloton.PodID) error

	// ReleaseHoldForPods release the hold of host for the pods specified.
	ReleaseHoldForPods(hostname string, podIDs []*peloton.PodID) error

	// CompleteLaunchPod is called when a pod is successfully launched.
	// This is for things like removing pods allocated to the pod
	// from available ports. This is called after successful launch
	// of individual pod. We cannot do this in CompleteLease.
	// For example, ports should not be removed after a failed launch,
	// otherwise the ports are leaked.
	CompleteLaunchPod(hostname string, pod *models.LaunchablePod) error

	// RecoverPodInfo updates pods info running on a particular host,
	// it is used only when hostsummary needs to recover the info
	// upon restart
	RecoverPodInfoOnHost(
		id *peloton.PodID,
		hostname string,
		state pbpod.PodState,
		spec *pbpod.PodSpec,
	)

	// AddPodsToHost is a temporary method to add host entries in host cache.
	// It would be removed after CompleteLease is called when launching pod.
	AddPodsToHost(tasks []*hostsvc.LaunchableTask, hostname string)
}

HostCache manages cluster resources, and provides necessary abstractions to interact with underlying system.

func New

func New(
	hostEventCh chan *scalar.HostEvent,
	backgroundMgr background.Manager,
	parent tally.Scope,
) HostCache

New returns a new instance of host cache.

type Metrics

type Metrics struct {
	// Available and Allocated resources in host cache.
	Available scalar.GaugeMaps
	Allocated scalar.GaugeMaps

	// Metrics for number of hosts on each status.
	ReadyHosts     tally.Gauge
	PlacingHosts   tally.Gauge
	HeldHosts      tally.Gauge
	AvailableHosts tally.Gauge
}

Metrics tracks various metrics at offer hostCache level.

func NewMetrics

func NewMetrics(scope tally.Scope) *Metrics

NewMetrics returns a new Metrics struct, with all metrics initialized and rooted at the given tally.Scope

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier