estimator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AuthFnAPIKeyRequestHeader = "X-API-KEY"
View Source
const ServerDefaultPort = 5656

Variables

View Source
var (
	ErrUnexpected = errors.New("ErrUnexpected")

	ErrClientUnauthorized      = errors.New("ErrClientUnauthorized")
	ErrServerEstimatorNotFound = errors.New("ErrServerEstimatorNotFound")

	ErrEstimator                 = errors.New("ErrEstimator")
	ErrEstimatorNoNodesAvailable = errors.New("ErrEstimatorNoNodesAvailable")
	ErrEstimatorInvalidRequest   = errors.New("ErrEstimatorInvalidRequest")

	ErrNodeMonitor         = errors.New("ErrNodeMonitor")
	ErrNodeMonitorNotFound = errors.New("ErrNodeMonitorNotFound")

	ErrNodeStatus = errors.New("ErrNodeStatus")

	ErrPCPredictor         = errors.New("ErrPCPredictor")
	ErrPCPredictorNotFound = errors.New("ErrPCPredictorNotFound")
)
View Source
var ComputeLeastCostPatternsFn = findLeastCostPatternsExhaustiveWithSampling
View Source
var ComputeLeastCostsFn = findLeastCosts

Functions

func GetErrorFromCode

func GetErrorFromCode(apiErr Error) error

func PredictPCFnDummy

func PredictPCFnDummy(_ context.Context, mcpu int, status NodeStatus) (float64, error)

PredictPCFnDummy returns ( mCPU/100 + avg(CPUUsage) + avg(AmbientTemp) )

func RequestToEstimatorName

func RequestToEstimatorName(ns, name string) string

Types

type AuthenticationFunc

type AuthenticationFunc = openapi3filter.AuthenticationFunc

func AuthFnAPIKey

func AuthFnAPIKey(apiKeys map[string]struct{}) AuthenticationFunc

type Client

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

func NewClient

func NewClient(server string, estimatorNamespace, estimatorName string, opts ...ClientOption) (*Client, error)

func (*Client) EstimatePowerConsumption

func (c *Client) EstimatePowerConsumption(ctx context.Context, cpuMilli, numWorkloads int) (pc *PowerConsumption, apiErr *Error, requestErr error)

type ClientOption

type ClientOption = api.ClientOption

func ClientOptionAddRequestHeader

func ClientOptionAddRequestHeader(k, v string) ClientOption

func ClientOptionGetRequestAsCurl

func ClientOptionGetRequestAsCurl(w io.Writer) ClientOption

type ComputeLeastCostPatternsFunc

type ComputeLeastCostPatternsFunc func(clusterNum, podNum int, wattMatrix [][]float64) (minWatt float64, minWattPatterns [][]int, err error)

type ComputeLeastCostsFunc

type ComputeLeastCostsFunc func(clusterNum, podNum int, wattMatrix [][]float64) (minWatts []float64, err error)

type Error

type Error = api.Error

type Estimator

type Estimator struct {
	Nodes *Nodes
	// contains filtered or unexported fields
}

func (*Estimator) EstimatePowerConsumption

func (e *Estimator) EstimatePowerConsumption(ctx context.Context, cpuMilli, numWorkloads int) ([]float64, error)

EstimatePowerConsumption is a thread-safe function that estimates power consumption with the given parameters.

+Inf in the response represents errors in Node.GetStatus or PowerConsumptionPredictor.Predict. The response will not contain -Inf or NaN, return an error instead if -Inf or NaN is encountered.

type Estimators

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

func (*Estimators) Add

func (m *Estimators) Add(k string, v *Estimator) bool

func (*Estimators) Delete

func (m *Estimators) Delete(k string)

func (*Estimators) Get

func (m *Estimators) Get(k string) (*Estimator, bool)

func (*Estimators) Len

func (m *Estimators) Len() int

func (*Estimators) Range

func (m *Estimators) Range(f func(k string, v *Estimator) bool)

type FakeNodeMonitor

type FakeNodeMonitor struct {
	FetchFunc func(ctx context.Context) (NodeStatus, error)
}

func (*FakeNodeMonitor) FetchStatus

func (m *FakeNodeMonitor) FetchStatus(ctx context.Context) (NodeStatus, error)

type FakePCPredictor

type FakePCPredictor struct {
	PredictFunc func(ctx context.Context, requestCPUMilli int, status NodeStatus) (watt float64, err error)
}

func (*FakePCPredictor) Predict

func (p *FakePCPredictor) Predict(ctx context.Context, requestCPUMilli int, status NodeStatus) (watt float64, err error)

type MLServerPCPredictor

type MLServerPCPredictor struct {
}

func (*MLServerPCPredictor) Predict

func (p *MLServerPCPredictor) Predict(ctx context.Context, requestCPUMilli int, status NodeStatus) (watt float64, err error)

type Node

type Node struct {
	Name string
	// contains filtered or unexported fields
}

func NewNode

func NewNode(name string, nm NodeMonitor, nodeStatusRefreshInterval time.Duration, pcp PowerConsumptionPredictor) *Node

func (*Node) FetchStatus

func (n *Node) FetchStatus(ctx context.Context) (NodeStatus, error)

func (*Node) GetStatus

func (n *Node) GetStatus() NodeStatus

func (*Node) Predict

func (n *Node) Predict(ctx context.Context, requestCPUMilli int, status NodeStatus) (watt float64, err error)

type NodeMonitor

type NodeMonitor interface {
	FetchStatus(ctx context.Context) (NodeStatus, error)
}

type NodeStatus

type NodeStatus struct {
	Timestamp time.Time

	// CPUSockets is the number of sockets the node has.
	// e.g. 2
	CPUSockets int
	// CPUCores is the number of cores per CPU.
	// e.g. 4
	CPUCores int
	// CPUUsages is the list of CPU usages per core.
	// e.g. [[10.0, 10.0, 10.0, 10.0], [20.0, 20.0, 20.0, 20.0]]
	CPUUsages [][]float64
	// CPUTemps is the list of CPU temperatures in Celsius per core.
	// e.g. [[30.0, 30.0, 30.0, 30.0], [50.0, 50.0, 50.0, 50.0]]
	CPUTemps [][]float64

	// AmbientSensors is the number of ambient temperature sensors the node has.
	// e.g. 4
	AmbientSensors int
	// AmbientTemps is the list of temperatures in Celsius.
	// e.g. [20.0, 20.0, 20.0, 20.0]
	AmbientTemps []float64
}

func (*NodeStatus) AverageAmbientTemp

func (s *NodeStatus) AverageAmbientTemp() (float64, error)

func (*NodeStatus) AverageCPUTemp

func (s *NodeStatus) AverageCPUTemp() (float64, error)

func (*NodeStatus) AverageCPUUsage

func (s *NodeStatus) AverageCPUUsage() (float64, error)

type Nodes

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

func (*Nodes) Add

func (m *Nodes) Add(k string, v *Node) bool

func (*Nodes) Delete

func (m *Nodes) Delete(k string)

func (*Nodes) Get

func (m *Nodes) Get(k string) (*Node, bool)

func (*Nodes) Len

func (m *Nodes) Len() int

func (*Nodes) Range

func (m *Nodes) Range(f func(k string, v *Node) bool)

type PowerConsumption

type PowerConsumption = api.PowerConsumption

type PowerConsumptionPredictor

type PowerConsumptionPredictor interface {
	Predict(ctx context.Context, requestCPUMilli int, status NodeStatus) (watt float64, err error)
}

type RedfishNodeMonitor

type RedfishNodeMonitor struct {
}

func (*RedfishNodeMonitor) FetchStatus

func (m *RedfishNodeMonitor) FetchStatus(ctx context.Context) (NodeStatus, error)

type Server

type Server struct {
	Estimators *Estimators
	// contains filtered or unexported fields
}

func (*Server) Handler

func (s *Server) Handler(middlewares ...func(http.Handler) http.Handler) (http.Handler, error)

func (*Server) HandlerWithAuthFn

func (s *Server) HandlerWithAuthFn(authFn AuthenticationFunc, middlewares ...func(http.Handler) http.Handler) (http.Handler, error)

Directories

Path Synopsis
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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