diff --git a/src/group_models.go b/src/group_models.go new file mode 100644 index 0000000..ce8b9e9 --- /dev/null +++ b/src/group_models.go @@ -0,0 +1,13 @@ +package main + +type Group struct { + Name string `json:"name"` + Weight int `json:"weight"` + Reserved bool `json:"reserved"` + NumGPU int `json:"quota_gpu"` + MemoryGPU int `json:"quota_gpu_mem"` + CPU int `json:"quota_cpu"` + Memory int `json:"quota_mem"` +} + + diff --git a/src/job_status.go b/src/job_status.go new file mode 100644 index 0000000..a0ff4d4 --- /dev/null +++ b/src/job_status.go @@ -0,0 +1,19 @@ +package main + +type JobStatus struct { + Name string + tasks map[string]TaskStatus +} + +type TaskStatus struct { + Id string `json:"id"` + HostName string `json:"hostname"` + Node string `json:"node"` + Image string `json:"image"` + ImageDigest string `json:"image_digest"` + Command string `json:"command"` + CreatedAt string `json:"created_at"` + FinishedAt string `json:"finished_at"` + Status string `json:"status"` + State map[string]interface{} `json:"state"` +} diff --git a/src/message.go b/src/message.go new file mode 100644 index 0000000..36684ca --- /dev/null +++ b/src/message.go @@ -0,0 +1,83 @@ +package main + +type MsgSubmit struct { + Code int `json:"code"` + Error string `json:"error"` +} + +type MsgPoolStatusHistory struct { + Code int `json:"code"` + Error string `json:"error"` + Data []PoolStatus `json:"data"` +} + +type MsgStop struct { + Code int `json:"code"` + Error string `json:"error"` +} + +type MsgSummary struct { + Code int `json:"code"` + Error string `json:"error"` + JobsFinished int `json:"jobs_finished"` + JobsRunning int `json:"jobs_running"` + JobsPending int `json:"jobs_pending"` + FreeGPU int `json:"gpu_free"` + UsingGPU int `json:"gpu_using"` +} + +type MsgJobList struct { + Code int `json:"code"` + Error string `json:"error"` + Jobs []Job `json:"jobs"` +} + +type MsgLog struct { + Code int `json:"code"` + Error string `json:"error"` + Logs string `json:"logs"` +} + +type MsgTaskStatus struct { + Code int `json:"code"` + Error string `json:"error"` + Status TaskStatus `json:"status"` +} + +type MsgJobStatus struct { + Code int `json:"code"` + Error string `json:"error"` + Status []TaskStatus `json:"status"` +} + +type MsgCreate struct { + Code int `json:"code"` + Error string `json:"error"` + Id string `json:"id"` +} + +type MsgResource struct { + Code int `json:"code"` + Error string `json:"error"` + Resource map[string]NodeStatus `json:"resources"` +} + +type MsgGroupCreate struct { + Code int `json:"code"` + Error string `json:"error"` +} + +type MsgGroupList struct { + Code int `json:"code"` + Error string `json:"error"` + Groups []Group `json:"groups"` +} + +type MsgOptimizerPredict struct { + Code int `json:"code"` + Error string `json:"error"` + Total int `json:"total"` + Pre int `json:"pre"` + Main int `json:"main"` + Post int `json:"post"` +} diff --git a/src/pool_seg.go b/src/pool_seg.go new file mode 100644 index 0000000..b746cf1 --- /dev/null +++ b/src/pool_seg.go @@ -0,0 +1,11 @@ +package main + +import "sync" + +type PoolSeg struct { + ID int + Nodes map[string]*NodeStatus + Lock sync.Mutex + Next *PoolSeg + IsVirtual bool +}