public class MesosSchedulerDriver extends java.lang.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,
Protos.FrameworkInfo framework,
java.util.Collection<java.lang.String> suppressedRoles,
java.lang.String master,
boolean implicitAcknowledgements)
Same as the other constructors, except that it accepts the newly
introduced 'suppressedRoles' parameter.
|
MesosSchedulerDriver(Scheduler scheduler,
Protos.FrameworkInfo framework,
java.util.Collection<java.lang.String> suppressedRoles,
java.lang.String master,
boolean implicitAcknowledgements,
Protos.Credential credential)
Same as the other constructors, except that it accepts the newly
introduced 'suppressedRoles' parameter.
|
MesosSchedulerDriver(Scheduler scheduler,
Protos.FrameworkInfo framework,
java.lang.String master)
Creates a new driver for the specified scheduler.
|
MesosSchedulerDriver(Scheduler scheduler,
Protos.FrameworkInfo framework,
java.lang.String master,
boolean implicitAcknowledgements)
Same as the other constructors, except that it accepts the newly
introduced 'implicitAcknowledgements' parameter.
|
MesosSchedulerDriver(Scheduler scheduler,
Protos.FrameworkInfo framework,
java.lang.String master,
boolean implicitAcknowledgements,
Protos.Credential credential)
Same as the other constructors, except that it accepts the newly
introduced 'implicitAcknowledgements' and 'credentials' parameters.
|
MesosSchedulerDriver(Scheduler scheduler,
Protos.FrameworkInfo framework,
java.lang.String master,
Protos.Credential credential)
Same as the other constructors, except that it accepts the newly
introduced 'credential' parameter.
|
| Modifier and Type | Method and Description |
|---|---|
Protos.Status |
abort()
Aborts the driver so that no more callbacks can be made to the
scheduler.
|
Protos.Status |
acceptOffers(java.util.Collection<Protos.OfferID> offerIds,
java.util.Collection<Protos.Offer.Operation> operations,
Protos.Filters filters)
Accepts the given offers and performs a sequence of operations on
those accepted offers.
|
Protos.Status |
acknowledgeStatusUpdate(Protos.TaskStatus status)
Acknowledges the status update.
|
Protos.Status |
declineOffer(Protos.OfferID offerId)
Declines an offer in its entirety.
|
Protos.Status |
declineOffer(Protos.OfferID offerId,
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() |
Protos.Status |
join()
Waits for the driver to be stopped or aborted, possibly
blocking the current thread indefinitely.
|
Protos.Status |
killTask(Protos.TaskID taskId)
Kills the specified task.
|
Protos.Status |
launchTasks(java.util.Collection<Protos.OfferID> offerIds,
java.util.Collection<Protos.TaskInfo> tasks)
Launches the given set of tasks.
|
Protos.Status |
launchTasks(java.util.Collection<Protos.OfferID> offerIds,
java.util.Collection<Protos.TaskInfo> tasks,
Protos.Filters filters)
Launches the given set of tasks.
|
Protos.Status |
launchTasks(Protos.OfferID offerId,
java.util.Collection<Protos.TaskInfo> tasks) |
Protos.Status |
launchTasks(Protos.OfferID offerId,
java.util.Collection<Protos.TaskInfo> tasks,
Protos.Filters filters) |
Protos.Status |
reconcileTasks(java.util.Collection<Protos.TaskStatus> statuses)
Allows the framework to query the status for non-terminal tasks.
|
Protos.Status |
requestResources(java.util.Collection<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).
|
Protos.Status |
reviveOffers()
Removes all filters previously set by the framework (via launchTasks()
or declineOffer()) and clears the set of suppressed roles.
|
Protos.Status |
reviveOffers(java.util.Collection<java.lang.String> roles)
Removes filters for the specified roles and removes these roles from
the suppressed set.
|
Protos.Status |
run()
Starts and immediately joins (i.e., blocks on) the driver.
|
Protos.Status |
sendFrameworkMessage(Protos.ExecutorID executorId,
Protos.SlaveID slaveId,
byte[] data)
Sends a message from the framework to one of its executors.
|
Protos.Status |
start()
Starts the scheduler driver.
|
Protos.Status |
stop()
Stops the scheduler driver assuming no failover.
|
Protos.Status |
stop(boolean failover)
Stops the scheduler driver.
|
Protos.Status |
suppressOffers()
Informs Mesos master to stop sending offers to the framework (i.e.
|
Protos.Status |
suppressOffers(java.util.Collection<java.lang.String> roles)
Adds the roles to the suppressed set.
|
Protos.Status |
updateFramework(Protos.FrameworkInfo frameworkInfo,
java.util.Collection<java.lang.String> suppressedRoles)
Deprecated.
Replaced by
#updateFramework(FrameworkInfo, Collection, OfferConstraints)
NOTE: The underlying JNI method exists only to maintain compatibility
of newer versions of libmesos-java.so with older versions of mesos.jar |
Protos.Status |
updateFramework(Protos.FrameworkInfo frameworkInfo,
java.util.Collection<java.lang.String> suppressedRoles,
org.apache.mesos.scheduler.Protos.OfferConstraints offerConstraints) |
public MesosSchedulerDriver(Scheduler scheduler, Protos.FrameworkInfo framework, java.lang.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, Protos.FrameworkInfo framework, java.lang.String master, 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 MesosSchedulerDriver(Scheduler scheduler, Protos.FrameworkInfo framework, java.lang.String master, boolean implicitAcknowledgements)
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.implicitAcknowledgements - Whether the driver should send
acknowledgements on behalf of the scheduler. Setting this to
false allows schedulers to perform their own acknowledgements,
which enables asynchronous / batch processing of status updates.public MesosSchedulerDriver(Scheduler scheduler, Protos.FrameworkInfo framework, java.lang.String master, boolean implicitAcknowledgements, 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.implicitAcknowledgements - Whether the driver should send
acknowledgements on behalf of the scheduler. Setting this to
false allows schedulers to perform their own acknowledgements,
which enables asynchronous / batch processing of status updates.credential - The credentials that will be used used to authenticate
calls from this scheduler.public MesosSchedulerDriver(Scheduler scheduler, Protos.FrameworkInfo framework, java.util.Collection<java.lang.String> suppressedRoles, java.lang.String master, boolean implicitAcknowledgements)
scheduler - The scheduler implementation which callbacks are invoked
upon scheduler events.framework - The frameworkInfo describing the current framework.suppressedRoles - The collection of initially suppressed roles.master - The address to the currently active Mesos master.implicitAcknowledgements - Whether the driver should send
acknowledgements on behalf of the scheduler. Setting this to
false allows schedulers to perform their own acknowledgements,
which enables asynchronous / batch processing of status updates.public MesosSchedulerDriver(Scheduler scheduler, Protos.FrameworkInfo framework, java.util.Collection<java.lang.String> suppressedRoles, java.lang.String master, boolean implicitAcknowledgements, Protos.Credential credential)
scheduler - The scheduler implementation which callbacks are invoked
upon scheduler events.framework - The frameworkInfo describing the current framework.suppressedRoles - The collection of initially suppressed roles.master - The address to the currently active Mesos master.implicitAcknowledgements - Whether the driver should send
acknowledgements on behalf of the scheduler. Setting this to
false allows schedulers to perform their own acknowledgements,
which enables asynchronous / batch processing of status updates.credential - The credentials that will be used used to authenticate
calls from this scheduler.public Protos.Status start()
SchedulerDriverstart in interface SchedulerDriverProtos.Statuspublic Protos.Status stop(boolean failover)
SchedulerDriverstop in interface SchedulerDriverfailover - Whether framework failover is expected.Protos.Statuspublic Protos.Status stop()
SchedulerDriverSchedulerDriver.stop(boolean)
for more details.stop in interface SchedulerDriverpublic Protos.Status abort()
SchedulerDriverSchedulerDriver.join(), see below), and instantiate
and start another driver if desired (from within the same
process).abort in interface SchedulerDriverpublic Protos.Status join()
SchedulerDriverjoin in interface SchedulerDriverpublic Protos.Status run()
SchedulerDriverrun in interface SchedulerDriverpublic Protos.Status requestResources(java.util.Collection<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 Protos.Status launchTasks(Protos.OfferID offerId, java.util.Collection<Protos.TaskInfo> tasks)
launchTasks in interface SchedulerDriverofferId - The offer ID.tasks - The collection of tasks to be launched.public Protos.Status launchTasks(Protos.OfferID offerId, java.util.Collection<Protos.TaskInfo> tasks, 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 Protos.Status launchTasks(java.util.Collection<Protos.OfferID> offerIds, java.util.Collection<Protos.TaskInfo> tasks)
SchedulerDriverlaunchTasks in interface SchedulerDriverofferIds - The collection of offer IDs.tasks - The collection of tasks to be launched.public Protos.Status launchTasks(java.util.Collection<Protos.OfferID> offerIds, java.util.Collection<Protos.TaskInfo> tasks, 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 Protos.Status killTask(Protos.TaskID taskId)
SchedulerDriverkillTask in interface SchedulerDrivertaskId - The ID of the task to be killed.public Protos.Status acceptOffers(java.util.Collection<Protos.OfferID> offerIds, java.util.Collection<Protos.Offer.Operation> operations, Protos.Filters filters)
SchedulerDriveracceptOffers in interface SchedulerDriverofferIds - The collection of offer IDs.operations - The collection of offer operations to perform.filters - The filters to set for any remaining resources.Protos.OfferID,
Offer.Operation,
Protos.Filters,
Protos.Statuspublic Protos.Status declineOffer(Protos.OfferID offerId)
SchedulerDriverdeclineOffer in interface SchedulerDriverofferId - The ID of the offer to be declined.Protos.OfferID,
Protos.Statuspublic Protos.Status declineOffer(Protos.OfferID offerId, 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 Protos.Status reviveOffers()
SchedulerDriverreviveOffers in interface SchedulerDriverProtos.Statuspublic Protos.Status reviveOffers(java.util.Collection<java.lang.String> roles)
SchedulerDriverreviveOffers in interface SchedulerDriverroles - The collection of the framework roles to be revivied.
If empty, this method does nothing.Protos.Statuspublic Protos.Status suppressOffers()
SchedulerDriversuppressOffers in interface SchedulerDriverProtos.Statuspublic Protos.Status suppressOffers(java.util.Collection<java.lang.String> roles)
SchedulerDriversuppressOffers in interface SchedulerDriverroles - The collection of framework roles to be suppressed.
If empty, the method does nothing.Protos.Statuspublic Protos.Status acknowledgeStatusUpdate(Protos.TaskStatus status)
SchedulerDriveracknowledgeStatusUpdate in interface SchedulerDriverstatus - The status to acknowledge.Protos.TaskStatuspublic Protos.Status sendFrameworkMessage(Protos.ExecutorID executorId, 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 Protos.Status reconcileTasks(java.util.Collection<Protos.TaskStatus> statuses)
SchedulerDriverreconcileTasks in interface SchedulerDriverstatuses - The collection of non-terminal TaskStatuses to reconcile.Protos.TaskStatus,
Protos.SlaveID@Deprecated public Protos.Status updateFramework(Protos.FrameworkInfo frameworkInfo, java.util.Collection<java.lang.String> suppressedRoles)
#updateFramework(FrameworkInfo, Collection, OfferConstraints)
NOTE: The underlying JNI method exists only to maintain compatibility
of newer versions of libmesos-java.so with older versions of mesos.jarupdateFramework in interface SchedulerDriverpublic Protos.Status updateFramework(Protos.FrameworkInfo frameworkInfo, java.util.Collection<java.lang.String> suppressedRoles, org.apache.mesos.scheduler.Protos.OfferConstraints offerConstraints)
updateFramework in interface SchedulerDriverprotected void initialize()
protected void finalize()
finalize in class java.lang.Object