org.apache.mesos
Interface Scheduler


public interface Scheduler

Callback interface to be implemented by frameworks' schedulers. Note that only one callback will be invoked at a time, so it is not recommended that you block within a callback because it may cause a deadlock. Each callback includes a reference to the scheduler driver that was used to run this scheduler. The reference will not change for the duration of a scheduler (i.e., from the point you do SchedulerDriver.start() to the point that SchedulerDriver.join() returns). This is intended for convenience so that a scheduler doesn't need to store a reference to the driver itself.


Method Summary
 void disconnected(SchedulerDriver driver)
          Invoked when the scheduler becomes "disconnected" from the master (e.g., the master fails and another is taking over).
 void error(SchedulerDriver driver, String message)
          Invoked when there is an unrecoverable error in the scheduler or scheduler driver.
 void executorLost(SchedulerDriver driver, org.apache.mesos.Protos.ExecutorID executorId, org.apache.mesos.Protos.SlaveID slaveId, int status)
          Invoked when an executor has exited/terminated.
 void frameworkMessage(SchedulerDriver driver, org.apache.mesos.Protos.ExecutorID executorId, org.apache.mesos.Protos.SlaveID slaveId, byte[] data)
          Invoked when an executor sends a message.
 void offerRescinded(SchedulerDriver driver, org.apache.mesos.Protos.OfferID offerId)
          Invoked when an offer is no longer valid (e.g., the slave was lost or another framework used resources in the offer).
 void registered(SchedulerDriver driver, org.apache.mesos.Protos.FrameworkID frameworkId, org.apache.mesos.Protos.MasterInfo masterInfo)
          Invoked when the scheduler successfully registers with a Mesos master.
 void reregistered(SchedulerDriver driver, org.apache.mesos.Protos.MasterInfo masterInfo)
          Invoked when the scheduler re-registers with a newly elected Mesos master.
 void resourceOffers(SchedulerDriver driver, List<org.apache.mesos.Protos.Offer> offers)
          Invoked when resources have been offered to this framework.
 void slaveLost(SchedulerDriver driver, org.apache.mesos.Protos.SlaveID slaveId)
          Invoked when a slave has been determined unreachable (e.g., machine failure, network partition).
 void statusUpdate(SchedulerDriver driver, org.apache.mesos.Protos.TaskStatus status)
          Invoked when the status of a task has changed (e.g., a slave is lost and so the task is lost, a task finishes and an executor sends a status update saying so, etc).
 

Method Detail

registered

void registered(SchedulerDriver driver,
                org.apache.mesos.Protos.FrameworkID frameworkId,
                org.apache.mesos.Protos.MasterInfo masterInfo)
Invoked when the scheduler successfully registers with a Mesos master. A unique ID (generated by the master) used for distinguishing this framework from others and MasterInfo with the ip and port of the current master are provided as arguments.


reregistered

void reregistered(SchedulerDriver driver,
                  org.apache.mesos.Protos.MasterInfo masterInfo)
Invoked when the scheduler re-registers with a newly elected Mesos master. This is only called when the scheduler has previously been registered. MasterInfo containing the updated information about the elected master is provided as an argument.


resourceOffers

void resourceOffers(SchedulerDriver driver,
                    List<org.apache.mesos.Protos.Offer> offers)
Invoked when resources have been offered to this framework. A single offer will only contain resources from a single slave. Resources associated with an offer will not be re-offered to _this_ framework until either (a) this framework has rejected those resources (see SchedulerDriver.launchTasks(java.util.Collection, java.util.Collection, org.apache.mesos.Protos.Filters)) or (b) those resources have been rescinded (see offerRescinded). Note that resources may be concurrently offered to more than one framework at a time (depending on the allocator being used). In that case, the first framework to launch tasks using those resources will be able to use them while the other frameworks will have those resources rescinded (or if a framework has already launched tasks with those resources then those tasks will fail with a TASK_LOST status and a message saying as much).


offerRescinded

void offerRescinded(SchedulerDriver driver,
                    org.apache.mesos.Protos.OfferID offerId)
Invoked when an offer is no longer valid (e.g., the slave was lost or another framework used resources in the offer). If for whatever reason an offer is never rescinded (e.g., dropped message, failing over framework, etc.), a framwork that attempts to launch tasks using an invalid offer will receive TASK_LOST status updats for those tasks (see resourceOffers(org.apache.mesos.SchedulerDriver, java.util.List)).


statusUpdate

void statusUpdate(SchedulerDriver driver,
                  org.apache.mesos.Protos.TaskStatus status)
Invoked when the status of a task has changed (e.g., a slave is lost and so the task is lost, a task finishes and an executor sends a status update saying so, etc). Note that returning from this callback _acknowledges_ receipt of this status update! If for whatever reason the scheduler aborts during this callback (or the process exits) another status update will be delivered (note, however, that this is currently not true if the slave sending the status update is lost/fails during that time).


frameworkMessage

void frameworkMessage(SchedulerDriver driver,
                      org.apache.mesos.Protos.ExecutorID executorId,
                      org.apache.mesos.Protos.SlaveID slaveId,
                      byte[] data)
Invoked when an executor sends a message. These messages are best effort; do not expect a framework message to be retransmitted in any reliable fashion.


disconnected

void disconnected(SchedulerDriver driver)
Invoked when the scheduler becomes "disconnected" from the master (e.g., the master fails and another is taking over).


slaveLost

void slaveLost(SchedulerDriver driver,
               org.apache.mesos.Protos.SlaveID slaveId)
Invoked when a slave has been determined unreachable (e.g., machine failure, network partition). Most frameworks will need to reschedule any tasks launched on this slave on a new slave.


executorLost

void executorLost(SchedulerDriver driver,
                  org.apache.mesos.Protos.ExecutorID executorId,
                  org.apache.mesos.Protos.SlaveID slaveId,
                  int status)
Invoked when an executor has exited/terminated. Note that any tasks running will have TASK_LOST status updates automagically generated.


error

void error(SchedulerDriver driver,
           String message)
Invoked when there is an unrecoverable error in the scheduler or scheduler driver. The driver will be aborted BEFORE invoking this callback.



Copyright © 2014 The Apache Software Foundation. All Rights Reserved.