Merged in genericTaskSorter (pull request #18)

GenericTaskSorter

Approved-by: Renan DelValle <rdelval1@binghamton.edu>
Approved-by: ajain13 <ajain13@binghamton.edu>
This commit is contained in:
Pradyumna Kaushik 2017-09-05 18:29:13 +00:00
commit dc279801b7
3 changed files with 23 additions and 2 deletions

View file

@ -16,11 +16,11 @@ To Do:
* Have a centralised logFile that can be filtered by identifier. All electron logs should go into this file.
* Make def.Task an interface for further modularization and flexibility.
* Convert def#WattsToConsider(...) to be a receiver of def.Task and change the name of it to Watts(...).
* Have a generic sorter for task resources instead of having one for each kind of resource.
* **Critical** -- Add software requirements to the README.md (Mesos version, RAPL version, PCP version, Go version...)
* **Critical** -- Retrofit to use Go 1.8 sorting techniques. Use def/taskUtils.go for reference.
* Handle powerclass not configured on a node condition. As of now, an assumption is made that the powerclass is configured
* Refine the sorting algorithm that sorts the clusters of tasks retrieved using the kmeans algorithm. This also involves the reduction in time complexity of the same.
* Use the generic task sorter in def/taskUtils.go to sort the tasks based on CPU or RAM etc. Remove the existing sorters present in def/task.go.
for all the nodes.
**Requires [Performance Co-Pilot](http://pcp.io/) tool pmdumptext to be installed on the

13
def/sortingCriteria.go Normal file
View file

@ -0,0 +1,13 @@
package def
// the sortBy function that takes a task reference and returns the resource to consider when sorting.
type sortBy func(task *Task) float64
// Possible Sorting Criteria
// Each holds a closure that fetches the required resource from the
// given task reference.
var (
SortByCPU = func(task *Task) float64 { return task.CPU }
SortByRAM = func(task *Task) float64 { return task.RAM }
SortByWatts = func(task *Task) float64 { return task.Watts }
)

View file

@ -2,8 +2,8 @@ package def
import (
"github.com/mdesenfants/gokmeans"
"sort"
"log"
"sort"
)
// Information about a cluster of tasks
@ -114,3 +114,11 @@ func labelAndOrder(clusters map[int][]Task, numberOfClusters int, taskObservatio
})
return sizedClusters
}
// Generic Task Sorter.
// Be able to sort an array of tasks based on any of the tasks' resources.
func SortTasks(ts []Task, sb sortBy) {
sort.SliceStable(ts, func(i, j int) bool {
return sb(&ts[i]) <= sb(&ts[j])
})
}