Used WithField() and Logf() where required.
Used elektronLogger#WithField(...) for single key-value pair. Used elektronLogger#Logf(...) where formatted string is required.
This commit is contained in:
parent
3b70a13cc8
commit
12f827c0fe
7 changed files with 91 additions and 72 deletions
|
@ -250,30 +250,34 @@ func (s *BaseScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos
|
|||
|
||||
func (s *BaseScheduler) LogTaskStarting(ts *def.Task, offer *mesos.Offer) {
|
||||
if ts == nil {
|
||||
elekLog.WithFields(log.Fields{"host": fmt.Sprintf("%s", offer.GetHostname())}).Log(CONSOLE, log.InfoLevel, "TASKS STARTING...")
|
||||
elekLog.WithField("host", offer.GetHostname()).Log(CONSOLE, log.InfoLevel, "TASKS STARTING...")
|
||||
} else {
|
||||
elekLog.WithFields(log.Fields{"task": fmt.Sprintf("%s", ts.Name), "Instance": fmt.Sprintf("%d", *ts.Instances),
|
||||
"host": fmt.Sprintf("%s", offer.GetHostname())}).Log(CONSOLE, log.InfoLevel, "TASK STARTING... ")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"task": ts.Name,
|
||||
"Instance": fmt.Sprintf("%d", *ts.Instances),
|
||||
"host": offer.GetHostname(),
|
||||
}).Log(CONSOLE, log.InfoLevel, "TASK STARTING... ")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogTaskWattsConsideration(ts def.Task, host string, wattsToConsider float64) {
|
||||
elekLog.WithFields(log.Fields{"task": ts.Name, "host": host, "Watts": fmt.Sprintf("%f", wattsToConsider)}).Log(CONSOLE, log.InfoLevel, "Watts considered for ")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"task": ts.Name,
|
||||
"host": host,
|
||||
"Watts": fmt.Sprintf("%f", wattsToConsider),
|
||||
}).Log(CONSOLE, log.InfoLevel, "Watts considered for ")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogOffersReceived(offers []*mesos.Offer) {
|
||||
elekLog.WithFields(log.Fields{"Resource offers received": fmt.Sprintf("%d", len(offers))}).Log(CONSOLE,
|
||||
log.InfoLevel, "")
|
||||
elekLog.WithField("numOffers", fmt.Sprintf("%d", len(offers))).Log(CONSOLE, log.InfoLevel, "Resource offers received")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogNoPendingTasksDeclineOffers(offer *mesos.Offer) {
|
||||
elekLog.WithFields(log.Fields{"DECLINING OFFER for host": fmt.Sprintf("%s", offer.GetHostname())}).Log(CONSOLE,
|
||||
log.WarnLevel, "No tasks left to schedule ")
|
||||
elekLog.Logf(CONSOLE, log.WarnLevel, "DECLINING OFFER for host %s. No tasks left to schedule", offer.GetHostname())
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogNumberOfRunningTasks() {
|
||||
elekLog.WithFields(log.Fields{"Number of tasks still Running": fmt.Sprintf("%d", s.tasksRunning)}).Log(CONSOLE,
|
||||
log.InfoLevel, "")
|
||||
elekLog.Logf(CONSOLE, log.InfoLevel, "Number of tasks still running %d", s.tasksRunning)
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogCoLocatedTasks(slaveID string) {
|
||||
|
@ -283,12 +287,11 @@ func (s *BaseScheduler) LogCoLocatedTasks(slaveID string) {
|
|||
buffer.WriteString(fmt.Sprintln(taskName))
|
||||
}
|
||||
s.TasksRunningMutex.Unlock()
|
||||
elekLog.WithFields(log.Fields{"Colocated with": fmt.Sprintf("%s", buffer.String())}).Log(CONSOLE,
|
||||
log.InfoLevel, "")
|
||||
elekLog.WithField("Tasks", buffer.String()).Log(CONSOLE, log.InfoLevel, "Colocated with")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogSchedTrace(taskToSchedule *mesos.TaskInfo, offer *mesos.Offer) {
|
||||
elekLog.WithFields(log.Fields{offer.GetHostname(): fmt.Sprintf("%s", taskToSchedule.GetTaskId().GetValue())}).Log(SCHED_TRACE, log.InfoLevel, "")
|
||||
elekLog.WithField(offer.GetHostname(), taskToSchedule.GetTaskId().GetValue()).Log(SCHED_TRACE, log.InfoLevel, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogTerminateScheduler() {
|
||||
|
@ -299,47 +302,48 @@ func (s *BaseScheduler) LogInsufficientResourcesDeclineOffer(offer *mesos.Offer,
|
|||
offerResources ...interface{}) {
|
||||
buffer := bytes.Buffer{}
|
||||
buffer.WriteString(fmt.Sprintf("<CPU: %f, RAM: %f, Watts: %f>", offerResources...))
|
||||
elekLog.WithFields(log.Fields{"Offer Resources": fmt.Sprintf("%s", buffer.String())}).Log(CONSOLE,
|
||||
elekLog.WithField("Offer Resources", buffer.String()).Log(CONSOLE,
|
||||
log.WarnLevel, "DECLINING OFFER... Offer has insufficient resources to launch a task")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogOfferRescinded(offerID *mesos.OfferID) {
|
||||
elekLog.WithFields(log.Fields{"OfferID": fmt.Sprintf("%s", offerID)}).Log(CONSOLE,
|
||||
log.ErrorLevel, "OFFER RESCINDED")
|
||||
elekLog.WithField("OfferID", *offerID.Value).Log(CONSOLE, log.ErrorLevel, "OFFER RESCINDED")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogSlaveLost(slaveID *mesos.SlaveID) {
|
||||
elekLog.WithFields(log.Fields{"SlaveID": fmt.Sprintf("%s", slaveID)}).Log(CONSOLE,
|
||||
log.ErrorLevel, "SLAVE LOST")
|
||||
elekLog.WithField("SlaveID", *slaveID.Value).Log(CONSOLE, log.ErrorLevel, "SLAVE LOST")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogExecutorLost(executorID *mesos.ExecutorID, slaveID *mesos.SlaveID) {
|
||||
elekLog.WithFields(log.Fields{"ExecutorID": fmt.Sprintf("%s", executorID), "SlaveID": fmt.Sprintf("%s", slaveID)}).Log(CONSOLE, log.ErrorLevel, "EXECUTOR LOST")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"ExecutorID": executorID,
|
||||
"SlaveID": slaveID,
|
||||
}).Log(CONSOLE, log.ErrorLevel, "EXECUTOR LOST")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogFrameworkMessage(executorID *mesos.ExecutorID,
|
||||
slaveID *mesos.SlaveID, message string) {
|
||||
elekLog.WithFields(log.Fields{"Received Framework message from executor": executorID}).Log(CONSOLE,
|
||||
log.InfoLevel, message)
|
||||
elekLog.Logf(CONSOLE, log.InfoLevel, "Received Framework message from executor %v", executorID)
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogMesosError(err string) {
|
||||
elekLog.WithFields(log.Fields{"MESOS CONSOLE": fmt.Sprintf("%v", err)}).Log(CONSOLE,
|
||||
log.ErrorLevel, "")
|
||||
elekLog.Logf(CONSOLE, log.ErrorLevel, "MESOS CONSOLE %v", err)
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogElectronError(err error) {
|
||||
elekLog.WithFields(log.Fields{"ELECTRON CONSOLE": fmt.Sprintf("%v", err)}).Log(CONSOLE, log.ErrorLevel, "")
|
||||
elekLog.Logf(CONSOLE, log.ErrorLevel, "ELEKTRON CONSOLE %v", err)
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogFrameworkRegistered(frameworkID *mesos.FrameworkID,
|
||||
masterInfo *mesos.MasterInfo) {
|
||||
elekLog.WithFields(log.Fields{"frameworkID": fmt.Sprintf("%s", frameworkID), "master": fmt.Sprintf("%v", masterInfo)}).Log(CONSOLE, log.InfoLevel, "FRAMEWORK REGISTERED!")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"frameworkID": frameworkID,
|
||||
"master": fmt.Sprintf("%v", masterInfo),
|
||||
}).Log(CONSOLE, log.InfoLevel, "FRAMEWORK REGISTERED!")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogFrameworkReregistered(masterInfo *mesos.MasterInfo) {
|
||||
elekLog.WithFields(log.Fields{"master": fmt.Sprintf("%v", masterInfo)}).Log(CONSOLE,
|
||||
log.InfoLevel, "Framework re-registered")
|
||||
elekLog.WithField("master", fmt.Sprintf("%v", masterInfo)).Log(CONSOLE, log.InfoLevel, "Framework re-registered")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogDisconnected() {
|
||||
|
@ -355,12 +359,15 @@ func (s *BaseScheduler) LogTaskStatusUpdate(status *mesos.TaskStatus) {
|
|||
default:
|
||||
level = log.InfoLevel
|
||||
}
|
||||
elekLog.WithFields(log.Fields{"task": fmt.Sprintf("%s", *status.TaskId.Value), "state": NameFor(status.State)}).Log(CONSOLE, level, "Task Status received")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"task": *status.TaskId.Value,
|
||||
"state": NameFor(status.State),
|
||||
}).Log(CONSOLE, level, "Task Status received")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogSchedPolicySwitch(name string, nextPolicy SchedPolicyState) {
|
||||
logSPS := func() {
|
||||
elekLog.WithFields(log.Fields{"Name": name}).Log(SPS, log.InfoLevel, "")
|
||||
elekLog.WithField("Name", name).Log(SPS, log.InfoLevel, "")
|
||||
}
|
||||
if s.hasReceivedResourceOffers && (s.curSchedPolicy != nextPolicy) {
|
||||
logSPS()
|
||||
|
@ -369,10 +376,13 @@ 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.
|
||||
elekLog.WithFields(log.Fields{"Window size": fmt.Sprintf("%d", s.schedWindowSize), "Name": name}).Log(SCHED_WINDOW, log.InfoLevel, "")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"Window size": fmt.Sprintf("%d", s.schedWindowSize),
|
||||
"Name": name,
|
||||
}).Log(SCHED_WINDOW, log.InfoLevel, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogClsfnAndTaskDistOverhead(overhead time.Duration) {
|
||||
// Logging the overhead in microseconds.
|
||||
elekLog.WithFields(log.Fields{"Overhead in microseconds": fmt.Sprintf("%f", float64(overhead.Nanoseconds())/1000.0)}).Log(CLSFN_TASKDISTR_OVERHEAD, log.InfoLevel, "")
|
||||
elekLog.WithField("Overhead in microseconds", fmt.Sprintf("%f", float64(overhead.Nanoseconds())/1000.0)).Log(CLSFN_TASKDISTR_OVERHEAD, log.InfoLevel, "")
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
func coLocated(tasks map[string]bool, s BaseScheduler) {
|
||||
|
||||
for _, task := range tasks {
|
||||
elekLog.WithFields(log.Fields{"Task": task}).Log(CONSOLE, log.InfoLevel, "")
|
||||
elekLog.WithField("Task", fmt.Sprintf("%v", task)).Log(CONSOLE, log.InfoLevel, "")
|
||||
}
|
||||
|
||||
elekLog.Log(CONSOLE, log.InfoLevel, "---------------------")
|
||||
|
|
|
@ -90,8 +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))
|
||||
elekLog.WithFields(log.Fields{"Task Distribution": fmt.Sprintf("%f", taskDist)}).Log(CONSOLE,
|
||||
log.InfoLevel, "Switching... ")
|
||||
elekLog.WithField("Task Distribution", fmt.Sprintf("%f", taskDist)).Log(CONSOLE, log.InfoLevel, "Switching... ")
|
||||
if err != nil {
|
||||
// All the tasks in the window were only classified into 1 cluster.
|
||||
// Max-Min and Max-GreedyMins would work the same way as Bin-Packing for this situation.
|
||||
|
@ -219,9 +218,11 @@ func (bsps *baseSchedPolicyState) SwitchIfNecessary(spc SchedPolicyContext) {
|
|||
switchToPolicyName = switchBasedOn[baseSchedRef.schedPolSwitchCriteria](baseSchedRef)
|
||||
} else {
|
||||
// We continue working with the currently deployed scheduling policy.
|
||||
log.Println("Continuing with the current scheduling policy...")
|
||||
log.Printf("TasksScheduled[%d], SchedWindowSize[%d]", bsps.numTasksScheduled,
|
||||
baseSchedRef.schedWindowSize)
|
||||
elekLog.Log(CONSOLE, log.InfoLevel, "Continuing with the current scheduling policy...")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"TasksScheduled": fmt.Sprintf("%d", bsps.numTasksScheduled),
|
||||
"SchedWindowSize": fmt.Sprintf("%d", baseSchedRef.schedWindowSize),
|
||||
}).Log(CONSOLE, log.InfoLevel, "")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -233,9 +234,11 @@ func (bsps *baseSchedPolicyState) SwitchIfNecessary(spc SchedPolicyContext) {
|
|||
bsps.numTasksScheduled = 0
|
||||
} else {
|
||||
// We continue working with the currently deployed scheduling policy.
|
||||
log.Println("Continuing with the current scheduling policy...")
|
||||
log.Printf("TasksScheduled[%d], SchedWindowSize[%d]", bsps.numTasksScheduled,
|
||||
baseSchedRef.schedWindowSize)
|
||||
elekLog.Log(CONSOLE, log.InfoLevel, "Continuing with the current scheduling policy...")
|
||||
elekLog.WithFields(log.Fields{
|
||||
"TasksScheduled": fmt.Sprintf("%d", bsps.numTasksScheduled),
|
||||
"SchedWindowSize": fmt.Sprintf("%d", baseSchedRef.schedWindowSize),
|
||||
}).Log(CONSOLE, log.InfoLevel, "")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue