Added Job interface
This commit is contained in:
parent
ae3657baf3
commit
dba42611d7
2 changed files with 131 additions and 76 deletions
31
updatejob.go
31
updatejob.go
|
@ -16,19 +16,42 @@ package realis
|
|||
|
||||
import "gen-go/apache/aurora"
|
||||
|
||||
// Structure to collect all information requrired to create job update
|
||||
// Structure to collect all information required to create job update
|
||||
type UpdateJob struct {
|
||||
*Job // SetInstanceCount for job is hidden, access via full qualifier
|
||||
Job // SetInstanceCount for job is hidden, access via full qualifier
|
||||
req *aurora.JobUpdateRequest
|
||||
}
|
||||
|
||||
// Create a default UpdateJob object.
|
||||
func NewUpdateJob(job *Job) *UpdateJob {
|
||||
func NewUpdateJob(config *aurora.TaskConfig) *UpdateJob {
|
||||
|
||||
req := aurora.NewJobUpdateRequest()
|
||||
req.TaskConfig = job.jobConfig.TaskConfig
|
||||
req.TaskConfig = config
|
||||
req.Settings = aurora.NewJobUpdateSettings()
|
||||
|
||||
job := NewJob().(AuroraJob)
|
||||
job.jobConfig.TaskConfig = config
|
||||
|
||||
|
||||
// Rebuild resource map from TaskConfig
|
||||
job.resources = make(map[string]*aurora.Resource)
|
||||
for ptr := range config.Resources {
|
||||
if(ptr.NumCpus != nil){
|
||||
job.resources["cpu"].NumCpus = ptr.NumCpus
|
||||
continue // Guard against Union violations that Go won't enforce
|
||||
}
|
||||
|
||||
if(ptr.RamMb != nil){
|
||||
job.resources["ram"].RamMb = ptr.RamMb
|
||||
continue
|
||||
}
|
||||
|
||||
if(ptr.DiskMb != nil){
|
||||
job.resources["disk"].DiskMb = ptr.DiskMb
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Mirrors defaults set by Pystachio
|
||||
req.Settings.UpdateOnlyTheseInstances = make(map[*aurora.Range]bool)
|
||||
req.Settings.UpdateGroupSize = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue