forked from clemsonciti/jobperf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobs.go
60 lines (51 loc) · 1.1 KB
/
jobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package jobperf
import (
"time"
)
type JobState interface {
IsRunning() bool
IsComplete() bool
IsQueued() bool
String() string
}
type JobQuery struct {
Username string
OnlyRunning bool
}
type JobEngine interface {
GetJobByID(jobID string) (*Job, error)
SelectJobIDs(q JobQuery) ([]string, error)
NodeStatsSession(j *Job, hostname string) (NodeStatsSession, error)
Warning() string
NodeStatsWarning() string
}
type Job struct {
ID string
Name string
Owner string
//ChunkCount int
CoresTotal int
MemoryTotal Bytes
GPUsTotal int
Walltime time.Duration
State string
StartTime time.Time
UsedWalltime time.Duration
UsedCPUTime time.Duration
UsedMemory Bytes
Nodes []Node
// Raw holds a scheduler specific type. It can be used by the scheduler
// plugin when creating a nodestats session.
Raw interface{}
}
func (j *Job) IsRunning() bool {
return j.State == "R" || j.State == "RUNNING"
}
func (j *Job) IsComplete() bool {
for _, s := range []string{"E", "F", "COMPLETED", "CANCELED", "TIMEOUT", "FAILED"} {
if j.State == s {
return true
}
}
return false
}