Commit 1b2cb123 authored by Armon Dadgar's avatar Armon Dadgar
Browse files

scheduler: Adding CreateEval to Planner

parent d0cf06a8
No related merge requests found
Showing with 26 additions and 2 deletions
+26 -2
......@@ -79,4 +79,8 @@ type Planner interface {
// UpdateEval is used to update an evaluation. This should update
// a copy of the input evaluation since that should be immutable.
UpdateEval(*structs.Evaluation) error
// CreateEval is used to create an evaluation. This should set the
// PreviousEval to that of the current evaluation.
CreateEval(*structs.Evaluation) error
}
......@@ -25,6 +25,10 @@ func (r *RejectPlan) UpdateEval(eval *structs.Evaluation) error {
return nil
}
func (r *RejectPlan) CreateEval(*structs.Evaluation) error {
return nil
}
// Harness is a lightweight testing harness for schedulers.
// It manages a state store copy and provides the planner
// interface. It can be extended for various testing uses.
......@@ -34,8 +38,9 @@ type Harness struct {
Planner Planner
planLock sync.Mutex
Plans []*structs.Plan
Evals []*structs.Evaluation
Plans []*structs.Plan
Evals []*structs.Evaluation
CreateEvals []*structs.Evaluation
nextIndex uint64
nextIndexLock sync.Mutex
......@@ -108,6 +113,21 @@ func (h *Harness) UpdateEval(eval *structs.Evaluation) error {
return nil
}
func (h *Harness) CreateEval(eval *structs.Evaluation) error {
// Ensure sequential plan application
h.planLock.Lock()
defer h.planLock.Unlock()
// Store the eval
h.CreateEvals = append(h.CreateEvals, eval)
// Check for custom planner
if h.Planner != nil {
return h.Planner.CreateEval(eval)
}
return nil
}
// NextIndex returns the next index
func (h *Harness) NextIndex() uint64 {
h.nextIndexLock.Lock()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment