server

package
v0.0.0-...-0c34cbd Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindReplicaSet  = "ReplicaSet"
	KindDaemonSet   = "DaemonSet"
	KindStatefulSet = "StatefulSet"
)
View Source
const (
	DefaultPort           = 2000
	DefaultScrapeInterval = time.Minute
	DefaultMetricDuration = 7 * 24 * time.Hour
	DefaultReClusterTime  = 1 * time.Hour
	DefaultNumRound       = 30
	DefaultNumClass       = 20
)
View Source
const PodListUrl = "http://localhost:8001/api/v1/pods"
View Source
const PodMetricsListUrl = "http://localhost:8001/apis/metrics.k8s.io/v1beta1/pods"

Variables

This section is empty.

Functions

func NewDatabaseDatasource

func NewDatabaseDatasource(db *gorm.DB) MetricDataSource

Types

type AppClassDO

type AppClassDO struct {
	gorm.Model
	AppId   uint `gorm:"uniqueIndex"`
	ClassId uint
	CpuMax  float32
	MemMax  float32
}

type AppDo

type AppDo struct {
	gorm.Model
	server.AppName
}

type AppPodMetricsDO

type AppPodMetricsDO struct {
	gorm.Model
	AppId     uint   `gorm:"uniqueIndex:unique_record"`
	Timestamp uint64 `gorm:"uniqueIndex:unique_record"`
	Cpu       float32
	Mem       float32
}

type ClassSectionMetricsDO

type ClassSectionMetricsDO struct {
	ID         uint `gorm:"primarykey"`
	SectionNum uint `gorm:"primarykey"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  gorm.DeletedAt `gorm:"index"`
	core.SectionData
}

type Dao

type Dao interface {
	DB() *gorm.DB
	UpdateDao
	QueryDao
}

func NewDao

func NewDao(host string) (Dao, error)

type QueryDao

type QueryDao interface {
	QueryClassMetricsByClassId(classId uint) (*server.ClassMetrics, error)
	QueryAllClassMetrics() ([]*server.ClassMetrics, error)
	QueryAppClassByApp(appName *server.AppName) (*server.AppClass, error)
}

type Server

type Server interface {
	Start() error
}

func NewServer

func NewServer(config *ServerConfig) (Server, error)

type ServerConfig

type ServerConfig struct {
	MetricDuration       time.Duration // 给每个应用保留的数据的时间长度
	Port                 uint16        // 本服务器监听端口
	ScrapeInterval       time.Duration // 从metrics server获取数据的周期。至少为15s。
	ReClusterTime        time.Duration // 再聚类的时间
	NumClass             uint          // 类别数量
	NumRound             uint          // 聚类迭代轮次
	InitialCenterCsvFile string        // 初始各类中心的数据文件。若不是空,则会清空数据库的数据并读取。若为空,则使用数据库数据,此时如果数据库没有类别数据,则会产生错误。
	MysqlHost            string
}

func (*ServerConfig) Complete

func (config *ServerConfig) Complete() error

func (ServerConfig) String

func (s ServerConfig) String() string

type UpdateDao

type UpdateDao interface {
	SaveClassMetrics(c *server.ClassMetrics) error
	SaveAppClass(a *server.AppClass) error
	SaveAllAppPodMetrics(arr []*server.AppPodMetrics) error

	// 永久删除timestamp之前的数据
	RemoveAppPodMetricsBefore(timestamp uint64) error
	// 删除所有存在的ClassMetrics
	RemoveAllClassMetrics() error
}

Jump to

Keyboard shortcuts

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