balancer

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ItemTypeHost  = "host"
	ItemTypeGuest = "guest"
)
View Source
const (
	EventActionFindResultFail = "find_result_fail"
	EventActionMigrating      = "migrating"
	EventActionMigrateSuccess = "migrate_success"
	EventActionMigrateFail    = "migrate_fail"
	EventActionMigrateError   = "migrate_error"
)

Variables

This section is empty.

Functions

func DoBalance

func DoBalance(ctx context.Context, s *mcclient.ClientSession, rules *Rules, recorder IRecorder) error

func GetAlertSettingThreshold

func GetAlertSettingThreshold(s *api.AlertSetting) (float64, error)

func NewMigrateNote

func NewMigrateNote(pair *resultPair, err error) (*models.MigrateNote, error)

func RecoverInProcessAlerts

func RecoverInProcessAlerts(ctx context.Context, s *mcclient.ClientSession) error

Types

type EventAction

type EventAction string

type HostMetric

type HostMetric struct {
	Id     string
	Values map[string]float64
}

type HostMetrics

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

func InfluxdbQuery

func InfluxdbQuery(
	ds *tsdb.DataSource,
	idKey string,
	hosts []IResource,
	query *TsdbQuery) (*HostMetrics, error)

func NewHostMetrics

func NewHostMetrics(ms []*HostMetric) *HostMetrics

func (HostMetrics) Get

func (hs HostMetrics) Get(id string) *HostMetric

func (HostMetrics) JSONString

func (hs HostMetrics) JSONString() string

type HostResource

type HostResource struct {
	IResource
	// contains filtered or unexported fields
}

func (*HostResource) GetHostResource

func (h *HostResource) GetHostResource() *HostResource

type ICandidate

type ICandidate interface {
	IResource
	GetHostName() string
	GetScore() float64
}

type ICondition

type ICondition interface {
	GetThreshold() float64
	// GetSourceThresholdDelta must > 0
	GetSourceThresholdDelta(threshold float64, srcHost IHost) float64
	IsFitTarget(settings *monitor.MigrationAlertSettings, t ITarget, c ICandidate) error
}

type IHost

type IHost interface {
	IResource
	GetHostResource() *HostResource
	GetCurrent() float64
	SetCurrent(float64) IHost
	Compare(oh IHost) bool
}

type IMetricDriver

type IMetricDriver interface {
	GetType() monitor.MigrationAlertMetricType
	GetTsdbQuery() *TsdbQuery
	GetCandidate(gst jsonutils.JSONObject, host IHost, ds *tsdb.DataSource) (ICandidate, error)
	SetHostCurrent(h IHost, values map[string]float64) error
	GetTarget(host jsonutils.JSONObject) (ITarget, error)
	GetCondition(s *monitor.AlertSetting) (ICondition, error)
}

type IRecorder

type IRecorder interface {
	Record(userCred mcclient.TokenCredential, alert *models.SMigrationAlert, notes interface{}, act EventAction)
	RecordError(userCred mcclient.TokenCredential, alert *models.SMigrationAlert, err error, act EventAction)

	RecordMigrate(ctx context.Context, s *mcclient.ClientSession, alert *models.SMigrationAlert, note *models.MigrateNote) error
	RecordMigrateError(userCred mcclient.TokenCredential, alert *models.SMigrationAlert, note *models.MigrateNote, err error) error

	StartWatchMigratingProcess(ctx context.Context, s *mcclient.ClientSession, alert *models.SMigrationAlert, note *models.MigrateNote)
}

func NewRecorder

func NewRecorder() IRecorder

type IResource

type IResource interface {
	GetId() string
	GetName() string
	GetObject() jsonutils.JSONObject
}

type ITarget

type ITarget interface {
	IHost
	Selected(c ICandidate) ITarget
}

type ItemType

type ItemType string

type MetricDrivers

type MetricDrivers struct {
	*sync.Map
}

func GetMetricDrivers

func GetMetricDrivers() *MetricDrivers

func NewMetricDrivers

func NewMetricDrivers() *MetricDrivers

func (*MetricDrivers) Get

type Rules

type Rules struct {
	Alert          *models.SMigrationAlert
	Condtion       ICondition
	Source         *SourceRule
	Target         *TargetRule
	ResultMustPair bool
}

func NewRules

func NewRules(_ *alerting.EvalContext, m *monitor.EvalMatch, alert *models.SMigrationAlert, drv IMetricDriver, resultMustPair bool) (*Rules, error)

func (*Rules) GetAlert

func (r *Rules) GetAlert() *models.SMigrationAlert

type SourceRule

type SourceRule struct {
	Host       IHost
	Candidates []ICandidate
}

SourceRule 定义触发了报警的宿主机和上面可以迁移的虚拟机

func NewSourceRule

func NewSourceRule(host IHost, cds []ICandidate) *SourceRule

type TargetRule

type TargetRule struct {
	Items []ITarget
}

TargetRule 定义可以选择迁移的宿主机

func NewTargetRule

func NewTargetRule(hosts []ITarget) *TargetRule

type TsdbQuery

type TsdbQuery struct {
	Database    string
	Measurement string
	Fields      []string
}

Jump to

Keyboard shortcuts

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