discovery

package
v2.0.0-beta.2+incompat... Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2016 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWaitForEndPointsTimeout is returned if we cannot get the endpoints in time
	ErrWaitForEndPointsTimeout = errors.New("timeout waiting for endpoints")
)
View Source
var (
	// LowReplicationLag defines the duration that replication lag is low enough that the VTTablet is considered healthy.
	LowReplicationLag = flag.Duration("discovery_low_replication_lag", 30*time.Second, "the replication lag that is considered low enough to be healthy")
)

Functions

func EndPointToMapKey

func EndPointToMapKey(endPoint *topodatapb.EndPoint) string

EndPointToMapKey creates a key to the map from endpoint's host and ports. It should only be used in discovery and related module.

func WaitForAllEndPoints

func WaitForAllEndPoints(ctx context.Context, hc HealthCheck, ts topo.SrvTopoServer, cell string, types []topodatapb.TabletType) error

WaitForAllEndPoints waits for at least one endpoint in the given cell for all keyspaces / shards before returning.

func WaitForEndPoints

func WaitForEndPoints(ctx context.Context, hc HealthCheck, cell, keyspace, shard string, types []topodatapb.TabletType) error

WaitForEndPoints waits for at least one endpoint in the given cell / keyspace / shard before returning.

Types

type EndPointStats

type EndPointStats struct {
	EndPoint                            *topodatapb.EndPoint
	Name                                string // name is an optional tag (e.g. alternative address)
	Cell                                string
	Target                              *querypb.Target
	Up                                  bool // whether the endpoint is added
	Serving                             bool // whether the server is serving
	TabletExternallyReparentedTimestamp int64
	Stats                               *querypb.RealtimeStats
	LastError                           error
}

EndPointStats is returned when getting the set of endpoints.

func FilterByReplicationLag

func FilterByReplicationLag(epsList []*EndPointStats) []*EndPointStats

FilterByReplicationLag filters the list of EndPointStats by EndPointStats.Stats.SecondsBehindMaster. The algorithm (EndPointStats that is non-serving or has error is ignored): - Return the list if there is 0 or 1 endpoint. - Return the list if all endpoints have <=30s lag. - Filter by replication lag: for each endpoint, if the mean value without it is more than 0.7 of the mean value across all endpoints, it is valid. For example, lags of (5s, 10s, 15s, 120s) return the first three; lags of (30m, 35m, 40m, 45m) return all.

type EndPointStatsList

type EndPointStatsList []*EndPointStats

EndPointStatsList is used for sorting.

func (EndPointStatsList) Len

func (epsl EndPointStatsList) Len() int

Len is part of sort.Interface.

func (EndPointStatsList) Less

func (epsl EndPointStatsList) Less(i, j int) bool

Less is part of sort.Interface

func (EndPointStatsList) Swap

func (epsl EndPointStatsList) Swap(i, j int)

Swap is part of sort.Interface

type EndPointsCacheStatus

type EndPointsCacheStatus struct {
	Cell           string
	Target         *querypb.Target
	EndPointsStats EndPointStatsList
}

EndPointsCacheStatus is the current endpoints for a cell/target. TODO: change this to reflect the e2e information about the endpoints.

func (*EndPointsCacheStatus) StatusAsHTML

func (epcs *EndPointsCacheStatus) StatusAsHTML() template.HTML

StatusAsHTML returns an HTML version of the status.

type EndPointsCacheStatusList

type EndPointsCacheStatusList []*EndPointsCacheStatus

EndPointsCacheStatusList is used for sorting.

func (EndPointsCacheStatusList) Len

func (epcsl EndPointsCacheStatusList) Len() int

Len is part of sort.Interface.

func (EndPointsCacheStatusList) Less

func (epcsl EndPointsCacheStatusList) Less(i, j int) bool

Less is part of sort.Interface

func (EndPointsCacheStatusList) Swap

func (epcsl EndPointsCacheStatusList) Swap(i, j int)

Swap is part of sort.Interface

type HealthCheck

type HealthCheck interface {
	// SetListener sets the listener for healthcheck updates. It should not block.
	SetListener(listener HealthCheckStatsListener)
	// AddEndPoint adds the endpoint, and starts health check.
	AddEndPoint(cell, name string, endPoint *topodatapb.EndPoint)
	// RemoveEndPoint removes the endpoint, and stops the health check.
	RemoveEndPoint(endPoint *topodatapb.EndPoint)
	// GetEndPointStatsFromKeyspaceShard returns all EndPointStats for the given keyspace/shard.
	GetEndPointStatsFromKeyspaceShard(keyspace, shard string) []*EndPointStats
	// GetEndPointStatsFromTarget returns all EndPointStats for the given target.
	GetEndPointStatsFromTarget(keyspace, shard string, tabletType topodatapb.TabletType) []*EndPointStats
	// GetConnection returns the TabletConn of the given endpoint.
	GetConnection(endPoint *topodatapb.EndPoint) tabletconn.TabletConn
	// CacheStatus returns a displayable version of the cache.
	CacheStatus() EndPointsCacheStatusList
	// Close stops the healthcheck.
	Close() error
}

HealthCheck defines the interface of health checking module.

func NewHealthCheck

func NewHealthCheck(connTimeout time.Duration, retryDelay time.Duration, healthCheckTimeout time.Duration, statsSuffix string) HealthCheck

NewHealthCheck creates a new HealthCheck object.

type HealthCheckImpl

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

HealthCheckImpl performs health checking and notifies downstream components about any changes.

func (*HealthCheckImpl) AddEndPoint

func (hc *HealthCheckImpl) AddEndPoint(cell, name string, endPoint *topodatapb.EndPoint)

AddEndPoint adds the endpoint, and starts health check. It does not block on making connection. name is an optional tag for the endpoint, e.g. an alternative address.

func (*HealthCheckImpl) CacheStatus

func (hc *HealthCheckImpl) CacheStatus() EndPointsCacheStatusList

CacheStatus returns a displayable version of the cache.

func (*HealthCheckImpl) Close

func (hc *HealthCheckImpl) Close() error

Close stops the healthcheck.

func (*HealthCheckImpl) GetConnection

func (hc *HealthCheckImpl) GetConnection(endPoint *topodatapb.EndPoint) tabletconn.TabletConn

GetConnection returns the TabletConn of the given endpoint.

func (*HealthCheckImpl) GetEndPointStatsFromKeyspaceShard

func (hc *HealthCheckImpl) GetEndPointStatsFromKeyspaceShard(keyspace, shard string) []*EndPointStats

GetEndPointStatsFromKeyspaceShard returns all EndPointStats for the given keyspace/shard.

func (*HealthCheckImpl) GetEndPointStatsFromTarget

func (hc *HealthCheckImpl) GetEndPointStatsFromTarget(keyspace, shard string, tabletType topodatapb.TabletType) []*EndPointStats

GetEndPointStatsFromTarget returns all EndPointStats for the given target.

func (*HealthCheckImpl) RemoveEndPoint

func (hc *HealthCheckImpl) RemoveEndPoint(endPoint *topodatapb.EndPoint)

RemoveEndPoint removes the endpoint, and stops the health check. It does not block.

func (*HealthCheckImpl) SetListener

func (hc *HealthCheckImpl) SetListener(listener HealthCheckStatsListener)

SetListener sets the listener for healthcheck updates. It should not block.

type HealthCheckStatsListener

type HealthCheckStatsListener interface {
	StatsUpdate(*EndPointStats)
}

HealthCheckStatsListener is the listener to receive health check stats update.

type TopologyWatcher

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

TopologyWatcher pulls endpoints from a configurable set of tablets periodically.

func NewCellTabletsWatcher

func NewCellTabletsWatcher(topoServer topo.Server, hc HealthCheck, cell string, refreshInterval time.Duration, topoReadConcurrency int) *TopologyWatcher

NewCellTabletsWatcher returns a TopologyWatcher that monitors all the tablets in a cell, and starts refreshing.

func NewShardReplicationWatcher

func NewShardReplicationWatcher(topoServer topo.Server, hc HealthCheck, cell, keyspace, shard string, refreshInterval time.Duration, topoReadConcurrency int) *TopologyWatcher

NewShardReplicationWatcher returns a TopologyWatcher that monitors the tablets in a cell/keyspace/shard, and starts refreshing.

func NewTopologyWatcher

func NewTopologyWatcher(topoServer topo.Server, hc HealthCheck, cell string, refreshInterval time.Duration, topoReadConcurrency int, getTablets func(tw *TopologyWatcher) ([]*topodatapb.TabletAlias, error)) *TopologyWatcher

NewTopologyWatcher returns a TopologyWatcher that monitors all the tablets in a cell, and starts refreshing.

func (*TopologyWatcher) Stop

func (tw *TopologyWatcher) Stop()

Stop stops the watcher. It does not clean up the endpoints added to HealthCheck.

Jump to

Keyboard shortcuts

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