Search code examples
rx-javamesos

mesos-rxjava -- kill tasks and shutdown scheduler


I'm looking for a way to kill a Mesos task or shutdown the framework in the mesos-rxjava library. It appears that after subscribe(), the only opportunities to send calls to Mesos are in response to events from Mesos. I've been able to integrate Fenzo in a separate scheduling loop by responding to offer leases with an Observable from a Promise and storing that promise for the Fenzo loop, so it's probably possible to do the same with the "task started" update event and keep the promise around to kill that task, but then you can't cancel a task that hasn't started yet, and it doesn't solve for shutting down the framework. Or maybe there's a way to use the library's authentication to simply send the HTTP request in a non-reactive way? Is there a cleaner solution I'm missing?


Solution

  • I think what you're looking for here is the TEARDOWN Call [1], when this call is sent to mesos from the scheduler it will initiate a full shutdown of the framework across the cluster.

    By weaving a Subject into the Observable (you can see an example of weaving Observables together in link 2 below) you provide to the mesos-rxjava client you can provide yourself with a handle to be able to send Calls that aren't a direct reaction to an Event. A link 3 below is a link to a Github issue explaining this a bit more.

    [1] https://github.com/apache/mesos/blob/master/docs/scheduler-http-api.md#teardown
    [2] https://github.com/mesosphere/mesos-rxjava/blob/master/mesos-rxjava-example/mesos-rxjava-example-framework/src/main/java/com/mesosphere/mesos/rx/java/example/framework/sleepy/Sleepy.java#L140
    [3] https://github.com/mesosphere/mesos-rxjava/pull/63#issuecomment-235043568