strategies

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2020 Pradyumna Kaushik

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(
	s Interface,
	labelMatchers []*query.LabelMatcher,
	receiver TaskRanksReceiver,
	prometheusScrapeInterval time.Duration) error

Build the strategy object.

Types

type Interface

type Interface interface {
	// Init initializes the task ranking strategy, if needed.
	// The Prometheus scrape interval is also provided.
	Init(prometheusScrapeInterval time.Duration)
	// SetTaskRanksReceiver registers a receiver of the task ranking results.
	// This receiver is a callback and is used to pass the result of applying
	// the strategy to rank tasks.
	SetTaskRanksReceiver(TaskRanksReceiver)
	// Execute the strategy.
	Execute(model.Value)
	// GetMetric returns the metric to pull data for.
	// Note: This has to be a single metric name.
	GetMetric() string
	// SetLabelMatchers sets the label matchers to use to filter data.
	// Strategy implementations can perform additional validations on the provided label matchers.
	SetLabelMatchers([]*query.LabelMatcher) error
	// GetLabelMatchers returns the labels and corresponding matching operators to use
	// filter out data that is not required by this strategy.
	GetLabelMatchers() []*query.LabelMatcher
	// Range returns the duration specifying how far back in time data needs to be fetched.
	// Returns the unit of time along with an integer quantifying the duration.
	GetRange() (query.TimeUnit, uint)
}

type TaskRankCpuSharesStrategy

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

TaskRankCpuSharesStrategy is a task ranking strategy that ranks the tasks in non-increasing order based on the cpu-shares allocated to tasks.

func (*TaskRankCpuSharesStrategy) Execute

func (s *TaskRankCpuSharesStrategy) Execute(data model.Value)

Execute the strategy using the provided data.

func (TaskRankCpuSharesStrategy) GetLabelMatchers

func (s TaskRankCpuSharesStrategy) GetLabelMatchers() []*query.LabelMatcher

GetLabelMatchers returns the label matchers to be used to filter data.

func (TaskRankCpuSharesStrategy) GetMetric

func (s TaskRankCpuSharesStrategy) GetMetric() string

GetMetric returns the name of the metric to query.

func (TaskRankCpuSharesStrategy) GetRange

func (s TaskRankCpuSharesStrategy) GetRange() (query.TimeUnit, uint)

GetRange returns the time unit and duration for how far back values need to be fetched.

func (*TaskRankCpuSharesStrategy) Init added in v0.4.0

func (*TaskRankCpuSharesStrategy) SetLabelMatchers

func (s *TaskRankCpuSharesStrategy) SetLabelMatchers(labelMatchers []*query.LabelMatcher) error

SetLabelMatchers sets the label matchers to use to filter data. This strategy mandates that a dedicated label be provided for filtering metrics based on TaskID and Hostname.

func (*TaskRankCpuSharesStrategy) SetTaskRanksReceiver

func (s *TaskRankCpuSharesStrategy) SetTaskRanksReceiver(receiver TaskRanksReceiver)

SetTaskRanksReceiver sets the receiver of the results of task ranking.

type TaskRankCpuUtilStrategy added in v0.4.0

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

TaskRankCpuUtilStrategy is a task ranking strategy that ranks the tasks in non-increasing order based on the cpu utilization (%) in the past 5 intervals of time.

For example, if Prometheus scrapes metrics every 1s, then each time interval is 1s long. This strategy then would then rank tasks based on their cpu utilization in the past 5 seconds.

func (*TaskRankCpuUtilStrategy) Execute added in v0.4.0

func (s *TaskRankCpuUtilStrategy) Execute(data model.Value)

Execute the strategy using the provided data.

func (TaskRankCpuUtilStrategy) GetLabelMatchers added in v0.4.0

func (s TaskRankCpuUtilStrategy) GetLabelMatchers() []*query.LabelMatcher

GetLabelMatchers returns the label matchers to be used to filter data.

func (TaskRankCpuUtilStrategy) GetMetric added in v0.4.0

func (s TaskRankCpuUtilStrategy) GetMetric() string

GetMetric returns the name of the metric to query.

func (TaskRankCpuUtilStrategy) GetRange added in v0.4.0

func (s TaskRankCpuUtilStrategy) GetRange() (query.TimeUnit, uint)

GetRange returns the time unit and duration for how far back (in seconds) values need to be fetched.

func (*TaskRankCpuUtilStrategy) Init added in v0.4.0

func (s *TaskRankCpuUtilStrategy) Init(prometheusScrapeInterval time.Duration)

Init initializes the prometheus scrape interval.

func (*TaskRankCpuUtilStrategy) SetLabelMatchers added in v0.4.0

func (s *TaskRankCpuUtilStrategy) SetLabelMatchers(labelMatchers []*query.LabelMatcher) error

SetLabelMatchers sets the label matchers to use when filtering data. This strategy mandates that a dedicated label be provided for filtering metrics based on TaskID and Hostname.

func (*TaskRankCpuUtilStrategy) SetTaskRanksReceiver added in v0.4.0

func (s *TaskRankCpuUtilStrategy) SetTaskRanksReceiver(receiver TaskRanksReceiver)

SetTaskRanksReceiver sets the receiver of the task ranking results.

type TaskRanksReceiver

type TaskRanksReceiver interface {
	// Receive the ranked tasks and their corresponding information.
	// Task at position i is ranked higher than task at position i+1.
	Receive(entities.RankedTasks)
}

TaskRanksReceiver defines an API to be implemented by all receivers of task ranking results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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