formatted the code
This commit is contained in:
parent
4cc1dd8e63
commit
7522cf9879
2 changed files with 397 additions and 396 deletions
|
@ -36,6 +36,7 @@ func newClusterwideCapper() *clusterwideCapper {
|
||||||
|
|
||||||
// Singleton instance of clusterwideCapper
|
// Singleton instance of clusterwideCapper
|
||||||
var singleton_capper *clusterwideCapper
|
var singleton_capper *clusterwideCapper
|
||||||
|
|
||||||
// Retrieve the singleton instance of clusterwideCapper.
|
// Retrieve the singleton instance of clusterwideCapper.
|
||||||
func getClusterwideCapperInstance() *clusterwideCapper {
|
func getClusterwideCapperInstance() *clusterwideCapper {
|
||||||
if singleton_capper == nil {
|
if singleton_capper == nil {
|
||||||
|
@ -142,7 +143,7 @@ func (capper clusterwideCapper) recap(total_power map[string]float64,
|
||||||
average := total_allocated_power / float64(total_running_tasks)
|
average := total_allocated_power / float64(total_running_tasks)
|
||||||
ratios := []float64{}
|
ratios := []float64{}
|
||||||
for _, tpower := range total_power {
|
for _, tpower := range total_power {
|
||||||
ratios = append(ratios, (average/tpower) * 100)
|
ratios = append(ratios, (average/tpower)*100)
|
||||||
}
|
}
|
||||||
sort.Float64s(ratios)
|
sort.Float64s(ratios)
|
||||||
median, err := stats.Median(ratios)
|
median, err := stats.Median(ratios)
|
||||||
|
@ -158,7 +159,7 @@ func (capper clusterwideCapper) quick_sort(low int, high int, tasks_to_sort []*d
|
||||||
i := low
|
i := low
|
||||||
j := high
|
j := high
|
||||||
// calculating the pivot
|
// calculating the pivot
|
||||||
pivot_index := low + (high - low)/2
|
pivot_index := low + (high-low)/2
|
||||||
pivot := tasks_to_sort[pivot_index]
|
pivot := tasks_to_sort[pivot_index]
|
||||||
for i <= j {
|
for i <= j {
|
||||||
for tasks_to_sort[i].Watts < pivot.Watts {
|
for tasks_to_sort[i].Watts < pivot.Watts {
|
||||||
|
@ -261,7 +262,7 @@ func (capper clusterwideCapper) fcfsDetermineCap(total_power map[string]float64,
|
||||||
running_average_to_total_power_percentage := make(map[string]float64)
|
running_average_to_total_power_percentage := make(map[string]float64)
|
||||||
for host, tpower := range total_power {
|
for host, tpower := range total_power {
|
||||||
if tpower >= running_average {
|
if tpower >= running_average {
|
||||||
running_average_to_total_power_percentage[host] = (running_average/tpower) * 100
|
running_average_to_total_power_percentage[host] = (running_average / tpower) * 100
|
||||||
} else {
|
} else {
|
||||||
// We don't consider this host for the computation of the cluster wide cap.
|
// We don't consider this host for the computation of the cluster wide cap.
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package schedulers
|
package schedulers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/electron/def"
|
|
||||||
"bitbucket.org/sunybingcloud/electron/constants"
|
"bitbucket.org/sunybingcloud/electron/constants"
|
||||||
|
"bitbucket.org/sunybingcloud/electron/def"
|
||||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
@ -59,7 +59,7 @@ type ProactiveClusterwideCapFCFS struct {
|
||||||
|
|
||||||
// New electron scheduler.
|
// New electron scheduler.
|
||||||
func NewProactiveClusterwideCapFCFS(tasks []def.Task, ignoreWatts bool) *ProactiveClusterwideCapFCFS {
|
func NewProactiveClusterwideCapFCFS(tasks []def.Task, ignoreWatts bool) *ProactiveClusterwideCapFCFS {
|
||||||
s := &ProactiveClusterwideCapFCFS {
|
s := &ProactiveClusterwideCapFCFS{
|
||||||
tasks: tasks,
|
tasks: tasks,
|
||||||
ignoreWatts: ignoreWatts,
|
ignoreWatts: ignoreWatts,
|
||||||
Shutdown: make(chan struct{}),
|
Shutdown: make(chan struct{}),
|
||||||
|
@ -153,14 +153,14 @@ func (s *ProactiveClusterwideCapFCFS) startCapping() {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <- s.ticker.C:
|
case <-s.ticker.C:
|
||||||
// Need to cap the cluster to the currentCapValue.
|
// Need to cap the cluster to the currentCapValue.
|
||||||
if currentCapValue > 0.0 {
|
if currentCapValue > 0.0 {
|
||||||
//mutex.Lock()
|
//mutex.Lock()
|
||||||
//s.lock.Lock()
|
//s.lock.Lock()
|
||||||
for _, host := range constants.Hosts {
|
for _, host := range constants.Hosts {
|
||||||
// Rounding curreCapValue to the nearest int.
|
// Rounding curreCapValue to the nearest int.
|
||||||
if err := rapl.Cap(host, "rapl", int(math.Floor(currentCapValue + 0.5))); err != nil {
|
if err := rapl.Cap(host, "rapl", int(math.Floor(currentCapValue+0.5))); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Successfully capped %s to %f%\n", host, currentCapValue)
|
fmt.Printf("Successfully capped %s to %f%\n", host, currentCapValue)
|
||||||
|
|
Reference in a new issue