machine

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package machine keeps track of machines and applications for scotty.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByHostAndName

func ByHostAndName(list []*Endpoint)

ByHostAndName sorts list by the hostname and then by application name in ascending order.

Types

type Endpoint

type Endpoint struct {
	M   *Machine
	App *application.Application
}

Endpoint represents an endpoint, a single application running on a single machine.

func (*Endpoint) Active

func (e *Endpoint) Active() bool

Active is a convenience routine that returns true iff this endpoint is active. For an endpoint to be active, both the application and the machine it is running on must be active.

type EndpointObservation

type EndpointObservation struct {
	// The observation number that increases by 1 each time
	SeqNo uint64

	// The name of each appliation and the port it is running on.
	Endpoints namesandports.NamesAndPorts
}

EndpointObservation represents an observation of applications and ports running on a certain machine.

type EndpointObservations

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

EndpointObservations stores endpoint observations for all machines. EndpointObservations is safe to use with multiple goroutines.

func NewEndpointObservations

func NewEndpointObservations() *EndpointObservations

NewEndpointObservations returns an empty EndpointObservations

func (*EndpointObservations) GetAll

GetAll returns a snapshot of all the endpoint observations.

func (*EndpointObservations) MaybeAddApp

func (e *EndpointObservations) MaybeAddApp(hostName, appName string, port uint)

MaybeAddApp atomically adds an application for hostName if its port isn't there already without incrementing the sequence number. If nothing has been previously stored for hostName, MaybeAddApp adds appName and sets the sequence number to 1. IsTLS for added app is false for now.

func (*EndpointObservations) Save

func (e *EndpointObservations) Save(
	hostName string, namesAndPorts namesandports.NamesAndPorts)

Save saves namesAndPorts for hostName and increments the sequence number by 1.

type EndpointStore

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

EndpointStore stores all the endpoints for scotty along with a store that stores the metrics for each endpoint.

func NewEndpointStore

func NewEndpointStore(
	astore *store.Store,
	config awsinfo.Config,
	countToInactivate int) *EndpointStore

NewEndpointStore returns a new EndpointStore. astore is a prototype of the store object for storing metrics. The caller should not hold onto the astore reference after passing it to NewEndpointStore. config contains information for understanding AWS information. countToInactive is how many times an application must be reported as missing before it is marked inactive.

func (*EndpointStore) AllActiveWithStore

func (e *EndpointStore) AllActiveWithStore() ([]*Endpoint, *store.Store)

AllActiveWithStore returns all active endpoints along with the metric store

func (*EndpointStore) AllWithStore

func (e *EndpointStore) AllWithStore() (
	result []*Endpoint, astore *store.Store)

AllWithStore returns all endpoints along with the metric store

func (*EndpointStore) ByHostAndName

func (e *EndpointStore) ByHostAndName(host, name string) (
	*Endpoint, *store.Store)

ByHostAndName returns the endpoint for given host name and application name along with the current metric store. If the host name application name combination doesn't exist, ByHostAndName returns nil for the endpoint.

func (*EndpointStore) LogChangedMetricCount

func (e *EndpointStore) LogChangedMetricCount(
	ep *scotty.Endpoint, metricCount uint)

LogChangedMetricCount logs the number of changed metrics for given / endpoint.

func (*EndpointStore) ReportError

func (e *EndpointStore) ReportError(
	ep *scotty.Endpoint, err error, ts time.Time)

ReportError reports an error for given endpoint.

func (*EndpointStore) Store

func (e *EndpointStore) Store() *store.Store

Store returns the current metric store

func (*EndpointStore) UpdateEndpoints

func (e *EndpointStore) UpdateEndpoints(
	timestamp float64, endpoints map[string]EndpointObservation)

UpdateEndpints tells this instance of all the applications running on al the hosts. endpoints are all the applications running keyed by hostname. If the sequence number for a given host hasn't changed since the last call to UpdateEndpoints, then UpdateEndpoints() becomes a no-op for that hostname.

func (*EndpointStore) UpdateMachines

func (e *EndpointStore) UpdateMachines(
	timestamp float64,
	activeHosts []mdb.Machine)

UpdateMachines updates the available machines.

func (*EndpointStore) UpdateState

func (e *EndpointStore) UpdateState(
	ep *scotty.Endpoint, newState *scotty.State)

UpdateState updates the state of the given endpoint.

type Machine

type Machine struct {

	// The host name of the machine
	Host string

	// The region of the machine
	Region string

	// The IP address of the machine
	IpAddress string

	// Whether or not machine is active
	Active bool

	// Aws information for machine. nil if no aws information available.
	Aws *awsinfo.AwsInfo
}

Machine represents a single machine

func (*Machine) AccountId

func (m *Machine) AccountId() string

AccountId is a convenience routine that returns the aws account id. If no aws information, returns the empty string.

func (*Machine) CloudHealth

func (m *Machine) CloudHealth() bool

CloudHealth is a convenience routine that returns true if scotty should write cloud health data for machine.

func (*Machine) CloudWatchStr

func (m *Machine) CloudWatchStr() string

CloudWatchStr is a convenience routine that returns how often scotty should write to cloud watch for the machine as a string (e.g "5m"). Returns the empty string if no aws information is available or if no data should be written to cloud watch.

func (*Machine) InstanceId

func (m *Machine) InstanceId() string

AccountId is a convenience routine that returns the aws instance id. If no aws information, returns the empty string.

Jump to

Keyboard shortcuts

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