diff --git a/def/taskUtils.go b/def/taskUtils.go index cb93afa..9556e06 100644 --- a/def/taskUtils.go +++ b/def/taskUtils.go @@ -26,7 +26,7 @@ import ( "github.com/mash/gokmeans" "github.com/montanaflynn/stats" log "github.com/sirupsen/logrus" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" ) @@ -52,7 +52,7 @@ func (tc TasksToClassify) taskObservationCalculator(task Task) []float64 { } else if task.Watts != 0.0 { return []float64{task.Watts} } else { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, log.FatalLevel, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.FatalLevel, log.Fields{}, "Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload") return []float64{0.0} // Won't reach here. } @@ -108,7 +108,7 @@ func clusterSizeAvgMMMPU(tasks []Task, taskObservation func(task Task) []float64 } else { // skip this value // there is an error in the task config. - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{}, fmt.Sprintf("%s", err)) } } else { diff --git a/pcp/pcp.go b/pcp/pcp.go index f1ff505..010cf09 100644 --- a/pcp/pcp.go +++ b/pcp/pcp.go @@ -25,7 +25,7 @@ import ( "time" log "github.com/sirupsen/logrus" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogT "github.com/spdfg/elektron/elektronLogging/types" ) @@ -47,7 +47,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) { scanner.Scan() // Write to logfile - elektronLogging.ElektronLog.Log(elekLogT.PCP, + elekLog.ElektronLog.Log(elekLogT.PCP, log.InfoLevel, log.Fields{}, scanner.Text()) @@ -60,7 +60,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) { text := scanner.Text() if *logging { - elektronLogging.ElektronLog.Log(elekLogT.PCP, + elekLog.ElektronLog.Log(elekLogT.PCP, log.InfoLevel, log.Fields{}, text) } @@ -69,7 +69,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) { } }(logging) - elektronLogging.ElektronLog.Log(elekLogT.GENERAL, + elekLog.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel, log.Fields{}, "PCP logging started") @@ -81,7 +81,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) { select { case <-quit: - elektronLogging.ElektronLog.Log(elekLogT.GENERAL, + elekLog.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel, log.Fields{}, "Stopping PCP logging in 5 seconds") time.Sleep(5 * time.Second) diff --git a/powerCap/extrema.go b/powerCap/extrema.go index 83e76b4..2e202eb 100644 --- a/powerCap/extrema.go +++ b/powerCap/extrema.go @@ -30,7 +30,7 @@ import ( "time" log "github.com/sirupsen/logrus" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "github.com/spdfg/elektron/pcp" "github.com/spdfg/elektron/rapl" @@ -43,7 +43,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} if hiThreshold < loThreshold { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "High threshold is lower than low threshold!") } @@ -61,7 +61,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh scanner.Scan() // Write to logfile - elektronLogging.ElektronLog.Log(elekLogTypes.PCP, + elekLog.ElektronLog.Log(elekLogTypes.PCP, log.InfoLevel, log.Fields{}, scanner.Text()) @@ -99,14 +99,14 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh if *logging { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Logging PCP...") text := scanner.Text() split := strings.Split(text, ",") - elektronLogging.ElektronLog.Log(elekLogTypes.PCP, + elekLog.ElektronLog.Log(elekLogTypes.PCP, log.InfoLevel, log.Fields{}, text) @@ -119,7 +119,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh powerHistories[host].Value = power powerHistories[host] = powerHistories[host].Next() - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Host": fmt.Sprintf("%s", indexToHost[powerIndex]), "Power": fmt.Sprintf("%f", (power * pcp.RAPLUnits))}, "") @@ -133,14 +133,14 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Total power": fmt.Sprintf("%f %d", clusterPower, clusterPowerHist.Len()), "Sec Avg": fmt.Sprintf("%f", clusterMean)}, "") if clusterMean > hiThreshold { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Need to cap a node") // Create statics for all victims and choose one to cap @@ -163,12 +163,12 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh if !cappedHosts[victim.Host] { cappedHosts[victim.Host] = true orderCapped = append(orderCapped, victim.Host) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Capping Victim": fmt.Sprintf("%s", victim.Host), "Avg. Wattage": fmt.Sprintf("%f", victim.Watts*pcp.RAPLUnits)}, "") if err := rapl.Cap(victim.Host, "rapl", 50); err != nil { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{}, "Error capping host") } @@ -184,11 +184,11 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh cappedHosts[host] = false // User RAPL package to send uncap. log.Printf("Uncapping host %s", host) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Uncapped host": host}, "") if err := rapl.Cap(host, "rapl", 100); err != nil { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{}, "Error capping host") } @@ -200,7 +200,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh } }(logging, hiThreshold, loThreshold) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "PCP logging started") @@ -212,7 +212,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh select { case <-quit: - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Stopping PCP logging in 5 seconds") time.Sleep(5 * time.Second) diff --git a/powerCap/progressiveExtrema.go b/powerCap/progressiveExtrema.go index 034376f..9fba626 100644 --- a/powerCap/progressiveExtrema.go +++ b/powerCap/progressiveExtrema.go @@ -32,7 +32,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/constants" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "github.com/spdfg/elektron/pcp" "github.com/spdfg/elektron/rapl" @@ -56,7 +56,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} if hiThreshold < loThreshold { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "High threshold is lower than low threshold!") } @@ -74,7 +74,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh scanner.Scan() // Write to logfile - elektronLogging.ElektronLog.Log(elekLogTypes.PCP, + elekLog.ElektronLog.Log(elekLogTypes.PCP, log.InfoLevel, log.Fields{}, scanner.Text()) @@ -115,13 +115,13 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh for scanner.Scan() { if *logging { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Logging PCP...") split := strings.Split(scanner.Text(), ",") text := scanner.Text() - elektronLogging.ElektronLog.Log(elekLogTypes.PCP, + elekLog.ElektronLog.Log(elekLogTypes.PCP, log.InfoLevel, log.Fields{}, text) @@ -134,7 +134,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh powerHistories[host].Value = power powerHistories[host] = powerHistories[host].Next() - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Host": fmt.Sprintf("%s", indexToHost[powerIndex]), "Power": fmt.Sprintf("%f", (power * pcp.RAPLUnits))}, "") @@ -147,22 +147,22 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Total power": fmt.Sprintf("%f %d", clusterPower, clusterPowerHist.Len()), "Sec Avg": fmt.Sprintf("%f", clusterMean)}, "") if clusterMean >= hiThreshold { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Need to cap a node") - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Cap values of capped victims": fmt.Sprintf("%v", cappedVictims)}, "") - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Cap values of victims to uncap": fmt.Sprintf("%v", orderCappedVictims)}, "") // Create statics for all victims and choose one to cap @@ -192,12 +192,12 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh // Need to cap this victim. if err := rapl.Cap(victims[i].Host, "rapl", 50.0); err != nil { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{"Error capping host": fmt.Sprintf("%s", victims[i].Host)}, "") } else { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, fmt.Sprintf("Capped host[%s] at %f", victims[i].Host, 50.0)) // Keeping track of this victim and it's cap value @@ -223,12 +223,12 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh newCapValue := getNextCapValue(capValue, 2) if err := rapl.Cap(alreadyCappedHosts[i], "rapl", newCapValue); err != nil { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{"Error capping host": fmt.Sprintf("%s", alreadyCappedHosts[i])}, "") } else { // Successful cap - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, fmt.Sprintf("Capped host[%s] at %f", alreadyCappedHosts[i], newCapValue)) // Checking whether this victim can be capped further @@ -253,7 +253,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh } } if !canCapAlreadyCappedVictim { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "No Victim left to cap") } @@ -261,13 +261,13 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh } else if clusterMean < loThreshold { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Need to uncap a node") - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Cap values of capped victims": fmt.Sprintf("%v", cappedVictims)}, "") - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Cap values of victims to uncap": fmt.Sprintf("%v", orderCappedVictims)}, "") if len(orderCapped) > 0 { @@ -280,12 +280,12 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh newUncapValue := orderCappedVictims[hostToUncap] * 2.0 if err := rapl.Cap(hostToUncap, "rapl", newUncapValue); err != nil { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{"Error uncapping host": fmt.Sprintf("%s", hostToUncap)}, "") } else { // Successful uncap - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, fmt.Sprintf("Uncapped host[%s] to %f", hostToUncap, newUncapValue)) // Can we uncap this host further. If not, then we remove its entry from orderCapped @@ -308,7 +308,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh } } } else { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "No host staged for Uncapped") } @@ -319,7 +319,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh }(logging, hiThreshold, loThreshold) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "PCP logging started") if err := cmd.Start(); err != nil { @@ -330,7 +330,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh select { case <-quit: - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Stopping PCP logging in 5 seconds") time.Sleep(5 * time.Second) diff --git a/scheduler.go b/scheduler.go index a0d453d..76feeba 100644 --- a/scheduler.go +++ b/scheduler.go @@ -26,7 +26,7 @@ import ( sched "github.com/mesos/mesos-go/api/v0/scheduler" log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/def" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "github.com/spdfg/elektron/pcp" "github.com/spdfg/elektron/powerCap" @@ -223,7 +223,7 @@ func main() { if strings.Contains(*pcplogPrefix, "/") { log.Fatal("log file prefix should not contain '/'.") } - elektronLogging.BuildLogger(*pcplogPrefix) + elekLog.BuildLogger(*pcplogPrefix) // Starting PCP logging. if noPowercap { @@ -278,11 +278,11 @@ func main() { // Starting the scheduler driver. if status, err := driver.Run(); err != nil { - elektronLogging.ElektronLog.Log(elekLogTypes.ERROR, + elekLog.ElektronLog.Log(elekLogTypes.ERROR, log.ErrorLevel, log.Fields{"status": status.String(), "error": err.Error()}, "Framework stopped ") } - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "Exiting...") } diff --git a/schedulers/base.go b/schedulers/base.go index decec5c..b29edbf 100644 --- a/schedulers/base.go +++ b/schedulers/base.go @@ -30,7 +30,7 @@ import ( sched "github.com/mesos/mesos-go/api/v0/scheduler" log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/def" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "github.com/spdfg/elektron/utilities" "github.com/spdfg/elektron/utilities/schedUtils" @@ -251,10 +251,10 @@ func (s *BaseScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos func (s *BaseScheduler) LogTaskStarting(ts *def.Task, offer *mesos.Offer) { lmt := elekLogTypes.GENERAL if ts == nil { - elektronLogging.ElektronLog.Log(lmt, log.InfoLevel, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"host": fmt.Sprintf("%s", offer.GetHostname())}, "TASKS STARTING...") } else { - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"task": fmt.Sprintf("%s", ts.Name), "Instance": fmt.Sprintf("%d", *ts.Instances), "host": fmt.Sprintf("%s", offer.GetHostname())}, @@ -264,28 +264,28 @@ func (s *BaseScheduler) LogTaskStarting(ts *def.Task, offer *mesos.Offer) { func (s *BaseScheduler) LogTaskWattsConsideration(ts def.Task, host string, wattsToConsider float64) { lmt := elekLogTypes.GENERAL - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"task": ts.Name, "host": host, "Watts": fmt.Sprintf("%f", wattsToConsider)}, "Watts considered for ") } func (s *BaseScheduler) LogOffersReceived(offers []*mesos.Offer) { lmt := elekLogTypes.GENERAL - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"Resource offers received": fmt.Sprintf("%d", len(offers))}, "") } func (s *BaseScheduler) LogNoPendingTasksDeclineOffers(offer *mesos.Offer) { lmt := elekLogTypes.WARNING - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.WarnLevel, log.Fields{"DECLINING OFFER for host": fmt.Sprintf("%s", offer.GetHostname())}, "No tasks left to schedule ") } func (s *BaseScheduler) LogNumberOfRunningTasks() { lmt := elekLogTypes.GENERAL - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"Number of tasks still Running": fmt.Sprintf("%d", s.tasksRunning)}, "") } @@ -298,20 +298,20 @@ func (s *BaseScheduler) LogCoLocatedTasks(slaveID string) { buffer.WriteString(fmt.Sprintln(taskName)) } s.TasksRunningMutex.Unlock() - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"Colocated with": fmt.Sprintf("%s", buffer.String())}, "") } func (s *BaseScheduler) LogSchedTrace(taskToSchedule *mesos.TaskInfo, offer *mesos.Offer) { - elektronLogging.ElektronLog.Log(elekLogTypes.SCHED_TRACE, + elekLog.ElektronLog.Log(elekLogTypes.SCHED_TRACE, log.InfoLevel, log.Fields{offer.GetHostname(): fmt.Sprintf("%s", taskToSchedule.GetTaskId().GetValue())}, "") } func (s *BaseScheduler) LogTerminateScheduler() { lmt := elekLogTypes.GENERAL - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{}, "Done scheduling all tasks!") } @@ -321,28 +321,28 @@ func (s *BaseScheduler) LogInsufficientResourcesDeclineOffer(offer *mesos.Offer, lmt := elekLogTypes.WARNING buffer := bytes.Buffer{} buffer.WriteString(fmt.Sprintf("", offerResources...)) - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.WarnLevel, log.Fields{"Offer Resources": fmt.Sprintf("%s", buffer.String())}, "DECLINING OFFER... Offer has insufficient resources to launch a task") } func (s *BaseScheduler) LogOfferRescinded(offerID *mesos.OfferID) { lmt := elekLogTypes.ERROR - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.ErrorLevel, log.Fields{"OfferID": fmt.Sprintf("%s", offerID)}, "OFFER RESCINDED") } func (s *BaseScheduler) LogSlaveLost(slaveID *mesos.SlaveID) { lmt := elekLogTypes.ERROR - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.ErrorLevel, log.Fields{"SlaveID": fmt.Sprintf("%s", slaveID)}, "SLAVE LOST") } func (s *BaseScheduler) LogExecutorLost(executorID *mesos.ExecutorID, slaveID *mesos.SlaveID) { lmt := elekLogTypes.ERROR - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.ErrorLevel, log.Fields{"ExecutorID": fmt.Sprintf("%s", executorID), "SlaveID": fmt.Sprintf("%s", slaveID)}, "EXECUTOR LOST") } @@ -350,21 +350,21 @@ func (s *BaseScheduler) LogExecutorLost(executorID *mesos.ExecutorID, slaveID *m func (s *BaseScheduler) LogFrameworkMessage(executorID *mesos.ExecutorID, slaveID *mesos.SlaveID, message string) { lmt := elekLogTypes.GENERAL - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"Received Framework message from executor": executorID}, message) } func (s *BaseScheduler) LogMesosError(err string) { lmt := elekLogTypes.ERROR - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.ErrorLevel, log.Fields{"MESOS ERROR": fmt.Sprintf("%v", err)}, "") } func (s *BaseScheduler) LogElectronError(err error) { lmt := elekLogTypes.ERROR - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.ErrorLevel, log.Fields{"ELECTRON ERROR": fmt.Sprintf("%v", err)}, "") } @@ -372,21 +372,21 @@ func (s *BaseScheduler) LogElectronError(err error) { func (s *BaseScheduler) LogFrameworkRegistered(frameworkID *mesos.FrameworkID, masterInfo *mesos.MasterInfo) { lmt := elekLogTypes.SUCCESS - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"frameworkID": fmt.Sprintf("%s", frameworkID), "master": fmt.Sprintf("%s", masterInfo)}, "FRAMEWORK REGISTERED!") } func (s *BaseScheduler) LogFrameworkReregistered(masterInfo *mesos.MasterInfo) { lmt := elekLogTypes.GENERAL - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"master": fmt.Sprintf("%s", masterInfo)}, "Framework re-registered") } func (s *BaseScheduler) LogDisconnected() { lmt := elekLogTypes.WARNING - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.WarnLevel, log.Fields{}, "Framework disconnected with master") } @@ -402,14 +402,14 @@ func (s *BaseScheduler) LogTaskStatusUpdate(status *mesos.TaskStatus) { default: lmt = elekLogTypes.GENERAL } - elektronLogging.ElektronLog.Log(lmt, + elekLog.ElektronLog.Log(lmt, log.InfoLevel, log.Fields{"task": fmt.Sprintf("%s", *status.TaskId.Value), "state": NameFor(status.State)}, "Task Status received") } func (s *BaseScheduler) LogSchedPolicySwitch(name string, nextPolicy SchedPolicyState) { logSPS := func() { - elektronLogging.ElektronLog.Log(elekLogTypes.SPS, + elekLog.ElektronLog.Log(elekLogTypes.SPS, log.InfoLevel, log.Fields{"Name": name}, "") } @@ -420,14 +420,14 @@ func (s *BaseScheduler) LogSchedPolicySwitch(name string, nextPolicy SchedPolicy } // Logging the size of the scheduling window and the scheduling policy // that is going to schedule the tasks in the scheduling window. - elektronLogging.ElektronLog.Log(elekLogTypes.SCHED_WINDOW, + elekLog.ElektronLog.Log(elekLogTypes.SCHED_WINDOW, log.InfoLevel, log.Fields{"Window size": fmt.Sprintf("%d", s.schedWindowSize), "Name": name}, "") } func (s *BaseScheduler) LogClsfnAndTaskDistOverhead(overhead time.Duration) { // Logging the overhead in microseconds. - elektronLogging.ElektronLog.Log(elekLogTypes.CLSFN_TASKDIST_OVERHEAD, + elekLog.ElektronLog.Log(elekLogTypes.CLSFN_TASKDIST_OVERHEAD, log.InfoLevel, log.Fields{"Overhead in microseconds": fmt.Sprintf("%f", float64(overhead.Nanoseconds())/1000.0)}, "") } diff --git a/schedulers/helpers.go b/schedulers/helpers.go index 8a2f532..a8bfc2b 100644 --- a/schedulers/helpers.go +++ b/schedulers/helpers.go @@ -26,7 +26,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/constants" "github.com/spdfg/elektron/def" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "github.com/spdfg/elektron/utilities" "github.com/spdfg/elektron/utilities/mesosUtils" @@ -35,12 +35,12 @@ import ( func coLocated(tasks map[string]bool, s BaseScheduler) { for task := range tasks { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Task": task}, "") } - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{}, "---------------------") } diff --git a/schedulers/schedPolicy.go b/schedulers/schedPolicy.go index e4716d7..34f3b12 100644 --- a/schedulers/schedPolicy.go +++ b/schedulers/schedPolicy.go @@ -26,7 +26,7 @@ import ( sched "github.com/mesos/mesos-go/api/v0/scheduler" log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/def" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" ) @@ -90,7 +90,7 @@ func switchTaskDistBased(baseSchedRef *BaseScheduler) string { // Determine the distribution of tasks in the new scheduling window. taskDist, err := def.GetTaskDistributionInWindow(baseSchedRef.schedWindowSize, baseSchedRef.tasks) baseSchedRef.LogClsfnAndTaskDistOverhead(time.Now().Sub(startTime)) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Task Distribution": fmt.Sprintf("%f", taskDist)}, "Switching... ") if err != nil { diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index a3062d8..bad440a 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -23,7 +23,7 @@ import ( mesos "github.com/mesos/mesos-go/api/v0/mesosproto" log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/constants" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "strings" ) @@ -90,13 +90,13 @@ func UpdateEnvironment(offer *mesos.Offer) { var host = offer.GetHostname() // If this host is not present in the set of hosts. if _, ok := constants.Hosts[host]; !ok { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, log.Fields{"Adding host": fmt.Sprintf("%s", host)}, "New host detected") // Add this host. constants.Hosts[host] = struct{}{} // Get the power class of this host. class := PowerClass(offer) - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, + elekLog.ElektronLog.Log(elekLogTypes.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 _, ok := constants.PowerClasses[class]; !ok { diff --git a/utilities/schedUtils/schedUtils.go b/utilities/schedUtils/schedUtils.go index ffa3124..1734811 100644 --- a/utilities/schedUtils/schedUtils.go +++ b/utilities/schedUtils/schedUtils.go @@ -22,7 +22,7 @@ import ( "fmt" log "github.com/sirupsen/logrus" "github.com/spdfg/elektron/def" - "github.com/spdfg/elektron/elektronLogging" + elekLog "github.com/spdfg/elektron/elektronLogging" elekLogTypes "github.com/spdfg/elektron/elektronLogging/types" "github.com/spdfg/elektron/utilities" ) @@ -79,7 +79,7 @@ func (s *fillNextOfferCycle) apply(taskQueue []def.Task) (int, int) { for _, task := range taskQueue { numberOfTasksTraversed++ for i := *task.Instances; i > 0; i-- { - elektronLogging.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, + elekLog.ElektronLog.Log(elekLogTypes.GENERAL, log.InfoLevel, 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) {