Documentation ¶
Overview ¶
//定义了集群内发生事件的各种事件类型
Index ¶
- Constants
- Variables
- func EventsBetween(dataPath string, startime, endtime int64) (instanceEvents, usageEvents, machineEvents [][]string)
- func GetVersion() string
- func PrepareDatas(dataPath string, starttime, endtime int64) (initState *ClusterState, instanceEvents []*InstanceEvent, ...)
- func PrintVersion()
- func SetCachePath(s string)
- type ClusterState
- func (c *ClusterState) AddMachine(newMachine *Machine) error
- func (c *ClusterState) AddTask(machineId int64, newInstance *Instance) error
- func (s *ClusterState) ExportAllUsage() (datas []MachineBasicInfo)
- func (c *ClusterState) RemoveMachine(machineId int64) error
- func (c *ClusterState) RemoveTask(targetId InstanceKey) error
- func (c *ClusterState) UpdateAllUsage()
- func (c *ClusterState) UpdateMachineCapacity(machineId int64, cpuCapacity, ramCapacity float64) error
- func (c *ClusterState) UpdateTaskRequest(targetId InstanceKey, cpuRequest, ramRequest float64) error
- func (c *ClusterState) UpdateTaskUsage(targetId InstanceKey, cpuUsage, ramUsage float64) error
- type Event
- type IEvent
- type Instance
- type InstanceEvent
- type InstanceEventType
- type InstanceKey
- type Machine
- type MachineBasicInfo
- type MachineEvent
- type MachineEventType
- type UsageEvent
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) 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 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 Machine ¶
type Machine struct { MachineBasicInfo Tasks map[InstanceKey]*Instance }
func NewMachine ¶
type MachineBasicInfo ¶
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 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.