public class MesosSchedulerDriver extends Object implements SchedulerDriver
Note that scheduler failover is supported in Mesos. After a
scheduler is registered with Mesos it may failover (to a new
process on the same machine or across multiple machines) by
creating a new driver with the ID given to it in Scheduler.registered(org.apache.mesos.SchedulerDriver, org.apache.mesos.Protos.FrameworkID, org.apache.mesos.Protos.MasterInfo).
The driver is responsible for invoking the Scheduler callbacks as it communicates with the Mesos master.
Note that blocking on the MesosSchedulerDriver (e.g., via join()) doesn't affect the scheduler callbacks in anyway because
they are handled by a different thread.
Note that the driver uses GLOG to do its own logging. GLOG flags can be set via environment variables, prefixing the flag name with "GLOG_", e.g., "GLOG_v=1". For Mesos specific logging flags see src/logging/flags.hpp. Mesos flags can also be set via environment variables, prefixing the flag name with "MESOS_", e.g., "MESOS_QUIET=1".
See src/examples/java/TestFramework.java for an example of using the MesosSchedulerDriver.
| Constructor and Description |
|---|
MesosSchedulerDriver(Scheduler scheduler,
org.apache.mesos.Protos.FrameworkInfo framework,
String master)
Creates a new driver for the specified scheduler.
|
MesosSchedulerDriver(Scheduler scheduler,
org.apache.mesos.Protos.FrameworkInfo framework,
String master,
org.apache.mesos.Protos.Credential credential)
Same as the above constructor, except that it accepts 'credential'
as a parameter.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.mesos.Protos.Status |
abort()
Aborts the driver so that no more callbacks can be made to the
scheduler.
|
org.apache.mesos.Protos.Status |
declineOffer(org.apache.mesos.Protos.OfferID offerId)
Declines an offer in its entirety.
|
org.apache.mesos.Protos.Status |
declineOffer(org.apache.mesos.Protos.OfferID offerId,
org.apache.mesos.Protos.Filters filters)
Declines an offer in its entirety and applies the specified
filters on the resources (see mesos.proto for a description of
Filters).
|
protected void |
finalize() |
protected void |
initialize() |
org.apache.mesos.Protos.Status |
join()
Waits for the driver to be stopped or aborted, possibly
blocking the current thread indefinitely.
|
org.apache.mesos.Protos.Status |
killTask(org.apache.mesos.Protos.TaskID taskId)
Kills the specified task.
|
org.apache.mesos.Protos.Status |
launchTasks(Collection<org.apache.mesos.Protos.OfferID> offerIds,
Collection<org.apache.mesos.Protos.TaskInfo> tasks)
Launches the given set of tasks.
|
org.apache.mesos.Protos.Status |
launchTasks(Collection<org.apache.mesos.Protos.OfferID> offerIds,
Collection<org.apache.mesos.Protos.TaskInfo> tasks,
org.apache.mesos.Protos.Filters filters)
Launches the given set of tasks on a set of offers.
|
org.apache.mesos.Protos.Status |
launchTasks(org.apache.mesos.Protos.OfferID offerId,
Collection<org.apache.mesos.Protos.TaskInfo> tasks) |
org.apache.mesos.Protos.Status |
launchTasks(org.apache.mesos.Protos.OfferID offerId,
Collection<org.apache.mesos.Protos.TaskInfo> tasks,
org.apache.mesos.Protos.Filters filters) |
org.apache.mesos.Protos.Status |
reconcileTasks(Collection<org.apache.mesos.Protos.TaskStatus> statuses)
Allows the framework to query the status for non-terminal tasks.
|
org.apache.mesos.Protos.Status |
requestResources(Collection<org.apache.mesos.Protos.Request> requests)
Requests resources from Mesos (see mesos.proto for a description
of Request and how, for example, to request resources
from specific slaves).
|
org.apache.mesos.Protos.Status |
reviveOffers()
Removes all filters, previously set by the framework (via
SchedulerDriver.launchTasks(java.util.Collection<org.apache.mesos.Protos.OfferID>, java.util.Collection<org.apache.mesos.Protos.TaskInfo>, org.apache.mesos.Protos.Filters)). |
org.apache.mesos.Protos.Status |
run()
Starts and immediately joins (i.e., blocks on) the driver.
|
org.apache.mesos.Protos.Status |
sendFrameworkMessage(org.apache.mesos.Protos.ExecutorID executorId,
org.apache.mesos.Protos.SlaveID slaveId,
byte[] data)
Sends a message from the framework to one of its executors.
|
org.apache.mesos.Protos.Status |
start()
Starts the scheduler driver.
|
org.apache.mesos.Protos.Status |
stop()
Stops the scheduler driver assuming no failover.
|
org.apache.mesos.Protos.Status |
stop(boolean failover)
Stops the scheduler driver.
|
public MesosSchedulerDriver(Scheduler scheduler, org.apache.mesos.Protos.FrameworkInfo framework, String master)
host:port
zk://host1:port1,host2:port2,.../path
zk://username:password@host1:port1,host2:port2,.../path
file:///path/to/file (where file contains one of the above)
The driver will attempt to "failover" if the specified FrameworkInfo includes a valid FrameworkID.
Any Mesos configuration options are read from environment variables, as well as any configuration files found through the environment variables.
scheduler - The scheduler implementation which callbacks are invoked
upon scheduler events.framework - The frameworkInfo describing the current framework.master - The address to the currently active Mesos master.public MesosSchedulerDriver(Scheduler scheduler, org.apache.mesos.Protos.FrameworkInfo framework, String master, org.apache.mesos.Protos.Credential credential)
scheduler - The scheduler implementation which callbacks are invoked
upon scheduler events.framework - The frameworkInfo describing the current framework.master - The address to the currently active Mesos master.credential - The credentials that will be used used to authenticate
calls from this scheduler.public org.apache.mesos.Protos.Status start()
SchedulerDriverstart in interface SchedulerDriverProtos.Statuspublic org.apache.mesos.Protos.Status stop(boolean failover)
SchedulerDriverstop in interface SchedulerDriverfailover - Whether framework failover is expected.Protos.Statuspublic org.apache.mesos.Protos.Status stop()
SchedulerDriverSchedulerDriver.stop(boolean)
for more details.stop in interface SchedulerDriverpublic org.apache.mesos.Protos.Status abort()
SchedulerDriverSchedulerDriver.join(), see below), and instantiate
and start another driver if desired (from within the same
process).abort in interface SchedulerDriverpublic org.apache.mesos.Protos.Status join()
SchedulerDriverjoin in interface SchedulerDriverpublic org.apache.mesos.Protos.Status run()
SchedulerDriverrun in interface SchedulerDriverpublic org.apache.mesos.Protos.Status requestResources(Collection<org.apache.mesos.Protos.Request> requests)
SchedulerDriverScheduler.resourceOffers(org.apache.mesos.SchedulerDriver, java.util.List<org.apache.mesos.Protos.Offer>) callback,
asynchronously.requestResources in interface SchedulerDriverrequests - The resource requests.Protos.Request,
Protos.Statuspublic org.apache.mesos.Protos.Status launchTasks(org.apache.mesos.Protos.OfferID offerId,
Collection<org.apache.mesos.Protos.TaskInfo> tasks)
launchTasks in interface SchedulerDriverofferId - The offer ID.tasks - The collection of tasks to be launched.public org.apache.mesos.Protos.Status launchTasks(org.apache.mesos.Protos.OfferID offerId,
Collection<org.apache.mesos.Protos.TaskInfo> tasks,
org.apache.mesos.Protos.Filters filters)
launchTasks in interface SchedulerDriverofferId - The offer ID.tasks - The collection of tasks to be launched.filters - The filters to set for any remaining resources.public org.apache.mesos.Protos.Status launchTasks(Collection<org.apache.mesos.Protos.OfferID> offerIds, Collection<org.apache.mesos.Protos.TaskInfo> tasks)
SchedulerDriverlaunchTasks in interface SchedulerDriverofferIds - The collection of offer IDs.tasks - The collection of tasks to be launched.public org.apache.mesos.Protos.Status launchTasks(Collection<org.apache.mesos.Protos.OfferID> offerIds, Collection<org.apache.mesos.Protos.TaskInfo> tasks, org.apache.mesos.Protos.Filters filters)
SchedulerDriverSchedulerDriver.declineOffer(org.apache.mesos.Protos.OfferID, org.apache.mesos.Protos.Filters)).launchTasks in interface SchedulerDriverofferIds - The collection of offer IDs.tasks - The collection of tasks to be launched.filters - The filters to set for any remaining resources.Protos.OfferID,
Protos.TaskInfo,
Protos.Filters,
Protos.Statuspublic org.apache.mesos.Protos.Status killTask(org.apache.mesos.Protos.TaskID taskId)
SchedulerDriverkillTask in interface SchedulerDrivertaskId - The ID of the task to be killed.public org.apache.mesos.Protos.Status declineOffer(org.apache.mesos.Protos.OfferID offerId)
SchedulerDriverdeclineOffer in interface SchedulerDriverofferId - The ID of the offer to be declined.Protos.OfferID,
Protos.Statuspublic org.apache.mesos.Protos.Status declineOffer(org.apache.mesos.Protos.OfferID offerId,
org.apache.mesos.Protos.Filters filters)
SchedulerDriverScheduler.resourceOffers(org.apache.mesos.SchedulerDriver, java.util.List<org.apache.mesos.Protos.Offer>)
callback.declineOffer in interface SchedulerDriverofferId - The ID of the offer to be declined.filters - The filters to set for any remaining resources.Protos.OfferID,
Protos.Filters,
Protos.Statuspublic org.apache.mesos.Protos.Status reviveOffers()
SchedulerDriverSchedulerDriver.launchTasks(java.util.Collection<org.apache.mesos.Protos.OfferID>, java.util.Collection<org.apache.mesos.Protos.TaskInfo>, org.apache.mesos.Protos.Filters)). This enables the framework to receive offers
from those filtered slaves.reviveOffers in interface SchedulerDriverProtos.Statuspublic org.apache.mesos.Protos.Status sendFrameworkMessage(org.apache.mesos.Protos.ExecutorID executorId,
org.apache.mesos.Protos.SlaveID slaveId,
byte[] data)
SchedulerDriversendFrameworkMessage in interface SchedulerDriverexecutorId - The ID of the executor to send the message to.slaveId - The ID of the slave that is running the executor.data - The message.Protos.ExecutorID,
Protos.SlaveIDpublic org.apache.mesos.Protos.Status reconcileTasks(Collection<org.apache.mesos.Protos.TaskStatus> statuses)
SchedulerDriverreconcileTasks in interface SchedulerDriverstatuses - The collection of non-terminal TaskStatuses to reconcile.Protos.TaskStatus,
Protos.SlaveIDprotected void initialize()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.