sclib

package module
v0.0.0-...-fa34bbc Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

//定义了集群内发生事件的各种事件类型

Index

Constants

View Source
const (
	SECOND int64 = 1000 * 1000
	MINUTE int64 = 60 * SECOND
	HOUR   int64 = 60 * MINUTE
)
View Source
const DefaultCachePath = "./sc_cache"

Variables

View Source
var CachePath = DefaultCachePath

Functions

func EventsBetween

func EventsBetween(dataPath string, startime, endtime int64) (instanceEvents, usageEvents, machineEvents [][]string)

找到所有在[starttime,endtime)发生的事件包括 instance_events usage_events machine_events

func GetVersion

func GetVersion() string

func PrepareDatas

func PrepareDatas(dataPath string, starttime, endtime int64) (initState *ClusterState, instanceEvents []*InstanceEvent, usageEvents []*UsageEvent, machineEvents []*MachineEvent)

func PrintVersion

func PrintVersion()

func SetCachePath

func SetCachePath(s string)

Types

type ClusterState

type ClusterState struct {
	Time     int64
	Tasks    map[InstanceKey]*Instance
	Machines map[int64]*Machine
}

func InitState

func InitState(dataPath string, starttime int64) (initState *ClusterState)

返回集群的初始状态,datapath为trace数据的路径 starttime为所要求初始状态的时刻

func (*ClusterState) AddMachine

func (c *ClusterState) AddMachine(newMachine *Machine) error

向集群增加机器

func (*ClusterState) AddTask

func (c *ClusterState) AddTask(machineId int64, newInstance *Instance) error

向一台机器上增加instance

func (*ClusterState) ExportAllUsage

func (s *ClusterState) ExportAllUsage() (datas []MachineBasicInfo)

返回机器总体利用率

func (*ClusterState) RemoveMachine

func (c *ClusterState) RemoveMachine(machineId int64) error

移除机器

func (*ClusterState) RemoveTask

func (c *ClusterState) RemoveTask(targetId InstanceKey) error

从集群中移除instance

func (*ClusterState) UpdateAllUsage

func (c *ClusterState) UpdateAllUsage()

更新机器利用率

func (*ClusterState) UpdateMachineCapacity

func (c *ClusterState) UpdateMachineCapacity(machineId int64, cpuCapacity, ramCapacity float64) error

更新机器容量

func (*ClusterState) UpdateTaskRequest

func (c *ClusterState) UpdateTaskRequest(targetId InstanceKey, cpuRequest, ramRequest float64) error

更新任务资源请求

func (*ClusterState) UpdateTaskUsage

func (c *ClusterState) UpdateTaskUsage(targetId InstanceKey, cpuUsage, ramUsage float64) error

更新集群任务利用率

type Event

type Event struct {
	Time   int64
	Object string
}

func (*Event) HappenTime

func (e *Event) HappenTime() int64

func (*Event) ObjectType

func (e *Event) ObjectType() string

type IEvent

type IEvent interface {
	HappenTime() int64
	ObjectType() string
}

type Instance

type Instance struct {
	InstanceId InstanceKey
	QueueTime  int64 //进入队列的时间
	CpuRequest float64
	RamRequest float64
	CpuUsage   float64
	RamUsage   float64

	MachineID int64
	// contains filtered or unexported fields
}

type InstanceEvent

type InstanceEvent struct {
	Event
	Type          InstanceEventType
	InstanceId    InstanceKey
	CpuRequest    float64
	RamRequest    float64
	MachineID     int64
	AllocID       int64
	ScheduleClass int64
	Priority      int64
}

type InstanceEventType

type InstanceEventType int64
const (
	INSTANCESubmit        InstanceEventType = 0
	INSTANCEQueue         InstanceEventType = 1
	INSTANCEEnable        InstanceEventType = 2
	INSTANCESchdule       InstanceEventType = 3
	INSTANCEEvict         InstanceEventType = 4
	INSTANCEFail          InstanceEventType = 5
	INSTANCEFinish        InstanceEventType = 6
	INSTANCEKill          InstanceEventType = 7
	INSTANCELost          InstanceEventType = 8
	INSTANCEUpdatePending InstanceEventType = 9
	INSTANCEUpdateRunning InstanceEventType = 10
)

type InstanceKey

type InstanceKey struct {
	CollectionId  int64
	InstanceIndex int64
}

type Machine

type Machine struct {
	MachineBasicInfo
	Tasks map[InstanceKey]*Instance
}

func NewMachine

func NewMachine(id int64, cpuCap, ramCap float64) *Machine

func (*Machine) CalUsage

func (m *Machine) CalUsage()

type MachineBasicInfo

type MachineBasicInfo struct {
	MachineId   int64   `json:"machine_id"`
	CpuCapacity float64 `json:"cpu_capacity"`
	RamCapacity float64 `json:"memory_capacity"`
	CpuUsagePer float64 `json:"cpu_usage_per"`
	RamUsagePer float64 `json:"ram_usage_per"`
}

type MachineEvent

type MachineEvent struct {
	Event
	MachineID   int64
	Type        MachineEventType
	CpuCapacity float64
	RamCapacity float64
}

type MachineEventType

type MachineEventType int64
const (
	MACHINEAdd    MachineEventType = 1
	MACHINEDelete MachineEventType = 2
	MACHINEUpdate MachineEventType = 3
)

type UsageEvent

type UsageEvent struct {
	Event
	InstanceId InstanceKey
	CpuUsage   float64
	RamUsage   float64
	MachineID  int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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