scheduler: thread size through

This commit is contained in:
Armon Dadgar
2015-08-13 18:36:13 -07:00
parent fde32cc6ca
commit 6b1ad69da4
2 changed files with 14 additions and 1 deletions

View File

@@ -189,7 +189,7 @@ func (s *ServiceScheduler) computePlacements(job *structs.Job, place []allocTupl
NodeID: option.Node.ID,
JobID: job.ID,
Job: job,
Resources: nil, // TODO: size
Resources: stack.TaskGroupSize(),
Metrics: ctx.Metrics(),
Status: structs.AllocStatusPending,
}

View File

@@ -15,6 +15,10 @@ type Stack interface {
// This must be called in between calls to Select.
SetTaskGroup(tg *structs.TaskGroup)
// TaskGroupSize returns the size of the task group.
// This is only valid after calling SetTaskGroup
TaskGroupSize() *structs.Resources
// Select is used to select a node for the task group
Select() *RankedNode
}
@@ -34,6 +38,8 @@ type ServiceStack struct {
BinPack *BinPackIterator
Limit *LimitIterator
MaxScore *MaxScoreIterator
size *structs.Resources
}
// NewServiceStack constructs a stack used for selecting service placements
@@ -99,6 +105,9 @@ func (s *ServiceStack) SetTaskGroup(tg *structs.TaskGroup) {
size.Add(task.Resources)
}
// Store the size
s.size = size
// Update the parameters of iterators
s.TaskGroupDrivers.SetDrivers(drivers)
s.TaskGroupConstraint.SetConstraints(constr)
@@ -108,6 +117,10 @@ func (s *ServiceStack) SetTaskGroup(tg *structs.TaskGroup) {
s.MaxScore.Reset()
}
func (s *ServiceStack) TaskGroupSize() *structs.Resources {
return s.size
}
func (s *ServiceStack) Select() *RankedNode {
return s.MaxScore.Next()
}