Documentation ¶
Overview ¶
//定义了集群内发生事件的各种事件类型
EventDB 的作用是存储模拟器模拟区间内所有的事件.
同时在使用外部调度器时,发生时间线变动时,方便修 改某个instance 在时间线中的所有的事件
Index ¶
- Constants
- Variables
- func CsvToList(path string) (table [][]string, tabletop []string)
- func EventHandle(c ClusterState, e IEvent)
- func ListToCsv(table [][]string, tabletop []string, outpath string)
- func SortByQueueTime(i []Instance)
- type ByQueueTime
- type CRClusterState
- type CRClusterStateSnapShot
- type CRNodeState
- func (state *CRNodeState) AddMachine(newMachine *Machine) error
- func (state *CRNodeState) GetAllocs() (machines []MachineBasicInfo)
- func (state *CRNodeState) GetUsage()
- func (state *CRNodeState) IsInstanceExisted(targetId InstanceKey) bool
- func (state *CRNodeState) IsMachineExisted(machineId MachineID) bool
- func (state *CRNodeState) RemoveInstance(targetId InstanceKey) error
- func (state *CRNodeState) RemoveMachine(machineId MachineID) error
- func (state *CRNodeState) ScduleInstance(machineId MachineID, newInstance *Instance) error
- func (state *CRNodeState) UpdateInstanceRequest(targetId InstanceKey, cpuReq, ramReq float64) error
- func (state *CRNodeState) UpdateMachineCapacity(machineId MachineID, cpuCapacity, ramCapacity float64) error
- type CRQueue
- type ClusterState
- type DataLoader
- func (dl *DataLoader) AllMachineEvent() (res []MachineEvent, err error)
- func (dl *DataLoader) GetInstanceEventBetween(startHour, endHour int) (res []InstanceEvent, err error)
- func (dl *DataLoader) GetMachineEvent(startHour, endHour int) (res []MachineEvent, err error)
- func (dl *DataLoader) InitialState(targetHour int) ClusterState
- type Event
- type EventObjectType
- type EventTable
- type IEvent
- type Instance
- type InstanceEvent
- type InstanceKey
- type Machine
- type MachineBasicInfo
- type MachineEvent
- type MachineID
- type NodeState
- type QueueState
- type SimState
- type Simulator
- func (s *Simulator) GetMachineInfo() (res []MachineBasicInfo, err error)
- func (s *Simulator) GetQueueInfo() (res []Instance, err error)
- func (s *Simulator) GetTimeNow() (time int64, err error)
- func (s *Simulator) Goto(end int64) error
- func (s *Simulator) Init(startHour, endHour int) error
- func (s *Simulator) Schdule(iID InstanceKey, mID MachineID) (err error)
- type Timeline
- type UsageEvent
Constants ¶
View Source
const ( MinHourToSimulate = 1 // 最小模拟开始的时间 MaxHourToSimulate = 10 // 最大模拟开始的时间 )
View Source
const ( INSTANCESubmit int64 = 0 INSTANCEQueue int64 = 1 INSTANCEEnable int64 = 2 INSTANCESchdule int64 = 3 INSTANCEEvict int64 = 4 INSTANCEFail int64 = 5 INSTANCEFinish int64 = 6 INSTANCEKill int64 = 7 INSTANCELost int64 = 8 INSTANCEUpdatePending int64 = 9 INSTANCEUpdateRunning int64 = 10 )
View Source
const ( MACHINEAdd int64 = 1 MACHINEDelete int64 = 2 MACHINEUpdate int64 = 3 )
Variables ¶
Functions ¶
func EventHandle ¶
func EventHandle(c ClusterState, e IEvent)
func SortByQueueTime ¶
func SortByQueueTime(i []Instance)
Types ¶
type ByQueueTime ¶
type ByQueueTime []Instance
func (ByQueueTime) Len ¶
func (a ByQueueTime) Len() int
func (ByQueueTime) Less ¶
func (a ByQueueTime) Less(i, j int) bool
func (ByQueueTime) Swap ¶
func (a ByQueueTime) Swap(i, j int)
type CRClusterState ¶
type CRClusterState struct { Time int64 Queue *CRQueue Nodes *CRNodeState }
C for center ,R for ram.
func (*CRClusterState) GetNodes ¶
func (c *CRClusterState) GetNodes() NodeState
func (*CRClusterState) GetQueue ¶
func (c *CRClusterState) GetQueue() QueueState
func (*CRClusterState) GetTime ¶
func (c *CRClusterState) GetTime() int64
func (*CRClusterState) SetTime ¶
func (c *CRClusterState) SetTime(t int64)
func (*CRClusterState) SnapShot ¶
func (c *CRClusterState) SnapShot() CRClusterStateSnapShot
type CRClusterStateSnapShot ¶
type CRClusterStateSnapShot struct { Time int64 Queue []Instance NodesInstances []Instance NodesMachines []MachineBasicInfo }
------------------ SnapShot define----------------
func (*CRClusterStateSnapShot) Recover ¶
func (snap *CRClusterStateSnapShot) Recover() *CRClusterState
type CRNodeState ¶
type CRNodeState struct { Instances map[InstanceKey]*Instance Machines map[MachineID]*Machine }
集群状态的实现 存储在内存的集中式数据库。 C for center ,R for ram.
func NewCRClusterState ¶
func NewCRClusterState() *CRNodeState
func (*CRNodeState) AddMachine ¶
func (state *CRNodeState) AddMachine(newMachine *Machine) error
func (*CRNodeState) GetAllocs ¶
func (state *CRNodeState) GetAllocs() (machines []MachineBasicInfo)
func (*CRNodeState) GetUsage ¶
func (state *CRNodeState) GetUsage()
func (*CRNodeState) IsInstanceExisted ¶
func (state *CRNodeState) IsInstanceExisted(targetId InstanceKey) bool
func (*CRNodeState) IsMachineExisted ¶
func (state *CRNodeState) IsMachineExisted(machineId MachineID) bool
func (*CRNodeState) RemoveInstance ¶
func (state *CRNodeState) RemoveInstance(targetId InstanceKey) error
func (*CRNodeState) RemoveMachine ¶
func (state *CRNodeState) RemoveMachine(machineId MachineID) error
func (*CRNodeState) ScduleInstance ¶
func (state *CRNodeState) ScduleInstance(machineId MachineID, newInstance *Instance) error
func (*CRNodeState) UpdateInstanceRequest ¶
func (state *CRNodeState) UpdateInstanceRequest(targetId InstanceKey, cpuReq, ramReq float64) error
func (*CRNodeState) UpdateMachineCapacity ¶
func (state *CRNodeState) UpdateMachineCapacity(machineId MachineID, cpuCapacity, ramCapacity float64) error
type CRQueue ¶
type CRQueue struct {
// contains filtered or unexported fields
}
func InitCRQueue ¶
func (*CRQueue) IsExisted ¶
func (q *CRQueue) IsExisted(k InstanceKey) bool
func (*CRQueue) Remove ¶
func (q *CRQueue) Remove(k InstanceKey) error
type ClusterState ¶
type ClusterState interface { SetTime(int64) GetTime() int64 GetQueue() QueueState GetNodes() NodeState }
func InitCRClusterState ¶
func InitCRClusterState() ClusterState
type DataLoader ¶
type DataLoader struct {
// contains filtered or unexported fields
}
DataLoader is preprocessor of data and the provider of data it deal the csv data to the binary data and store the data as cache (powered by boltdb) it also provide the state and events of the cluster data
func NewDataLoader ¶
func NewDataLoader(dataDir string, cacheDir string) *DataLoader
func (*DataLoader) AllMachineEvent ¶
func (dl *DataLoader) AllMachineEvent() (res []MachineEvent, err error)
func (*DataLoader) GetInstanceEventBetween ¶
func (dl *DataLoader) GetInstanceEventBetween(startHour, endHour int) (res []InstanceEvent, err error)
return the InstanceEvent between startHour to endHour ,for example startHour=8,endHour=10, then the function will return the event of 8 and 9 hour( not including 10)
func (*DataLoader) GetMachineEvent ¶
func (dl *DataLoader) GetMachineEvent(startHour, endHour int) (res []MachineEvent, err error)
func (*DataLoader) InitialState ¶
func (dl *DataLoader) InitialState(targetHour int) ClusterState
type Event ¶
type Event struct { Time int64 Object EventObjectType }
func (*Event) HappenTime ¶
func (*Event) ObjectType ¶
func (e *Event) ObjectType() EventObjectType
type EventObjectType ¶
type EventObjectType uint8
const ( E_MACHINE EventObjectType = iota E_INSTANCE )
type EventTable ¶
type EventTable struct {
// contains filtered or unexported fields
}
func NewEventTable ¶
func NewEventTable(i []InstanceEvent, m []MachineEvent) (table *EventTable)
type IEvent ¶
type IEvent interface { HappenTime() int64 ObjectType() EventObjectType }
type InstanceEvent ¶
type InstanceEvent struct { Event Type int64 InstanceId InstanceKey CpuRequest float64 RamRequest float64 MachineID MachineID AllocID int64 ScheduleClass int64 Priority int64 }
func FileToInstanceEventList ¶
func FileToInstanceEventList(fileName string) []InstanceEvent
type InstanceKey ¶
type Machine ¶
type Machine struct { MachineBasicInfo Instances map[InstanceKey]*Instance }
func NewMachine ¶
func (*Machine) CalAlloc ¶
func (m *Machine) CalAlloc() MachineBasicInfo
type MachineBasicInfo ¶
type MachineBasicInfo struct { MachineId MachineID CpuCapacity float64 RamCapacity float64 CpuAlloc float64 RamAlloc float64 }
func (MachineBasicInfo) ToMachine ¶
func (m_info MachineBasicInfo) ToMachine() *Machine
type MachineEvent ¶
type NodeState ¶
type NodeState interface { IsInstanceExisted(InstanceKey) bool IsMachineExisted(MachineID) bool AddMachine(*Machine) error RemoveMachine(MachineID) error ScduleInstance(MachineID, *Instance) error RemoveInstance(InstanceKey) error UpdateInstanceRequest(targetId InstanceKey, cpuReq, ramReq float64) error UpdateMachineCapacity(machineId MachineID, cpuCapacity, ramCapacity float64) error GetAllocs() []MachineBasicInfo GetUsage() }
type QueueState ¶
type QueueState interface { Add(i Instance) error Remove(i InstanceKey) error Get(i InstanceKey) (Instance, error) IsExisted(i InstanceKey) bool All() []Instance }
-------------------- queue define-------------------
type Simulator ¶
type Simulator struct { Flag SimState DataPath string CachePath string // contains filtered or unexported fields }
func NewSimulator ¶
func (*Simulator) GetMachineInfo ¶
func (s *Simulator) GetMachineInfo() (res []MachineBasicInfo, err error)
func (*Simulator) GetQueueInfo ¶
func (*Simulator) GetTimeNow ¶
type UsageEvent ¶
type UsageEvent struct { Event InstanceId InstanceKey CpuUsage float64 RamUsage float64 MachineID int64 }
Click to show internal directories.
Click to hide internal directories.