Replaced old usage with new library
This commit is contained in:
parent
c27aba895b
commit
40efeca04b
3 changed files with 22 additions and 11 deletions
|
@ -21,11 +21,13 @@ package def
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/mash/gokmeans"
|
"github.com/mash/gokmeans"
|
||||||
"github.com/montanaflynn/stats"
|
"github.com/montanaflynn/stats"
|
||||||
|
"github.com/spdfg/elektron/elektronLogging"
|
||||||
|
elekLogT "github.com/spdfg/elektron/elektronLogging/types"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Information about a cluster of tasks.
|
// Information about a cluster of tasks.
|
||||||
|
@ -50,7 +52,8 @@ func (tc TasksToClassify) taskObservationCalculator(task Task) []float64 {
|
||||||
} else if task.Watts != 0.0 {
|
} else if task.Watts != 0.0 {
|
||||||
return []float64{task.Watts}
|
return []float64{task.Watts}
|
||||||
} else {
|
} else {
|
||||||
log.Fatal("Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload.")
|
elektronLogging.ElektronLog.Log(elekLogT.ERROR, log.FatalLevel,
|
||||||
|
log.Fields {}, "Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload")
|
||||||
return []float64{0.0} // Won't reach here.
|
return []float64{0.0} // Won't reach here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +108,8 @@ func clusterSizeAvgMMMPU(tasks []Task, taskObservation func(task Task) []float64
|
||||||
} else {
|
} else {
|
||||||
// skip this value
|
// skip this value
|
||||||
// there is an error in the task config.
|
// there is an error in the task config.
|
||||||
log.Println(err)
|
elektronLogging.ElektronLog.Log(elekLogT.ERROR, log.ErrorLevel,
|
||||||
|
log.Fields {}, fmt.Sprintf("%s",err))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// There is only one observation for the task.
|
// There is only one observation for the task.
|
||||||
|
|
|
@ -19,11 +19,13 @@
|
||||||
package offerUtils
|
package offerUtils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"fmt"
|
||||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||||
"github.com/spdfg/elektron/constants"
|
"github.com/spdfg/elektron/constants"
|
||||||
|
"github.com/spdfg/elektron/elektronLogging"
|
||||||
|
elekLogT "github.com/spdfg/elektron/elektronLogging/types"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
|
func OfferAgg(offer *mesos.Offer) (float64, float64, float64) {
|
||||||
|
@ -88,12 +90,14 @@ func UpdateEnvironment(offer *mesos.Offer) {
|
||||||
var host = offer.GetHostname()
|
var host = offer.GetHostname()
|
||||||
// If this host is not present in the set of hosts.
|
// If this host is not present in the set of hosts.
|
||||||
if _, ok := constants.Hosts[host]; !ok {
|
if _, ok := constants.Hosts[host]; !ok {
|
||||||
log.Printf("New host detected. Adding host [%s]", host)
|
elektronLogging.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel,
|
||||||
|
log.Fields {"Adding host" : fmt.Sprintf("%s",host)}, "New host detected")
|
||||||
// Add this host.
|
// Add this host.
|
||||||
constants.Hosts[host] = struct{}{}
|
constants.Hosts[host] = struct{}{}
|
||||||
// Get the power class of this host.
|
// Get the power class of this host.
|
||||||
class := PowerClass(offer)
|
class := PowerClass(offer)
|
||||||
log.Printf("Registering the power class... Host [%s] --> PowerClass [%s]", host, class)
|
elektronLogging.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel,
|
||||||
|
log.Fields {"host" : fmt.Sprintf("%s",host), "PowerClass" : fmt.Sprintf("%s", class)}, "Registering the power class...")
|
||||||
// If new power class, register the power class.
|
// If new power class, register the power class.
|
||||||
if _, ok := constants.PowerClasses[class]; !ok {
|
if _, ok := constants.PowerClasses[class]; !ok {
|
||||||
constants.PowerClasses[class] = make(map[string]struct{})
|
constants.PowerClasses[class] = make(map[string]struct{})
|
||||||
|
|
|
@ -19,10 +19,12 @@
|
||||||
package schedUtils
|
package schedUtils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spdfg/elektron/def"
|
"github.com/spdfg/elektron/def"
|
||||||
"github.com/spdfg/elektron/utilities"
|
"github.com/spdfg/elektron/utilities"
|
||||||
|
"github.com/spdfg/elektron/elektronLogging"
|
||||||
|
elekLogT "github.com/spdfg/elektron/elektronLogging/types"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Criteria for resizing the scheduling window.
|
// Criteria for resizing the scheduling window.
|
||||||
|
@ -77,8 +79,9 @@ func (s *fillNextOfferCycle) apply(taskQueue []def.Task) (int, int) {
|
||||||
for _, task := range taskQueue {
|
for _, task := range taskQueue {
|
||||||
numberOfTasksTraversed++
|
numberOfTasksTraversed++
|
||||||
for i := *task.Instances; i > 0; i-- {
|
for i := *task.Instances; i > 0; i-- {
|
||||||
log.Printf("Checking if Instance #%d of Task[%s] can be scheduled "+
|
elektronLogging.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel,
|
||||||
"during the next offer cycle...", i, task.Name)
|
log.Fields {}, fmt.Sprintf("Checking if Instance #%d of Task[%s] can be scheduled "+
|
||||||
|
"during the next offer cycle...", i, task.Name))
|
||||||
if canSchedule(task) {
|
if canSchedule(task) {
|
||||||
filledCPU += task.CPU
|
filledCPU += task.CPU
|
||||||
filledRAM += task.RAM
|
filledRAM += task.RAM
|
||||||
|
|
Reference in a new issue