Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
1b2cb123
Commit
1b2cb123
authored
9 years ago
by
Armon Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
scheduler: Adding CreateEval to Planner
parent
d0cf06a8
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scheduler/scheduler.go
+4
-0
scheduler/scheduler.go
scheduler/scheduler_test.go
+22
-2
scheduler/scheduler_test.go
with
26 additions
and
2 deletions
+26
-2
scheduler/scheduler.go
+
4
-
0
View file @
1b2cb123
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
scheduler/scheduler_test.go
+
22
-
2
View file @
1b2cb123
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help