host

package
v0.0.0-...-d2b1cdf Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAgentInfo

func GetAgentInfo(hostname string) *mesos.AgentInfo

GetAgentInfo return agent info from global map.

func IsHostUp

func IsHostUp(hostname string) bool

IsHostUp returns whether the host is registered as an UP agent

Types

type AgentMap

type AgentMap struct {
	// Registered agent details by id.
	RegisteredAgents map[string]*mesos_master.Response_GetAgents_Agent

	Capacity      scalar.Resources
	SlackCapacity scalar.Resources
}

AgentMap is a placeholder from agent id to agent related information. Note that AgentInfo is immutable as of Mesos 1.3.

func GetAgentMap

func GetAgentMap() *AgentMap

GetAgentMap returns a full map of all registered agents. Note that caller should not mutable the content since it's not protected by any lock.

func (*AgentMap) ReportCapacityMetrics

func (a *AgentMap) ReportCapacityMetrics(scope tally.Scope)

ReportCapacityMetrics into given metric scope.

type Drainer

type Drainer interface {
	Start()
	Stop()
}

Drainer defines the interface for host drainer

func NewDrainer

func NewDrainer(
	drainerPeriod time.Duration,
	masterOperatorClient mpb.MasterOperatorClient,
	maintenanceQueue queue.MaintenanceQueue,
	hostInfoMap MaintenanceHostInfoMap,
) Drainer

NewDrainer creates a new host drainer

type Loader

type Loader struct {
	sync.Mutex
	OperatorClient         mpb.MasterOperatorClient
	MaintenanceHostInfoMap MaintenanceHostInfoMap
	SlackResourceTypes     []string
	Scope                  tally.Scope
}

Loader loads hostmap from Mesos and stores in global singleton.

func (*Loader) Load

func (loader *Loader) Load(_ *uatomic.Bool)

Load hostmap into singleton.

type MaintenanceHostInfoMap

type MaintenanceHostInfoMap interface {
	// GetDrainingHostInfos returns HostInfo of the specified DRAINING hosts.
	// If the hostFilter is empty then HostInfos of all DRAINING hosts is returned.
	GetDrainingHostInfos(hostFilter []string) []*host.HostInfo
	// GetDownHostInfos returns HostInfo of hosts in DOWN state
	// If the hostFilter is empty then HostInfos of all DOWN hosts is returned.
	GetDownHostInfos(hostFilter []string) []*host.HostInfo
	// AddHostInfo adds a HostInfo to the map. AddHostInfo is called when a host
	// transitions to a maintenance states (DRAINING and DRAINED).
	AddHostInfo(hostInfo *host.HostInfo)
	// RemoveHostInfo removes the host's hostInfo from
	// the relevant host state based list of hostInfos
	// RemoveHostInfo is needed to remove entries of hosts from the map when
	// hosts transition from one of the maintenance states to UP state.
	RemoveHostInfo(host string)
	// UpdateHostState updates the HostInfo.HostState of the specified
	// host from 'from' state to 'to' state.
	UpdateHostState(hostname string, from host.HostState, to host.HostState) error
	// ClearAndFillMap clears the content of the
	// map and fills the map with the given host infos
	ClearAndFillMap(hostInfos []*host.HostInfo)
}

MaintenanceHostInfoMap defines an interface of a map of HostInfos of hosts in maintenance TODO: remove this once GetAgents Response has maintenance state of the agents

func NewMaintenanceHostInfoMap

func NewMaintenanceHostInfoMap(scope tally.Scope) MaintenanceHostInfoMap

NewMaintenanceHostInfoMap returns a new MaintenanceHostInfoMap

type Metrics

type Metrics struct {
	DrainingHosts tally.Gauge
	DownHosts     tally.Gauge
	// contains filtered or unexported fields
}

Metrics is placeholder for all metrics in hostmgr/host package.

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

Jump to

Keyboard shortcuts

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