Fixed the comments to be capitalized at the start and also terminate with a period.
This commit is contained in:
parent
577120ae7c
commit
b807625b78
19 changed files with 194 additions and 201 deletions
|
@ -24,7 +24,7 @@ func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
|
|||
return cpus, mem, watts
|
||||
}
|
||||
|
||||
// Determine the power class of the host in the offer
|
||||
// Determine the power class of the host in the offer.
|
||||
func PowerClass(offer *mesos.Offer) string {
|
||||
var powerClass string
|
||||
for _, attr := range offer.GetAttributes() {
|
||||
|
@ -36,7 +36,7 @@ func PowerClass(offer *mesos.Offer) string {
|
|||
}
|
||||
|
||||
// Implements the sort.Sort interface to sort Offers based on CPU.
|
||||
// TODO: Have a generic sorter that sorts based on a defined requirement (CPU, RAM, DISK or Watts)
|
||||
// TODO: Have a generic sorter that sorts based on a defined requirement (CPU, RAM, DISK or Watts).
|
||||
type OffersSorter []*mesos.Offer
|
||||
|
||||
func (offersSorter OffersSorter) Len() int {
|
||||
|
@ -48,9 +48,9 @@ func (offersSorter OffersSorter) Swap(i, j int) {
|
|||
}
|
||||
|
||||
func (offersSorter OffersSorter) Less(i, j int) bool {
|
||||
// getting CPU resource availability of offersSorter[i]
|
||||
// Getting CPU resource availability of offersSorter[i].
|
||||
cpu1, _, _ := OfferAgg(offersSorter[i])
|
||||
// getting CPU resource availability of offersSorter[j]
|
||||
// Getting CPU resource availability of offersSorter[j].
|
||||
cpu2, _, _ := OfferAgg(offersSorter[j])
|
||||
return cpu1 <= cpu2
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
type Interface interface {
|
||||
// Value to use for running average calculation.
|
||||
Val() float64
|
||||
// Unique ID
|
||||
// Unique ID.
|
||||
ID() string
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ type runningAverageCalculator struct {
|
|||
currentSum float64
|
||||
}
|
||||
|
||||
// singleton instance
|
||||
// Singleton instance.
|
||||
var racSingleton *runningAverageCalculator
|
||||
|
||||
// return single instance
|
||||
// Return single instance.
|
||||
func getInstance(curSum float64, wSize int) *runningAverageCalculator {
|
||||
if racSingleton == nil {
|
||||
racSingleton = &runningAverageCalculator{
|
||||
|
@ -51,12 +51,12 @@ func (rac *runningAverageCalculator) calculate(data Interface) float64 {
|
|||
rac.considerationWindow.PushBack(data)
|
||||
rac.currentSum += data.Val()
|
||||
} else {
|
||||
// removing the element at the front of the window.
|
||||
// Removing the element at the front of the window.
|
||||
elementToRemove := rac.considerationWindow.Front()
|
||||
rac.currentSum -= elementToRemove.Value.(Interface).Val()
|
||||
rac.considerationWindow.Remove(elementToRemove)
|
||||
|
||||
// adding new element to the window
|
||||
// Adding new element to the window.
|
||||
rac.considerationWindow.PushBack(data)
|
||||
rac.currentSum += data.Val()
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func (rac *runningAverageCalculator) calculate(data Interface) float64 {
|
|||
|
||||
/*
|
||||
If element with given ID present in the window, then remove it and return (removeElement, nil).
|
||||
Else, return (nil, error)
|
||||
Else, return (nil, error).
|
||||
*/
|
||||
func (rac *runningAverageCalculator) removeFromWindow(id string) (interface{}, error) {
|
||||
for element := rac.considerationWindow.Front(); element != nil; element = element.Next() {
|
||||
|
@ -86,7 +86,7 @@ func Calc(data Interface, windowSize int) float64 {
|
|||
|
||||
// Remove element from the window if it is present.
|
||||
func Remove(id string) (interface{}, error) {
|
||||
// checking if racSingleton has been instantiated
|
||||
// Checking if racSingleton has been instantiated.
|
||||
if racSingleton == nil {
|
||||
return nil, errors.New("Error: Not instantiated. Please call Init() to instantiate.")
|
||||
} else {
|
||||
|
@ -94,9 +94,9 @@ func Remove(id string) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// initialize the parameters of the running average calculator
|
||||
// Initialize the parameters of the running average calculator.
|
||||
func Init() {
|
||||
// checking to see if racSingleton needs top be instantiated
|
||||
// Checking to see if racSingleton needs top be instantiated.
|
||||
if racSingleton == nil {
|
||||
racSingleton = getInstance(0.0, 0)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package utilities
|
|||
|
||||
/*
|
||||
The Pair and PairList have been taken from google groups forum,
|
||||
https://groups.google.com/forum/#!topic/golang-nuts/FT7cjmcL7gw
|
||||
https://groups.google.com/forum/#!topic/golang-nuts/FT7cjmcL7gw.
|
||||
*/
|
||||
|
||||
// Utility struct that helps in sorting map[string]float64 by value.
|
||||
|
@ -14,7 +14,7 @@ type Pair struct {
|
|||
// A slice of pairs that implements the sort.Interface to sort by value.
|
||||
type PairList []Pair
|
||||
|
||||
// Convert map[string]float64 to PairList
|
||||
// Convert map[string]float64 to PairList.
|
||||
func GetPairList(m map[string]float64) PairList {
|
||||
pl := PairList{}
|
||||
for k, v := range m {
|
||||
|
@ -23,17 +23,17 @@ func GetPairList(m map[string]float64) PairList {
|
|||
return pl
|
||||
}
|
||||
|
||||
// Swap pairs in the PairList
|
||||
// Swap pairs in the PairList.
|
||||
func (plist PairList) Swap(i, j int) {
|
||||
plist[i], plist[j] = plist[j], plist[i]
|
||||
}
|
||||
|
||||
// function to return the length of the pairlist.
|
||||
// Get the length of the pairlist.
|
||||
func (plist PairList) Len() int {
|
||||
return len(plist)
|
||||
}
|
||||
|
||||
// function to compare two elements in pairlist.
|
||||
// Compare two elements in pairlist.
|
||||
func (plist PairList) Less(i, j int) bool {
|
||||
return plist[i].Value < plist[j].Value
|
||||
}
|
||||
|
|
Reference in a new issue