formatted code

This commit is contained in:
Pradyumna Kaushik 2017-01-14 17:22:15 -05:00
parent 6798807a0b
commit 65263426b4
2 changed files with 22 additions and 23 deletions

View file

@ -8,10 +8,10 @@ import (
"github.com/mesos/mesos-go/mesosutil" "github.com/mesos/mesos-go/mesosutil"
sched "github.com/mesos/mesos-go/scheduler" sched "github.com/mesos/mesos-go/scheduler"
"log" "log"
"os"
"sort"
"strings" "strings"
"time" "time"
"sort"
"os"
) )
// electron scheduler implements the Scheduler interface // electron scheduler implements the Scheduler interface
@ -58,7 +58,7 @@ func NewFirstFitSortedWattsClassMapWatts(tasks []def.Task, ignoreWatts bool, sch
PCPLog: make(chan struct{}), PCPLog: make(chan struct{}),
running: make(map[string]map[string]bool), running: make(map[string]map[string]bool),
RecordPCP: false, RecordPCP: false,
schedTrace: log.New(logFile, "", log.LstdFlags), schedTrace: log.New(logFile, "", log.LstdFlags),
} }
return s return s
} }
@ -201,4 +201,4 @@ func (s *FirstFitSortedWattsClassMapWatts) StatusUpdate(driver sched.SchedulerDr
} }
} }
log.Printf("DONE: Task status [%s] for task [%s]", NameFor(status.State), *status.TaskId.Value) log.Printf("DONE: Task status [%s] for task [%s]", NameFor(status.State), *status.TaskId.Value)
} }

View file

@ -1,36 +1,36 @@
package schedulers package schedulers
import ( import (
"bitbucket.org/sunybingcloud/electron/constants"
"bitbucket.org/sunybingcloud/electron/def" "bitbucket.org/sunybingcloud/electron/def"
"bitbucket.org/sunybingcloud/electron/pcp"
"bitbucket.org/sunybingcloud/electron/rapl"
"fmt" "fmt"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
mesos "github.com/mesos/mesos-go/mesosproto" mesos "github.com/mesos/mesos-go/mesosproto"
"github.com/mesos/mesos-go/mesosutil" "github.com/mesos/mesos-go/mesosutil"
sched "github.com/mesos/mesos-go/scheduler" sched "github.com/mesos/mesos-go/scheduler"
"log" "log"
"strings"
"time"
"sort"
"os"
"bitbucket.org/sunybingcloud/electron/pcp"
"sync"
"math" "math"
"bitbucket.org/sunybingcloud/electron/constants" "os"
"bitbucket.org/sunybingcloud/electron/rapl" "sort"
"strings"
"sync"
"time"
) )
// electron scheduler implements the Scheduler interface // electron scheduler implements the Scheduler interface
type FirstFitSortedWattsClassMapWattsProacCC struct { type FirstFitSortedWattsClassMapWattsProacCC struct {
base // Type embedded to inherit common features. base // Type embedded to inherit common features.
tasksCreated int tasksCreated int
tasksRunning int tasksRunning int
tasks []def.Task tasks []def.Task
metrics map[string]def.Metric metrics map[string]def.Metric
running map[string]map[string]bool running map[string]map[string]bool
taskMonitor map[string][]def.Task taskMonitor map[string][]def.Task
availablePower map[string]float64 availablePower map[string]float64
totalPower map[string]float64 totalPower map[string]float64
ignoreWatts bool ignoreWatts bool
capper *pcp.ClusterwideCapper capper *pcp.ClusterwideCapper
ticker *time.Ticker ticker *time.Ticker
recapTicker *time.Ticker recapTicker *time.Ticker
@ -80,7 +80,6 @@ func NewFirstFitSortedWattsClassMapWattsProacCC(tasks []def.Task, ignoreWatts bo
isCapping: false, isCapping: false,
isRecapping: false, isRecapping: false,
schedTrace: log.New(logFile, "", log.LstdFlags), schedTrace: log.New(logFile, "", log.LstdFlags),
} }
return s return s
} }
@ -88,7 +87,7 @@ func NewFirstFitSortedWattsClassMapWattsProacCC(tasks []def.Task, ignoreWatts bo
// mutex // mutex
var ffswClassMapWattsProacCCMutex sync.Mutex var ffswClassMapWattsProacCCMutex sync.Mutex
func (s *FirstFitSortedWattsClassMapWattsProacCC) newTask(offer *mesos.Offer, task def.Task, newTaskClass string) *mesos.TaskInfo { func (s *FirstFitSortedWattsClassMapWattsProacCC) newTask(offer *mesos.Offer, task def.Task, newTaskClass string) *mesos.TaskInfo {
taskName := fmt.Sprintf("%s-%d", task.Name, *task.Instances) taskName := fmt.Sprintf("%s-%d", task.Name, *task.Instances)
s.tasksCreated++ s.tasksCreated++
@ -154,7 +153,7 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) Disconnected(sched.SchedulerDr
} }
// go routine to cap the entire cluster in regular intervals of time // go routine to cap the entire cluster in regular intervals of time
var ffswClassMapWattsProacCCCapValue = 0.0 // initial value to indicate that we haven't capped the cluster yet. var ffswClassMapWattsProacCCCapValue = 0.0 // initial value to indicate that we haven't capped the cluster yet.
var ffswClassMapWattsProacCCNewCapValue = 0.0 // newly computed cap value var ffswClassMapWattsProacCCNewCapValue = 0.0 // newly computed cap value
func (s *FirstFitSortedWattsClassMapWattsProacCC) startCapping() { func (s *FirstFitSortedWattsClassMapWattsProacCC) startCapping() {
go func() { go func() {
@ -378,7 +377,7 @@ func (s *FirstFitSortedWattsClassMapWattsProacCC) StatusUpdate(driver sched.Sche
if s.tasksRunning == 0 { if s.tasksRunning == 0 {
select { select {
case <-s.Shutdown: case <-s.Shutdown:
// Need to stop the cluster-wide recapping // Need to stop the cluster-wide recapping
s.stopRecapping() s.stopRecapping()
close(s.Done) close(s.Done)
default: default: