2018-10-06 20:03:14 -07:00
// Copyright (C) 2018 spdf
//
// This file is part of Elektron.
//
// Elektron is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Elektron is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Elektron. If not, see <http://www.gnu.org/licenses/>.
//
2018-01-19 21:20:43 +00:00
package schedulers
import (
2018-09-30 18:23:38 -07:00
"time"
2018-01-19 17:46:35 -05:00
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
sched "github.com/mesos/mesos-go/api/v0/scheduler"
2018-09-30 18:23:38 -07:00
"gitlab.com/spdf/elektron/def"
2018-10-04 13:45:31 -04:00
elekLogDef "gitlab.com/spdf/elektron/logging/def"
2018-01-19 21:20:43 +00:00
)
// Implements mesos scheduler.
type ElectronScheduler interface {
sched . Scheduler
2018-10-04 19:24:16 -04:00
init ( opts ... SchedulerOptions )
2018-01-19 21:20:43 +00:00
// Interface for log messages.
// Every ElectronScheduler implementer should provide definitions for these functions.
// This interface serves as a template to maintain consistent log messages.
// Each of these functions are supposed to call the Log(...) that sends the
// log message type, and the log message to the corresponding channels.
// Pass the logMessageType and the logMessage to the loggers for logging.
2018-10-04 13:45:31 -04:00
Log ( logMType elekLogDef . LogMessageType , logMsg string )
2018-01-19 21:20:43 +00:00
// To be called when about to launch a task.
// Log message indicating that a task is about to start executing.
// Also, log the host on which the task is going to be launched.
LogTaskStarting ( ts * def . Task , offer * mesos . Offer )
// To be called when an offer is taken.
// Log the chosen watts attribute for the task that has fit an offer.
LogTaskWattsConsideration ( ts def . Task , host string , wattsToConsider float64 )
// To be called when offers are received from Mesos.
// Log the number of offers received and/or information about the received offers.
LogOffersReceived ( offers [ ] * mesos . Offer )
// To be called when a scheduling policy declines Mesos offers, as
// there are no tasks pending to be scheduled.
// Log the host information corresponding to the offers that were declined.
LogNoPendingTasksDeclineOffers ( offers * mesos . Offer )
// Log the number of tasks that are currently executing on the cluster.
LogNumberOfRunningTasks ( )
// To be called when a task fits a Mesos offer.
// Log information on the tasks that the new task is going to be coLocated with.
// Uses the coLocated(...) utility in helpers.go.
LogCoLocatedTasks ( slaveID string )
// Log the scheduled trace of task.
// The schedTrace includes the TaskID and the hostname of the node
// where is the task is going to be launched.
LogSchedTrace ( taskToSchedule * mesos . TaskInfo , offer * mesos . Offer )
// To be called when all the tasks have completed executing.
// Log message indicating that Electron has scheduled all the tasks.
LogTerminateScheduler ( )
// To be called when the offer is not consumed.
// Log message to indicate that the offer had insufficient resources.
LogInsufficientResourcesDeclineOffer ( offer * mesos . Offer , offerResources ... interface { } )
// To be called when offer is rescinded by Mesos.
LogOfferRescinded ( offerID * mesos . OfferID )
// To be called when Mesos agent is lost
LogSlaveLost ( slaveID * mesos . SlaveID )
// To be called when executor lost.
LogExecutorLost ( executorID * mesos . ExecutorID , slaveID * mesos . SlaveID )
// Log a mesos error
LogMesosError ( err string )
// Log an Electron error
LogElectronError ( err error )
// Log Framework message
LogFrameworkMessage ( executorID * mesos . ExecutorID , slaveID * mesos . SlaveID , message string )
// Log Framework has been registered
LogFrameworkRegistered ( frameworkID * mesos . FrameworkID , masterInfo * mesos . MasterInfo )
// Log Framework has been re-registered
LogFrameworkReregistered ( masterInfo * mesos . MasterInfo )
// Log Framework has been disconnected from the Mesos master
LogDisconnected ( )
// Log Status update of a task
LogTaskStatusUpdate ( status * mesos . TaskStatus )
2018-02-11 13:11:42 +00:00
// Log Scheduling policy switches (if any)
2018-04-17 23:44:36 +00:00
LogSchedPolicySwitch ( name string , nextPolicy SchedPolicyState )
2018-04-17 20:10:36 +00:00
// Log the computation overhead of classifying tasks in the scheduling window.
LogClsfnAndTaskDistOverhead ( overhead time . Duration )
2018-01-19 21:20:43 +00:00
}