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
|
||||
var singleton_capper *clusterwideCapper
|
||||
|
||||
// Retrieve the singleton instance of clusterwideCapper.
|
||||
func getClusterwideCapperInstance() *clusterwideCapper {
|
||||
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)
|
||||
ratios := []float64{}
|
||||
for _, tpower := range total_power {
|
||||
ratios = append(ratios, (average/tpower) * 100)
|
||||
ratios = append(ratios, (average/tpower)*100)
|
||||
}
|
||||
sort.Float64s(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
|
||||
j := high
|
||||
// calculating the pivot
|
||||
pivot_index := low + (high - low)/2
|
||||
pivot_index := low + (high-low)/2
|
||||
pivot := tasks_to_sort[pivot_index]
|
||||
for i <= j {
|
||||
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)
|
||||
for host, tpower := range total_power {
|
||||
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 {
|
||||
// We don't consider this host for the computation of the cluster wide cap.
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package schedulers
|
||||
|
||||
import (
|
||||
"bitbucket.org/sunybingcloud/electron/def"
|
||||
"bitbucket.org/sunybingcloud/electron/constants"
|
||||
"bitbucket.org/sunybingcloud/electron/def"
|
||||
"bitbucket.org/sunybingcloud/electron/rapl"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
@ -59,7 +59,7 @@ type ProactiveClusterwideCapFCFS struct {
|
|||
|
||||
// New electron scheduler.
|
||||
func NewProactiveClusterwideCapFCFS(tasks []def.Task, ignoreWatts bool) *ProactiveClusterwideCapFCFS {
|
||||
s := &ProactiveClusterwideCapFCFS {
|
||||
s := &ProactiveClusterwideCapFCFS{
|
||||
tasks: tasks,
|
||||
ignoreWatts: ignoreWatts,
|
||||
Shutdown: make(chan struct{}),
|
||||
|
@ -153,14 +153,14 @@ func (s *ProactiveClusterwideCapFCFS) startCapping() {
|
|||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <- s.ticker.C:
|
||||
case <-s.ticker.C:
|
||||
// Need to cap the cluster to the currentCapValue.
|
||||
if currentCapValue > 0.0 {
|
||||
//mutex.Lock()
|
||||
//s.lock.Lock()
|
||||
for _, host := range constants.Hosts {
|
||||
// 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)
|
||||
} else {
|
||||
fmt.Printf("Successfully capped %s to %f%\n", host, currentCapValue)
|
||||
|
|
Reference in a new issue