-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjobarray_hlp.go
54 lines (49 loc) · 1011 Bytes
/
jobarray_hlp.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
package drmaa2os
import (
"fmt"
"github.com/dgruber/drmaa2interface"
)
type action int
const (
suspend action = iota
resume
hold
release
terminate
)
func jobAction(a action, jobs []drmaa2interface.Job) error {
var globalError error
for i := range jobs {
var err error
switch a {
case suspend:
err = jobs[i].Suspend()
case resume:
err = jobs[i].Resume()
case hold:
err = jobs[i].Hold()
case release:
err = jobs[i].Release()
case terminate:
err = jobs[i].Terminate()
}
if err != nil {
if globalError != nil {
globalError = fmt.Errorf("Job %s error: %s | %s",
jobs[i].GetID(), err, globalError.Error())
} else {
globalError = fmt.Errorf("Job %s error: %s",
jobs[i].GetID(), err)
}
}
}
return globalError
}
func newArrayJob(id, jsessionname string, tmpl drmaa2interface.JobTemplate, jobs []drmaa2interface.Job) *ArrayJob {
return &ArrayJob{
id: id,
sessionname: jsessionname,
template: tmpl,
jobs: jobs,
}
}